blob: b942019461a1524e73f8dcba3b9aaa3f39fe9484 [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;
792 }
793 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
794}
795
796/*
Takashi Iwaid88897e2008-10-31 15:01:37 +0100797 */
798static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
799{
800 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
801 return;
802 spec->mixers[spec->num_mixers++] = mix;
803}
804
805static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
806{
807 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
808 return;
809 spec->init_verbs[spec->num_init_verbs++] = verb;
810}
811
Takashi Iwaidaead532008-11-28 12:55:36 +0100812#ifdef CONFIG_PROC_FS
813/*
814 * hook for proc
815 */
816static void print_realtek_coef(struct snd_info_buffer *buffer,
817 struct hda_codec *codec, hda_nid_t nid)
818{
819 int coeff;
820
821 if (nid != 0x20)
822 return;
823 coeff = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PROC_COEF, 0);
824 snd_iprintf(buffer, " Processing Coefficient: 0x%02x\n", coeff);
825 coeff = snd_hda_codec_read(codec, nid, 0,
826 AC_VERB_GET_COEF_INDEX, 0);
827 snd_iprintf(buffer, " Coefficient Index: 0x%02x\n", coeff);
828}
829#else
830#define print_realtek_coef NULL
831#endif
832
Takashi Iwaid88897e2008-10-31 15:01:37 +0100833/*
Kailang Yangdf694da2005-12-05 19:42:22 +0100834 * set up from the preset table
835 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200836static void setup_preset(struct alc_spec *spec,
837 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100838{
839 int i;
840
841 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100842 add_mixer(spec, preset->mixers[i]);
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100843 spec->cap_mixer = preset->cap_mixer;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200844 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
845 i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100846 add_verb(spec, preset->init_verbs[i]);
Kailang Yangea1fb292008-08-26 12:58:38 +0200847
Kailang Yangdf694da2005-12-05 19:42:22 +0100848 spec->channel_mode = preset->channel_mode;
849 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200850 spec->need_dac_fix = preset->need_dac_fix;
Kailang Yangdf694da2005-12-05 19:42:22 +0100851
852 spec->multiout.max_channels = spec->channel_mode[0].channels;
853
854 spec->multiout.num_dacs = preset->num_dacs;
855 spec->multiout.dac_nids = preset->dac_nids;
856 spec->multiout.dig_out_nid = preset->dig_out_nid;
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800857 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100858 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200859
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200860 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200861 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200862 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100863 spec->input_mux = preset->input_mux;
864
865 spec->num_adc_nids = preset->num_adc_nids;
866 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100867 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100868 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100869
870 spec->unsol_event = preset->unsol_event;
871 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200872#ifdef CONFIG_SND_HDA_POWER_SAVE
873 spec->loopback.amplist = preset->loopbacks;
874#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100875}
876
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200877/* Enable GPIO mask and set output */
878static struct hda_verb alc_gpio1_init_verbs[] = {
879 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
880 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
881 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
882 { }
883};
884
885static struct hda_verb alc_gpio2_init_verbs[] = {
886 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
887 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
888 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
889 { }
890};
891
Kailang Yangbdd148a2007-05-08 15:19:08 +0200892static struct hda_verb alc_gpio3_init_verbs[] = {
893 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
894 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
895 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
896 { }
897};
898
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200899/*
900 * Fix hardware PLL issue
901 * On some codecs, the analog PLL gating control must be off while
902 * the default value is 1.
903 */
904static void alc_fix_pll(struct hda_codec *codec)
905{
906 struct alc_spec *spec = codec->spec;
907 unsigned int val;
908
909 if (!spec->pll_nid)
910 return;
911 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
912 spec->pll_coef_idx);
913 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
914 AC_VERB_GET_PROC_COEF, 0);
915 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
916 spec->pll_coef_idx);
917 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
918 val & ~(1 << spec->pll_coef_bit));
919}
920
921static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
922 unsigned int coef_idx, unsigned int coef_bit)
923{
924 struct alc_spec *spec = codec->spec;
925 spec->pll_nid = nid;
926 spec->pll_coef_idx = coef_idx;
927 spec->pll_coef_bit = coef_bit;
928 alc_fix_pll(codec);
929}
930
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200931static void alc_automute_pin(struct hda_codec *codec)
Kailang Yangc9b58002007-10-16 14:30:01 +0200932{
933 struct alc_spec *spec = codec->spec;
Kailang Yangc9b58002007-10-16 14:30:01 +0200934 unsigned int present;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200935 unsigned int nid = spec->autocfg.hp_pins[0];
936 int i;
Kailang Yangc9b58002007-10-16 14:30:01 +0200937
938 /* need to execute and sync at first */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200939 snd_hda_codec_read(codec, nid, 0, AC_VERB_SET_PIN_SENSE, 0);
940 present = snd_hda_codec_read(codec, nid, 0,
Kailang Yangc9b58002007-10-16 14:30:01 +0200941 AC_VERB_GET_PIN_SENSE, 0);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200942 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
943 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
944 nid = spec->autocfg.speaker_pins[i];
945 if (!nid)
946 break;
947 snd_hda_codec_write(codec, nid, 0,
948 AC_VERB_SET_PIN_WIDGET_CONTROL,
949 spec->jack_present ? 0 : PIN_OUT);
950 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200951}
952
Takashi Iwai4605b712008-10-31 14:18:24 +0100953#if 0 /* it's broken in some acses -- temporarily disabled */
Kailang Yang7fb0d782008-10-15 11:12:35 +0200954static void alc_mic_automute(struct hda_codec *codec)
955{
956 struct alc_spec *spec = codec->spec;
957 unsigned int present;
958 unsigned int mic_nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
959 unsigned int fmic_nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
960 unsigned int mix_nid = spec->capsrc_nids[0];
961 unsigned int capsrc_idx_mic, capsrc_idx_fmic;
962
963 capsrc_idx_mic = mic_nid - 0x18;
964 capsrc_idx_fmic = fmic_nid - 0x18;
965 present = snd_hda_codec_read(codec, mic_nid, 0,
966 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
967 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
968 0x7000 | (capsrc_idx_mic << 8) | (present ? 0 : 0x80));
969 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
970 0x7000 | (capsrc_idx_fmic << 8) | (present ? 0x80 : 0));
971 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, capsrc_idx_fmic,
972 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
973}
Takashi Iwai4605b712008-10-31 14:18:24 +0100974#else
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100975#define alc_mic_automute(codec) do {} while(0) /* NOP */
Takashi Iwai4605b712008-10-31 14:18:24 +0100976#endif /* disabled */
Kailang Yang7fb0d782008-10-15 11:12:35 +0200977
Kailang Yangc9b58002007-10-16 14:30:01 +0200978/* unsolicited event for HP jack sensing */
979static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
980{
981 if (codec->vendor_id == 0x10ec0880)
982 res >>= 28;
983 else
984 res >>= 26;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200985 switch (res) {
986 case ALC880_HP_EVENT:
987 alc_automute_pin(codec);
988 break;
989 case ALC880_MIC_EVENT:
Kailang Yang7fb0d782008-10-15 11:12:35 +0200990 alc_mic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200991 break;
992 }
Kailang Yang7fb0d782008-10-15 11:12:35 +0200993}
994
995static void alc_inithook(struct hda_codec *codec)
996{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200997 alc_automute_pin(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +0200998 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +0200999}
1000
Kailang Yangf9423e72008-05-27 12:32:25 +02001001/* additional initialization for ALC888 variants */
1002static void alc888_coef_init(struct hda_codec *codec)
1003{
1004 unsigned int tmp;
1005
1006 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1007 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1008 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
Takashi Iwai37db6232009-03-05 09:40:16 +01001009 if ((tmp & 0xf0) == 0x20)
Kailang Yangf9423e72008-05-27 12:32:25 +02001010 /* alc888S-VC */
1011 snd_hda_codec_read(codec, 0x20, 0,
1012 AC_VERB_SET_PROC_COEF, 0x830);
1013 else
1014 /* alc888-VB */
1015 snd_hda_codec_read(codec, 0x20, 0,
1016 AC_VERB_SET_PROC_COEF, 0x3030);
1017}
1018
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001019static void alc_auto_init_amp(struct hda_codec *codec, int type)
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001020{
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001021 unsigned int tmp;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001022
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001023 switch (type) {
1024 case ALC_INIT_GPIO1:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001025 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1026 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001027 case ALC_INIT_GPIO2:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001028 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1029 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001030 case ALC_INIT_GPIO3:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001031 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1032 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001033 case ALC_INIT_DEFAULT:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001034 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001035 case 0x10ec0260:
1036 snd_hda_codec_write(codec, 0x0f, 0,
1037 AC_VERB_SET_EAPD_BTLENABLE, 2);
1038 snd_hda_codec_write(codec, 0x10, 0,
1039 AC_VERB_SET_EAPD_BTLENABLE, 2);
1040 break;
1041 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001042 case 0x10ec0267:
1043 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001044 case 0x10ec0269:
Takashi Iwaic6e8f2d2009-02-06 12:45:52 +01001045 case 0x10ec0272:
Kailang Yangf9423e72008-05-27 12:32:25 +02001046 case 0x10ec0660:
1047 case 0x10ec0662:
1048 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001049 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001050 case 0x10ec0889:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001051 snd_hda_codec_write(codec, 0x14, 0,
1052 AC_VERB_SET_EAPD_BTLENABLE, 2);
1053 snd_hda_codec_write(codec, 0x15, 0,
1054 AC_VERB_SET_EAPD_BTLENABLE, 2);
Kailang Yangc9b58002007-10-16 14:30:01 +02001055 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001056 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001057 switch (codec->vendor_id) {
1058 case 0x10ec0260:
1059 snd_hda_codec_write(codec, 0x1a, 0,
1060 AC_VERB_SET_COEF_INDEX, 7);
1061 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1062 AC_VERB_GET_PROC_COEF, 0);
1063 snd_hda_codec_write(codec, 0x1a, 0,
1064 AC_VERB_SET_COEF_INDEX, 7);
1065 snd_hda_codec_write(codec, 0x1a, 0,
1066 AC_VERB_SET_PROC_COEF,
1067 tmp | 0x2010);
1068 break;
1069 case 0x10ec0262:
1070 case 0x10ec0880:
1071 case 0x10ec0882:
1072 case 0x10ec0883:
1073 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001074 case 0x10ec0887:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001075 case 0x10ec0889:
Kailang Yangc9b58002007-10-16 14:30:01 +02001076 snd_hda_codec_write(codec, 0x20, 0,
1077 AC_VERB_SET_COEF_INDEX, 7);
1078 tmp = snd_hda_codec_read(codec, 0x20, 0,
1079 AC_VERB_GET_PROC_COEF, 0);
1080 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001081 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001082 snd_hda_codec_write(codec, 0x20, 0,
1083 AC_VERB_SET_PROC_COEF,
1084 tmp | 0x2010);
1085 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001086 case 0x10ec0888:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001087 alc888_coef_init(codec);
Kailang Yangf9423e72008-05-27 12:32:25 +02001088 break;
Kailang Yangc9b58002007-10-16 14:30:01 +02001089 case 0x10ec0267:
1090 case 0x10ec0268:
1091 snd_hda_codec_write(codec, 0x20, 0,
1092 AC_VERB_SET_COEF_INDEX, 7);
1093 tmp = snd_hda_codec_read(codec, 0x20, 0,
1094 AC_VERB_GET_PROC_COEF, 0);
1095 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001096 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001097 snd_hda_codec_write(codec, 0x20, 0,
1098 AC_VERB_SET_PROC_COEF,
1099 tmp | 0x3000);
1100 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001101 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001102 break;
1103 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001104}
Kailang Yangea1fb292008-08-26 12:58:38 +02001105
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001106static void alc_init_auto_hp(struct hda_codec *codec)
1107{
1108 struct alc_spec *spec = codec->spec;
1109
1110 if (!spec->autocfg.hp_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +02001111 return;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001112
Kailang Yangc9b58002007-10-16 14:30:01 +02001113 if (!spec->autocfg.speaker_pins[0]) {
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001114 if (spec->autocfg.line_out_pins[0] &&
1115 spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT)
Kailang Yangc9b58002007-10-16 14:30:01 +02001116 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +01001117 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +02001118 else
1119 return;
1120 }
1121
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001122 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1123 spec->autocfg.hp_pins[0]);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001124 snd_hda_codec_write_cache(codec, spec->autocfg.hp_pins[0], 0,
1125 AC_VERB_SET_UNSOLICITED_ENABLE,
1126 AC_USRSP_EN | ALC880_HP_EVENT);
1127 spec->unsol_event = alc_sku_unsol_event;
1128}
1129
1130/* check subsystem ID and set up device-specific initialization;
1131 * return 1 if initialized, 0 if invalid SSID
1132 */
1133/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1134 * 31 ~ 16 : Manufacture ID
1135 * 15 ~ 8 : SKU ID
1136 * 7 ~ 0 : Assembly ID
1137 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1138 */
1139static int alc_subsystem_id(struct hda_codec *codec,
1140 hda_nid_t porta, hda_nid_t porte,
1141 hda_nid_t portd)
1142{
1143 unsigned int ass, tmp, i;
1144 unsigned nid;
1145 struct alc_spec *spec = codec->spec;
1146
1147 ass = codec->subsystem_id & 0xffff;
1148 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1149 goto do_sku;
1150
1151 /* invalid SSID, check the special NID pin defcfg instead */
1152 /*
1153 * 31~30 : port conetcivity
1154 * 29~21 : reserve
1155 * 20 : PCBEEP input
1156 * 19~16 : Check sum (15:1)
1157 * 15~1 : Custom
1158 * 0 : override
1159 */
1160 nid = 0x1d;
1161 if (codec->vendor_id == 0x10ec0260)
1162 nid = 0x17;
1163 ass = snd_hda_codec_get_pincfg(codec, nid);
1164 snd_printd("realtek: No valid SSID, "
1165 "checking pincfg 0x%08x for NID 0x%x\n",
Takashi Iwaicb6605c2009-04-28 13:03:19 +02001166 ass, nid);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001167 if (!(ass & 1) && !(ass & 0x100000))
1168 return 0;
1169 if ((ass >> 30) != 1) /* no physical connection */
1170 return 0;
1171
1172 /* check sum */
1173 tmp = 0;
1174 for (i = 1; i < 16; i++) {
1175 if ((ass >> i) & 1)
1176 tmp++;
1177 }
1178 if (((ass >> 16) & 0xf) != tmp)
1179 return 0;
1180do_sku:
1181 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1182 ass & 0xffff, codec->vendor_id);
1183 /*
1184 * 0 : override
1185 * 1 : Swap Jack
1186 * 2 : 0 --> Desktop, 1 --> Laptop
1187 * 3~5 : External Amplifier control
1188 * 7~6 : Reserved
1189 */
1190 tmp = (ass & 0x38) >> 3; /* external Amp control */
1191 switch (tmp) {
1192 case 1:
1193 spec->init_amp = ALC_INIT_GPIO1;
1194 break;
1195 case 3:
1196 spec->init_amp = ALC_INIT_GPIO2;
1197 break;
1198 case 7:
1199 spec->init_amp = ALC_INIT_GPIO3;
1200 break;
1201 case 5:
1202 spec->init_amp = ALC_INIT_DEFAULT;
1203 break;
1204 }
1205
1206 /* is laptop or Desktop and enable the function "Mute internal speaker
1207 * when the external headphone out jack is plugged"
1208 */
1209 if (!(ass & 0x8000))
1210 return 1;
1211 /*
1212 * 10~8 : Jack location
1213 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1214 * 14~13: Resvered
1215 * 15 : 1 --> enable the function "Mute internal speaker
1216 * when the external headphone out jack is plugged"
1217 */
Kailang Yangc9b58002007-10-16 14:30:01 +02001218 if (!spec->autocfg.hp_pins[0]) {
1219 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1220 if (tmp == 0)
1221 spec->autocfg.hp_pins[0] = porta;
1222 else if (tmp == 1)
1223 spec->autocfg.hp_pins[0] = porte;
1224 else if (tmp == 2)
1225 spec->autocfg.hp_pins[0] = portd;
1226 else
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001227 return 1;
Kailang Yangc9b58002007-10-16 14:30:01 +02001228 }
1229
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001230 alc_init_auto_hp(codec);
1231 return 1;
1232}
Kailang Yangea1fb292008-08-26 12:58:38 +02001233
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001234static void alc_ssid_check(struct hda_codec *codec,
1235 hda_nid_t porta, hda_nid_t porte, hda_nid_t portd)
1236{
1237 if (!alc_subsystem_id(codec, porta, porte, portd)) {
1238 struct alc_spec *spec = codec->spec;
1239 snd_printd("realtek: "
1240 "Enable default setup for auto mode as fallback\n");
1241 spec->init_amp = ALC_INIT_DEFAULT;
1242 alc_init_auto_hp(codec);
1243 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001244}
1245
Takashi Iwai41e41f12005-06-08 14:48:49 +02001246/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02001247 * Fix-up pin default configurations
1248 */
1249
1250struct alc_pincfg {
1251 hda_nid_t nid;
1252 u32 val;
1253};
1254
1255static void alc_fix_pincfg(struct hda_codec *codec,
1256 const struct snd_pci_quirk *quirk,
1257 const struct alc_pincfg **pinfix)
1258{
1259 const struct alc_pincfg *cfg;
1260
1261 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1262 if (!quirk)
1263 return;
1264
1265 cfg = pinfix[quirk->value];
Takashi Iwai0e8a21b2009-02-20 14:13:06 +01001266 for (; cfg->nid; cfg++)
1267 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
Takashi Iwaif95474e2007-07-10 00:47:43 +02001268}
1269
1270/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001271 * ALC888
1272 */
1273
1274/*
1275 * 2ch mode
1276 */
1277static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1278/* Mic-in jack as mic in */
1279 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1280 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1281/* Line-in jack as Line in */
1282 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1283 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1284/* Line-Out as Front */
1285 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1286 { } /* end */
1287};
1288
1289/*
1290 * 4ch mode
1291 */
1292static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1293/* Mic-in jack as mic in */
1294 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1295 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1296/* Line-in jack as Surround */
1297 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1298 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1299/* Line-Out as Front */
1300 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1301 { } /* end */
1302};
1303
1304/*
1305 * 6ch mode
1306 */
1307static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1308/* Mic-in jack as CLFE */
1309 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1310 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1311/* Line-in jack as Surround */
1312 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1313 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1314/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1315 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1316 { } /* end */
1317};
1318
1319/*
1320 * 8ch mode
1321 */
1322static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1323/* Mic-in jack as CLFE */
1324 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1325 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1326/* Line-in jack as Surround */
1327 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1328 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1329/* Line-Out as Side */
1330 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1331 { } /* end */
1332};
1333
1334static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1335 { 2, alc888_4ST_ch2_intel_init },
1336 { 4, alc888_4ST_ch4_intel_init },
1337 { 6, alc888_4ST_ch6_intel_init },
1338 { 8, alc888_4ST_ch8_intel_init },
1339};
1340
1341/*
1342 * ALC888 Fujitsu Siemens Amillo xa3530
1343 */
1344
1345static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1346/* Front Mic: set to PIN_IN (empty by default) */
1347 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1348/* Connect Internal HP to Front */
1349 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1350 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1351 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1352/* Connect Bass HP to Front */
1353 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1354 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1355 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1356/* Connect Line-Out side jack (SPDIF) to Side */
1357 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1358 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1359 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1360/* Connect Mic jack to CLFE */
1361 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1362 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1363 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1364/* Connect Line-in jack to Surround */
1365 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1366 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1367 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1368/* Connect HP out jack to Front */
1369 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1370 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1371 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1372/* Enable unsolicited event for HP jack and Line-out jack */
1373 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1374 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1375 {}
1376};
1377
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001378static void alc_automute_amp(struct hda_codec *codec)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001379{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001380 struct alc_spec *spec = codec->spec;
1381 unsigned int val, mute;
1382 hda_nid_t nid;
1383 int i;
1384
1385 spec->jack_present = 0;
1386 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1387 nid = spec->autocfg.hp_pins[i];
1388 if (!nid)
1389 break;
1390 val = snd_hda_codec_read(codec, nid, 0,
1391 AC_VERB_GET_PIN_SENSE, 0);
1392 if (val & AC_PINSENSE_PRESENCE) {
1393 spec->jack_present = 1;
1394 break;
1395 }
1396 }
1397
1398 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001399 /* Toggle internal speakers muting */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001400 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1401 nid = spec->autocfg.speaker_pins[i];
1402 if (!nid)
1403 break;
1404 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1405 HDA_AMP_MUTE, mute);
1406 }
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001407}
1408
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001409static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1410 unsigned int res)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001411{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001412 if (codec->vendor_id == 0x10ec0880)
1413 res >>= 28;
1414 else
1415 res >>= 26;
1416 if (res == ALC880_HP_EVENT)
1417 alc_automute_amp(codec);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001418}
1419
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001420static void alc888_fujitsu_xa3530_init_hook(struct hda_codec *codec)
1421{
1422 struct alc_spec *spec = codec->spec;
1423
1424 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1425 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1426 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1427 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
1428 alc_automute_amp(codec);
1429}
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001430
1431/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001432 * ALC888 Acer Aspire 4930G model
1433 */
1434
1435static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1436/* Front Mic: set to PIN_IN (empty by default) */
1437 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1438/* Unselect Front Mic by default in input mixer 3 */
1439 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001440/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001441 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1442/* Connect Internal HP to front */
1443 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1444 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1445 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1446/* Connect HP out to front */
1447 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1448 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1449 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1450 { }
1451};
1452
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001453static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001454 /* Front mic only available on one ADC */
1455 {
1456 .num_items = 4,
1457 .items = {
1458 { "Mic", 0x0 },
1459 { "Line", 0x2 },
1460 { "CD", 0x4 },
1461 { "Front Mic", 0xb },
1462 },
1463 },
1464 {
1465 .num_items = 3,
1466 .items = {
1467 { "Mic", 0x0 },
1468 { "Line", 0x2 },
1469 { "CD", 0x4 },
1470 },
1471 }
1472};
1473
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001474static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001475 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1476 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1477 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1478 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1479 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1480 HDA_OUTPUT),
1481 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1482 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1483 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1484 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1485 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1486 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1487 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1488 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1489 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1490 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1491 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1492 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001493 { } /* end */
1494};
1495
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001496static void alc888_acer_aspire_4930g_init_hook(struct hda_codec *codec)
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001497{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001498 struct alc_spec *spec = codec->spec;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001499
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001500 spec->autocfg.hp_pins[0] = 0x15;
1501 spec->autocfg.speaker_pins[0] = 0x14;
1502 alc_automute_amp(codec);
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001503}
1504
1505/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001506 * ALC880 3-stack model
1507 *
1508 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001509 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1510 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07001511 */
1512
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001513static hda_nid_t alc880_dac_nids[4] = {
1514 /* front, rear, clfe, rear_surr */
1515 0x02, 0x05, 0x04, 0x03
1516};
1517
1518static hda_nid_t alc880_adc_nids[3] = {
1519 /* ADC0-2 */
1520 0x07, 0x08, 0x09,
1521};
1522
1523/* The datasheet says the node 0x07 is connected from inputs,
1524 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01001525 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07001526 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001527static hda_nid_t alc880_adc_nids_alt[2] = {
1528 /* ADC1-2 */
1529 0x08, 0x09,
1530};
1531
1532#define ALC880_DIGOUT_NID 0x06
1533#define ALC880_DIGIN_NID 0x0a
1534
1535static struct hda_input_mux alc880_capture_source = {
1536 .num_items = 4,
1537 .items = {
1538 { "Mic", 0x0 },
1539 { "Front Mic", 0x3 },
1540 { "Line", 0x2 },
1541 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001542 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001543};
1544
1545/* channel source setting (2/6 channel selection for 3-stack) */
1546/* 2ch mode */
1547static struct hda_verb alc880_threestack_ch2_init[] = {
1548 /* set line-in to input, mute it */
1549 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1550 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1551 /* set mic-in to input vref 80%, mute it */
1552 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1553 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001554 { } /* end */
1555};
1556
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001557/* 6ch mode */
1558static struct hda_verb alc880_threestack_ch6_init[] = {
1559 /* set line-in to output, unmute it */
1560 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1561 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1562 /* set mic-in to output, unmute it */
1563 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1564 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1565 { } /* end */
1566};
1567
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001568static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001569 { 2, alc880_threestack_ch2_init },
1570 { 6, alc880_threestack_ch6_init },
1571};
1572
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001573static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001574 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001575 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001576 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001577 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001578 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1579 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001580 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1581 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001582 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1583 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1584 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1585 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1586 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1587 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1588 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1589 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001590 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001591 {
1592 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1593 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001594 .info = alc_ch_mode_info,
1595 .get = alc_ch_mode_get,
1596 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001597 },
1598 { } /* end */
1599};
1600
1601/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001602static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1603 struct snd_ctl_elem_info *uinfo)
1604{
1605 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1606 struct alc_spec *spec = codec->spec;
1607 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001608
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001609 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001610 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1611 HDA_INPUT);
1612 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001613 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001614 return err;
1615}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001616
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001617static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1618 unsigned int size, unsigned int __user *tlv)
1619{
1620 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1621 struct alc_spec *spec = codec->spec;
1622 int err;
1623
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001624 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001625 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1626 HDA_INPUT);
1627 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001628 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001629 return err;
1630}
1631
1632typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1633 struct snd_ctl_elem_value *ucontrol);
1634
1635static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1636 struct snd_ctl_elem_value *ucontrol,
1637 getput_call_t func)
1638{
1639 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1640 struct alc_spec *spec = codec->spec;
1641 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1642 int err;
1643
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001644 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001645 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
1646 3, 0, HDA_INPUT);
1647 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001648 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001649 return err;
1650}
1651
1652static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
1653 struct snd_ctl_elem_value *ucontrol)
1654{
1655 return alc_cap_getput_caller(kcontrol, ucontrol,
1656 snd_hda_mixer_amp_volume_get);
1657}
1658
1659static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
1660 struct snd_ctl_elem_value *ucontrol)
1661{
1662 return alc_cap_getput_caller(kcontrol, ucontrol,
1663 snd_hda_mixer_amp_volume_put);
1664}
1665
1666/* capture mixer elements */
1667#define alc_cap_sw_info snd_ctl_boolean_stereo_info
1668
1669static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
1670 struct snd_ctl_elem_value *ucontrol)
1671{
1672 return alc_cap_getput_caller(kcontrol, ucontrol,
1673 snd_hda_mixer_amp_switch_get);
1674}
1675
1676static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
1677 struct snd_ctl_elem_value *ucontrol)
1678{
1679 return alc_cap_getput_caller(kcontrol, ucontrol,
1680 snd_hda_mixer_amp_switch_put);
1681}
1682
Takashi Iwaia23b6882009-03-23 15:21:36 +01001683#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001684 { \
1685 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1686 .name = "Capture Switch", \
1687 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1688 .count = num, \
1689 .info = alc_cap_sw_info, \
1690 .get = alc_cap_sw_get, \
1691 .put = alc_cap_sw_put, \
1692 }, \
1693 { \
1694 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1695 .name = "Capture Volume", \
1696 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1697 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1698 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
1699 .count = num, \
1700 .info = alc_cap_vol_info, \
1701 .get = alc_cap_vol_get, \
1702 .put = alc_cap_vol_put, \
1703 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01001704 }
1705
1706#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01001707 { \
1708 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1709 /* .name = "Capture Source", */ \
1710 .name = "Input Source", \
1711 .count = num, \
1712 .info = alc_mux_enum_info, \
1713 .get = alc_mux_enum_get, \
1714 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01001715 }
1716
1717#define DEFINE_CAPMIX(num) \
1718static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
1719 _DEFINE_CAPMIX(num), \
1720 _DEFINE_CAPSRC(num), \
1721 { } /* end */ \
1722}
1723
1724#define DEFINE_CAPMIX_NOSRC(num) \
1725static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
1726 _DEFINE_CAPMIX(num), \
1727 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001728}
1729
1730/* up to three ADCs */
1731DEFINE_CAPMIX(1);
1732DEFINE_CAPMIX(2);
1733DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01001734DEFINE_CAPMIX_NOSRC(1);
1735DEFINE_CAPMIX_NOSRC(2);
1736DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001737
1738/*
1739 * ALC880 5-stack model
1740 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001741 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
1742 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001743 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
1744 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
1745 */
1746
1747/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001748static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001749 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001750 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001751 { } /* end */
1752};
1753
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001754/* channel source setting (6/8 channel selection for 5-stack) */
1755/* 6ch mode */
1756static struct hda_verb alc880_fivestack_ch6_init[] = {
1757 /* set line-in to input, mute it */
1758 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1759 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001760 { } /* end */
1761};
1762
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001763/* 8ch mode */
1764static struct hda_verb alc880_fivestack_ch8_init[] = {
1765 /* set line-in to output, unmute it */
1766 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1767 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1768 { } /* end */
1769};
1770
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001771static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001772 { 6, alc880_fivestack_ch6_init },
1773 { 8, alc880_fivestack_ch8_init },
1774};
1775
1776
1777/*
1778 * ALC880 6-stack model
1779 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001780 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
1781 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001782 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
1783 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
1784 */
1785
1786static hda_nid_t alc880_6st_dac_nids[4] = {
1787 /* front, rear, clfe, rear_surr */
1788 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001789};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001790
1791static struct hda_input_mux alc880_6stack_capture_source = {
1792 .num_items = 4,
1793 .items = {
1794 { "Mic", 0x0 },
1795 { "Front Mic", 0x1 },
1796 { "Line", 0x2 },
1797 { "CD", 0x4 },
1798 },
1799};
1800
1801/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001802static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001803 { 8, NULL },
1804};
1805
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001806static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001807 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001808 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001809 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001810 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001811 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1812 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001813 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1814 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001815 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001816 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001817 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1818 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1819 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1820 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1821 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1822 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1823 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1824 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001825 {
1826 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1827 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001828 .info = alc_ch_mode_info,
1829 .get = alc_ch_mode_get,
1830 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001831 },
1832 { } /* end */
1833};
1834
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001835
1836/*
1837 * ALC880 W810 model
1838 *
1839 * W810 has rear IO for:
1840 * Front (DAC 02)
1841 * Surround (DAC 03)
1842 * Center/LFE (DAC 04)
1843 * Digital out (06)
1844 *
1845 * The system also has a pair of internal speakers, and a headphone jack.
1846 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02001847 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001848 * There is a variable resistor to control the speaker or headphone
1849 * volume. This is a hardware-only device without a software API.
1850 *
1851 * Plugging headphones in will disable the internal speakers. This is
1852 * implemented in hardware, not via the driver using jack sense. In
1853 * a similar fashion, plugging into the rear socket marked "front" will
1854 * disable both the speakers and headphones.
1855 *
1856 * For input, there's a microphone jack, and an "audio in" jack.
1857 * These may not do anything useful with this driver yet, because I
1858 * haven't setup any initialization verbs for these yet...
1859 */
1860
1861static hda_nid_t alc880_w810_dac_nids[3] = {
1862 /* front, rear/surround, clfe */
1863 0x02, 0x03, 0x04
1864};
1865
1866/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001867static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001868 { 6, NULL }
1869};
1870
1871/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001872static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001873 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001874 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001875 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001876 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001877 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1878 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001879 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1880 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001881 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1882 { } /* end */
1883};
1884
1885
1886/*
1887 * Z710V model
1888 *
1889 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001890 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1891 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001892 */
1893
1894static hda_nid_t alc880_z71v_dac_nids[1] = {
1895 0x02
1896};
1897#define ALC880_Z71V_HP_DAC 0x03
1898
1899/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001900static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001901 { 2, NULL }
1902};
1903
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001904static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001905 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001906 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001907 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001908 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001909 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1910 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1911 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1912 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1913 { } /* end */
1914};
1915
1916
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001917/*
1918 * ALC880 F1734 model
1919 *
1920 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1921 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1922 */
1923
1924static hda_nid_t alc880_f1734_dac_nids[1] = {
1925 0x03
1926};
1927#define ALC880_F1734_HP_DAC 0x02
1928
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001929static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001930 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001931 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01001932 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1933 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001934 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1935 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01001936 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1937 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001938 { } /* end */
1939};
1940
Takashi Iwai937b4162008-02-11 14:52:36 +01001941static struct hda_input_mux alc880_f1734_capture_source = {
1942 .num_items = 2,
1943 .items = {
1944 { "Mic", 0x1 },
1945 { "CD", 0x4 },
1946 },
1947};
1948
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001949
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001950/*
1951 * ALC880 ASUS model
1952 *
1953 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1954 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1955 * Mic = 0x18, Line = 0x1a
1956 */
1957
1958#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1959#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1960
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001961static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001962 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001963 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001964 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001965 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001966 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1967 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001968 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1969 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001970 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1971 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1972 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1973 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1974 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1975 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001976 {
1977 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1978 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001979 .info = alc_ch_mode_info,
1980 .get = alc_ch_mode_get,
1981 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001982 },
1983 { } /* end */
1984};
1985
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001986/*
1987 * ALC880 ASUS W1V model
1988 *
1989 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1990 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1991 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1992 */
1993
1994/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001995static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001996 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1997 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001998 { } /* end */
1999};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002000
Kailang Yangdf694da2005-12-05 19:42:22 +01002001/* TCL S700 */
2002static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2003 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2004 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2005 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2006 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2007 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2008 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2009 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2010 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2011 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002012 { } /* end */
2013};
2014
Kailang Yangccc656c2006-10-17 12:32:26 +02002015/* Uniwill */
2016static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002017 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2018 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2019 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2020 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002021 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2022 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2023 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2024 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2025 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2026 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2027 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2028 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2029 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2030 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2031 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2032 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002033 {
2034 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2035 .name = "Channel Mode",
2036 .info = alc_ch_mode_info,
2037 .get = alc_ch_mode_get,
2038 .put = alc_ch_mode_put,
2039 },
2040 { } /* end */
2041};
2042
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002043static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2044 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2045 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2046 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2047 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2048 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2049 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2050 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2051 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2052 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2053 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2054 { } /* end */
2055};
2056
Kailang Yangccc656c2006-10-17 12:32:26 +02002057static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002058 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2059 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2060 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2061 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002062 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2063 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2064 { } /* end */
2065};
2066
Linus Torvalds1da177e2005-04-16 15:20:36 -07002067/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01002068 * virtual master controls
2069 */
2070
2071/*
2072 * slave controls for virtual master
2073 */
2074static const char *alc_slave_vols[] = {
2075 "Front Playback Volume",
2076 "Surround Playback Volume",
2077 "Center Playback Volume",
2078 "LFE Playback Volume",
2079 "Side Playback Volume",
2080 "Headphone Playback Volume",
2081 "Speaker Playback Volume",
2082 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002083 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01002084 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002085 NULL,
2086};
2087
2088static const char *alc_slave_sws[] = {
2089 "Front Playback Switch",
2090 "Surround Playback Switch",
2091 "Center Playback Switch",
2092 "LFE Playback Switch",
2093 "Side Playback Switch",
2094 "Headphone Playback Switch",
2095 "Speaker Playback Switch",
2096 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01002097 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002098 NULL,
2099};
2100
2101/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002102 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002103 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002104
2105static void alc_free_kctls(struct hda_codec *codec);
2106
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002107/* additional beep mixers; the actual parameters are overwritten at build */
2108static struct snd_kcontrol_new alc_beep_mixer[] = {
2109 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
2110 HDA_CODEC_MUTE("Beep Playback Switch", 0, 0, HDA_INPUT),
2111 { } /* end */
2112};
2113
Linus Torvalds1da177e2005-04-16 15:20:36 -07002114static int alc_build_controls(struct hda_codec *codec)
2115{
2116 struct alc_spec *spec = codec->spec;
2117 int err;
2118 int i;
2119
2120 for (i = 0; i < spec->num_mixers; i++) {
2121 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2122 if (err < 0)
2123 return err;
2124 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002125 if (spec->cap_mixer) {
2126 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2127 if (err < 0)
2128 return err;
2129 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002130 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002131 err = snd_hda_create_spdif_out_ctls(codec,
2132 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002133 if (err < 0)
2134 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002135 if (!spec->no_analog) {
2136 err = snd_hda_create_spdif_share_sw(codec,
2137 &spec->multiout);
2138 if (err < 0)
2139 return err;
2140 spec->multiout.share_spdif = 1;
2141 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002142 }
2143 if (spec->dig_in_nid) {
2144 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2145 if (err < 0)
2146 return err;
2147 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002148
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002149 /* create beep controls if needed */
2150 if (spec->beep_amp) {
2151 struct snd_kcontrol_new *knew;
2152 for (knew = alc_beep_mixer; knew->name; knew++) {
2153 struct snd_kcontrol *kctl;
2154 kctl = snd_ctl_new1(knew, codec);
2155 if (!kctl)
2156 return -ENOMEM;
2157 kctl->private_value = spec->beep_amp;
2158 err = snd_hda_ctl_add(codec, kctl);
2159 if (err < 0)
2160 return err;
2161 }
2162 }
2163
Takashi Iwai2134ea42008-01-10 16:53:55 +01002164 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002165 if (!spec->no_analog &&
2166 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002167 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002168 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002169 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002170 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002171 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002172 if (err < 0)
2173 return err;
2174 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002175 if (!spec->no_analog &&
2176 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002177 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2178 NULL, alc_slave_sws);
2179 if (err < 0)
2180 return err;
2181 }
2182
Takashi Iwai603c4012008-07-30 15:01:44 +02002183 alc_free_kctls(codec); /* no longer needed */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002184 return 0;
2185}
2186
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002187
Linus Torvalds1da177e2005-04-16 15:20:36 -07002188/*
2189 * initialize the codec volumes, etc
2190 */
2191
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002192/*
2193 * generic initialization of ADC, input mixers and output mixers
2194 */
2195static struct hda_verb alc880_volume_init_verbs[] = {
2196 /*
2197 * Unmute ADC0-2 and set the default input to mic-in
2198 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002199 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002200 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002201 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002202 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002203 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002204 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002205
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002206 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2207 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002208 * Note: PASD motherboards uses the Line In 2 as the input for front
2209 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002210 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002211 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02002212 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2213 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2214 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2215 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2216 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2217 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2218 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002219
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002220 /*
2221 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002222 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002223 /* set vol=0 to output mixers */
2224 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2225 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2226 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2227 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2228 /* set up input amps for analog loopback */
2229 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002230 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2231 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002232 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2233 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002234 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2235 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002236 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2237 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002238
2239 { }
2240};
2241
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002242/*
2243 * 3-stack pin configuration:
2244 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2245 */
2246static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2247 /*
2248 * preset connection lists of input pins
2249 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2250 */
2251 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2252 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2253 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2254
2255 /*
2256 * Set pin mode and muting
2257 */
2258 /* set front pin widgets 0x14 for output */
2259 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2260 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2261 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2262 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2263 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2264 /* Mic2 (as headphone out) for HP output */
2265 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2266 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2267 /* Line In pin widget for input */
2268 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2269 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2270 /* Line2 (as front mic) pin widget for input and vref at 80% */
2271 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2272 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2273 /* CD pin widget for input */
2274 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2275
2276 { }
2277};
2278
2279/*
2280 * 5-stack pin configuration:
2281 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2282 * line-in/side = 0x1a, f-mic = 0x1b
2283 */
2284static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2285 /*
2286 * preset connection lists of input pins
2287 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2288 */
2289 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2290 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2291
2292 /*
2293 * Set pin mode and muting
2294 */
2295 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02002296 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2297 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2298 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2299 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002300 /* unmute pins for output (no gain on this amp) */
2301 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2302 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2303 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2304 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2305
Linus Torvalds1da177e2005-04-16 15:20:36 -07002306 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02002307 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002308 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2309 /* Mic2 (as headphone out) for HP output */
2310 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002311 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002312 /* Line In pin widget for input */
2313 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2314 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2315 /* Line2 (as front mic) pin widget for input and vref at 80% */
2316 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2317 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2318 /* CD pin widget for input */
2319 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002320
2321 { }
2322};
2323
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002324/*
2325 * W810 pin configuration:
2326 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2327 */
2328static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002329 /* hphone/speaker input selector: front DAC */
2330 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2331
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002332 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2333 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2334 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2335 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2336 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2337 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2338
2339 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002340 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002341
Linus Torvalds1da177e2005-04-16 15:20:36 -07002342 { }
2343};
2344
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002345/*
2346 * Z71V pin configuration:
2347 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2348 */
2349static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002350 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002351 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02002352 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002353 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002354
Takashi Iwai16ded522005-06-10 19:58:24 +02002355 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002356 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002357 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002358 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002359
2360 { }
2361};
2362
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002363/*
2364 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002365 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2366 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002367 */
2368static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2369 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2370
Takashi Iwai16ded522005-06-10 19:58:24 +02002371 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002372 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002373 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002374 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002375 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002376 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002377 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002378 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2379
Takashi Iwai16ded522005-06-10 19:58:24 +02002380 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002381 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002382 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002383 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002384 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002385 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002386 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02002387 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002388 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002389
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002390 { }
2391};
Takashi Iwai16ded522005-06-10 19:58:24 +02002392
Kailang Yangccc656c2006-10-17 12:32:26 +02002393/*
2394 * Uniwill pin configuration:
2395 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2396 * line = 0x1a
2397 */
2398static struct hda_verb alc880_uniwill_init_verbs[] = {
2399 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2400
2401 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2402 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2403 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2404 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2405 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2406 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2407 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2408 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2409 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2410 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2411 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2412 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2413 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2414 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2415
2416 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2417 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2418 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2419 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2420 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2421 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2422 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2423 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2424 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2425
2426 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2427 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2428
2429 { }
2430};
2431
2432/*
2433* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02002434* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02002435 */
2436static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2437 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2438
2439 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2440 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2441 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2442 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2443 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2444 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2445 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2446 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2447 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2448 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2449 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2450 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2451
2452 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2453 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2454 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2455 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2456 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2457 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2458
2459 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2460 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2461
2462 { }
2463};
2464
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002465static struct hda_verb alc880_beep_init_verbs[] = {
2466 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2467 { }
2468};
2469
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002470/* auto-toggle front mic */
2471static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2472{
2473 unsigned int present;
2474 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002475
2476 present = snd_hda_codec_read(codec, 0x18, 0,
2477 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002478 bits = present ? HDA_AMP_MUTE : 0;
2479 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002480}
2481
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002482static void alc880_uniwill_init_hook(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002483{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002484 struct alc_spec *spec = codec->spec;
2485
2486 spec->autocfg.hp_pins[0] = 0x14;
2487 spec->autocfg.speaker_pins[0] = 0x15;
2488 spec->autocfg.speaker_pins[0] = 0x16;
2489 alc_automute_amp(codec);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002490 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002491}
2492
2493static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2494 unsigned int res)
2495{
2496 /* Looks like the unsol event is incompatible with the standard
2497 * definition. 4bit tag is placed at 28 bit!
2498 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002499 switch (res >> 28) {
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002500 case ALC880_MIC_EVENT:
2501 alc880_uniwill_mic_automute(codec);
2502 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002503 default:
2504 alc_automute_amp_unsol_event(codec, res);
2505 break;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002506 }
Kailang Yangccc656c2006-10-17 12:32:26 +02002507}
2508
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002509static void alc880_uniwill_p53_init_hook(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02002510{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002511 struct alc_spec *spec = codec->spec;
Kailang Yangccc656c2006-10-17 12:32:26 +02002512
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002513 spec->autocfg.hp_pins[0] = 0x14;
2514 spec->autocfg.speaker_pins[0] = 0x15;
2515 alc_automute_amp(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002516}
2517
2518static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2519{
2520 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02002521
Kailang Yangccc656c2006-10-17 12:32:26 +02002522 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02002523 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2524 present &= HDA_AMP_VOLMASK;
2525 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2526 HDA_AMP_VOLMASK, present);
2527 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2528 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02002529}
Takashi Iwai47fd8302007-08-10 17:11:07 +02002530
Kailang Yangccc656c2006-10-17 12:32:26 +02002531static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2532 unsigned int res)
2533{
2534 /* Looks like the unsol event is incompatible with the standard
2535 * definition. 4bit tag is placed at 28 bit!
2536 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002537 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02002538 alc880_uniwill_p53_dcvol_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002539 else
2540 alc_automute_amp_unsol_event(codec, res);
Kailang Yangccc656c2006-10-17 12:32:26 +02002541}
2542
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002543/*
2544 * F1734 pin configuration:
2545 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2546 */
2547static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01002548 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002549 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2550 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2551 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2552 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2553
2554 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2555 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2556 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2557 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2558
2559 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2560 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01002561 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002562 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2563 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2564 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2565 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2566 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2567 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002568
Takashi Iwai937b4162008-02-11 14:52:36 +01002569 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2570 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2571
Takashi Iwai16ded522005-06-10 19:58:24 +02002572 { }
2573};
2574
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002575/*
2576 * ASUS pin configuration:
2577 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2578 */
2579static struct hda_verb alc880_pin_asus_init_verbs[] = {
2580 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2581 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2582 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2583 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2584
2585 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2586 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2587 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2588 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2589 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2590 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2591 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2592 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2593
2594 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2595 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2596 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2597 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2598 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2599 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2600 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2601 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2602 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002603
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002604 { }
2605};
2606
2607/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02002608#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2609#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002610
Kailang Yangdf694da2005-12-05 19:42:22 +01002611/* Clevo m520g init */
2612static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2613 /* headphone output */
2614 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2615 /* line-out */
2616 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2617 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2618 /* Line-in */
2619 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2620 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2621 /* CD */
2622 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2623 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2624 /* Mic1 (rear panel) */
2625 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2626 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2627 /* Mic2 (front panel) */
2628 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2629 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2630 /* headphone */
2631 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2632 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2633 /* change to EAPD mode */
2634 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2635 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2636
2637 { }
2638};
2639
2640static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002641 /* change to EAPD mode */
2642 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2643 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2644
Kailang Yangdf694da2005-12-05 19:42:22 +01002645 /* Headphone output */
2646 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2647 /* Front output*/
2648 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2649 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2650
2651 /* Line In pin widget for input */
2652 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2653 /* CD pin widget for input */
2654 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2655 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2656 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2657
2658 /* change to EAPD mode */
2659 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2660 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2661
2662 { }
2663};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002664
2665/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002666 * LG m1 express dual
2667 *
2668 * Pin assignment:
2669 * Rear Line-In/Out (blue): 0x14
2670 * Build-in Mic-In: 0x15
2671 * Speaker-out: 0x17
2672 * HP-Out (green): 0x1b
2673 * Mic-In/Out (red): 0x19
2674 * SPDIF-Out: 0x1e
2675 */
2676
2677/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2678static hda_nid_t alc880_lg_dac_nids[3] = {
2679 0x05, 0x02, 0x03
2680};
2681
2682/* seems analog CD is not working */
2683static struct hda_input_mux alc880_lg_capture_source = {
2684 .num_items = 3,
2685 .items = {
2686 { "Mic", 0x1 },
2687 { "Line", 0x5 },
2688 { "Internal Mic", 0x6 },
2689 },
2690};
2691
2692/* 2,4,6 channel modes */
2693static struct hda_verb alc880_lg_ch2_init[] = {
2694 /* set line-in and mic-in to input */
2695 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2696 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2697 { }
2698};
2699
2700static struct hda_verb alc880_lg_ch4_init[] = {
2701 /* set line-in to out and mic-in to input */
2702 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2703 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2704 { }
2705};
2706
2707static struct hda_verb alc880_lg_ch6_init[] = {
2708 /* set line-in and mic-in to output */
2709 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2710 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2711 { }
2712};
2713
2714static struct hda_channel_mode alc880_lg_ch_modes[3] = {
2715 { 2, alc880_lg_ch2_init },
2716 { 4, alc880_lg_ch4_init },
2717 { 6, alc880_lg_ch6_init },
2718};
2719
2720static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002721 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2722 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002723 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2724 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
2725 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
2726 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
2727 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
2728 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
2729 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2730 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2731 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
2732 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
2733 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
2734 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
2735 {
2736 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2737 .name = "Channel Mode",
2738 .info = alc_ch_mode_info,
2739 .get = alc_ch_mode_get,
2740 .put = alc_ch_mode_put,
2741 },
2742 { } /* end */
2743};
2744
2745static struct hda_verb alc880_lg_init_verbs[] = {
2746 /* set capture source to mic-in */
2747 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2748 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2749 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2750 /* mute all amp mixer inputs */
2751 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002752 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2753 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002754 /* line-in to input */
2755 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2756 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2757 /* built-in mic */
2758 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2759 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2760 /* speaker-out */
2761 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2762 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2763 /* mic-in to input */
2764 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2765 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2766 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2767 /* HP-out */
2768 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
2769 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2770 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2771 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002772 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002773 { }
2774};
2775
2776/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002777static void alc880_lg_init_hook(struct hda_codec *codec)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002778{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002779 struct alc_spec *spec = codec->spec;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002780
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002781 spec->autocfg.hp_pins[0] = 0x1b;
2782 spec->autocfg.speaker_pins[0] = 0x17;
2783 alc_automute_amp(codec);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002784}
2785
2786/*
Takashi Iwaid6815182006-03-23 16:06:23 +01002787 * LG LW20
2788 *
2789 * Pin assignment:
2790 * Speaker-out: 0x14
2791 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002792 * Built-in Mic-In: 0x19
2793 * Line-In: 0x1b
2794 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01002795 * SPDIF-Out: 0x1e
2796 */
2797
Takashi Iwaid6815182006-03-23 16:06:23 +01002798static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002799 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01002800 .items = {
2801 { "Mic", 0x0 },
2802 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002803 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002804 },
2805};
2806
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002807#define alc880_lg_lw_modes alc880_threestack_modes
2808
Takashi Iwaid6815182006-03-23 16:06:23 +01002809static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002810 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2811 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2812 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2813 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2814 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2815 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2816 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2817 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2818 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2819 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01002820 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2821 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2822 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
2823 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002824 {
2825 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2826 .name = "Channel Mode",
2827 .info = alc_ch_mode_info,
2828 .get = alc_ch_mode_get,
2829 .put = alc_ch_mode_put,
2830 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002831 { } /* end */
2832};
2833
2834static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002835 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2836 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2837 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2838
Takashi Iwaid6815182006-03-23 16:06:23 +01002839 /* set capture source to mic-in */
2840 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2841 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2842 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002843 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01002844 /* speaker-out */
2845 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2846 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2847 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01002848 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2849 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2850 /* mic-in to input */
2851 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2852 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2853 /* built-in mic */
2854 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2855 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2856 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002857 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaid6815182006-03-23 16:06:23 +01002858 { }
2859};
2860
2861/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002862static void alc880_lg_lw_init_hook(struct hda_codec *codec)
Takashi Iwaid6815182006-03-23 16:06:23 +01002863{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002864 struct alc_spec *spec = codec->spec;
Takashi Iwaid6815182006-03-23 16:06:23 +01002865
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002866 spec->autocfg.hp_pins[0] = 0x1b;
2867 spec->autocfg.speaker_pins[0] = 0x14;
2868 alc_automute_amp(codec);
Takashi Iwaid6815182006-03-23 16:06:23 +01002869}
2870
Takashi Iwaidf99cd32008-04-25 15:25:04 +02002871static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
2872 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2873 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
2874 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2875 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2876 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2877 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
2878 { } /* end */
2879};
2880
2881static struct hda_input_mux alc880_medion_rim_capture_source = {
2882 .num_items = 2,
2883 .items = {
2884 { "Mic", 0x0 },
2885 { "Internal Mic", 0x1 },
2886 },
2887};
2888
2889static struct hda_verb alc880_medion_rim_init_verbs[] = {
2890 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2891
2892 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2893 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2894
2895 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2896 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2897 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2898 /* Mic2 (as headphone out) for HP output */
2899 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2900 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2901 /* Internal Speaker */
2902 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2903 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2904
2905 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2906 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2907
2908 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2909 { }
2910};
2911
2912/* toggle speaker-output according to the hp-jack state */
2913static void alc880_medion_rim_automute(struct hda_codec *codec)
2914{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002915 struct alc_spec *spec = codec->spec;
2916 alc_automute_amp(codec);
2917 /* toggle EAPD */
2918 if (spec->jack_present)
Takashi Iwaidf99cd32008-04-25 15:25:04 +02002919 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
2920 else
2921 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
2922}
2923
2924static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
2925 unsigned int res)
2926{
2927 /* Looks like the unsol event is incompatible with the standard
2928 * definition. 4bit tag is placed at 28 bit!
2929 */
2930 if ((res >> 28) == ALC880_HP_EVENT)
2931 alc880_medion_rim_automute(codec);
2932}
2933
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002934static void alc880_medion_rim_init_hook(struct hda_codec *codec)
2935{
2936 struct alc_spec *spec = codec->spec;
2937
2938 spec->autocfg.hp_pins[0] = 0x14;
2939 spec->autocfg.speaker_pins[0] = 0x1b;
2940 alc880_medion_rim_automute(codec);
2941}
2942
Takashi Iwaicb53c622007-08-10 17:21:45 +02002943#ifdef CONFIG_SND_HDA_POWER_SAVE
2944static struct hda_amp_list alc880_loopbacks[] = {
2945 { 0x0b, HDA_INPUT, 0 },
2946 { 0x0b, HDA_INPUT, 1 },
2947 { 0x0b, HDA_INPUT, 2 },
2948 { 0x0b, HDA_INPUT, 3 },
2949 { 0x0b, HDA_INPUT, 4 },
2950 { } /* end */
2951};
2952
2953static struct hda_amp_list alc880_lg_loopbacks[] = {
2954 { 0x0b, HDA_INPUT, 1 },
2955 { 0x0b, HDA_INPUT, 6 },
2956 { 0x0b, HDA_INPUT, 7 },
2957 { } /* end */
2958};
2959#endif
2960
Takashi Iwaid6815182006-03-23 16:06:23 +01002961/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002962 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002963 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002964
Linus Torvalds1da177e2005-04-16 15:20:36 -07002965static int alc_init(struct hda_codec *codec)
2966{
2967 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002968 unsigned int i;
2969
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02002970 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02002971 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02002972
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002973 for (i = 0; i < spec->num_init_verbs; i++)
2974 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002975
2976 if (spec->init_hook)
2977 spec->init_hook(codec);
2978
Linus Torvalds1da177e2005-04-16 15:20:36 -07002979 return 0;
2980}
2981
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002982static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2983{
2984 struct alc_spec *spec = codec->spec;
2985
2986 if (spec->unsol_event)
2987 spec->unsol_event(codec, res);
2988}
2989
Takashi Iwaicb53c622007-08-10 17:21:45 +02002990#ifdef CONFIG_SND_HDA_POWER_SAVE
2991static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
2992{
2993 struct alc_spec *spec = codec->spec;
2994 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
2995}
2996#endif
2997
Linus Torvalds1da177e2005-04-16 15:20:36 -07002998/*
2999 * Analog playback callbacks
3000 */
3001static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3002 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003003 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003004{
3005 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01003006 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3007 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003008}
3009
3010static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3011 struct hda_codec *codec,
3012 unsigned int stream_tag,
3013 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003014 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003015{
3016 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003017 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3018 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003019}
3020
3021static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3022 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003023 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003024{
3025 struct alc_spec *spec = codec->spec;
3026 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3027}
3028
3029/*
3030 * Digital out
3031 */
3032static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3033 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003034 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003035{
3036 struct alc_spec *spec = codec->spec;
3037 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3038}
3039
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003040static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3041 struct hda_codec *codec,
3042 unsigned int stream_tag,
3043 unsigned int format,
3044 struct snd_pcm_substream *substream)
3045{
3046 struct alc_spec *spec = codec->spec;
3047 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3048 stream_tag, format, substream);
3049}
3050
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003051static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3052 struct hda_codec *codec,
3053 struct snd_pcm_substream *substream)
3054{
3055 struct alc_spec *spec = codec->spec;
3056 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3057}
3058
Linus Torvalds1da177e2005-04-16 15:20:36 -07003059static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3060 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003061 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003062{
3063 struct alc_spec *spec = codec->spec;
3064 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3065}
3066
3067/*
3068 * Analog capture
3069 */
Takashi Iwai63300792008-01-24 15:31:36 +01003070static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003071 struct hda_codec *codec,
3072 unsigned int stream_tag,
3073 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003074 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003075{
3076 struct alc_spec *spec = codec->spec;
3077
Takashi Iwai63300792008-01-24 15:31:36 +01003078 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07003079 stream_tag, 0, format);
3080 return 0;
3081}
3082
Takashi Iwai63300792008-01-24 15:31:36 +01003083static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003084 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003085 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003086{
3087 struct alc_spec *spec = codec->spec;
3088
Takashi Iwai888afa12008-03-18 09:57:50 +01003089 snd_hda_codec_cleanup_stream(codec,
3090 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003091 return 0;
3092}
3093
3094
3095/*
3096 */
3097static struct hda_pcm_stream alc880_pcm_analog_playback = {
3098 .substreams = 1,
3099 .channels_min = 2,
3100 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003101 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003102 .ops = {
3103 .open = alc880_playback_pcm_open,
3104 .prepare = alc880_playback_pcm_prepare,
3105 .cleanup = alc880_playback_pcm_cleanup
3106 },
3107};
3108
3109static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01003110 .substreams = 1,
3111 .channels_min = 2,
3112 .channels_max = 2,
3113 /* NID is set in alc_build_pcms */
3114};
3115
3116static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3117 .substreams = 1,
3118 .channels_min = 2,
3119 .channels_max = 2,
3120 /* NID is set in alc_build_pcms */
3121};
3122
3123static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3124 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003125 .channels_min = 2,
3126 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003127 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003128 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01003129 .prepare = alc880_alt_capture_pcm_prepare,
3130 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003131 },
3132};
3133
3134static struct hda_pcm_stream alc880_pcm_digital_playback = {
3135 .substreams = 1,
3136 .channels_min = 2,
3137 .channels_max = 2,
3138 /* NID is set in alc_build_pcms */
3139 .ops = {
3140 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003141 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003142 .prepare = alc880_dig_playback_pcm_prepare,
3143 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003144 },
3145};
3146
3147static struct hda_pcm_stream alc880_pcm_digital_capture = {
3148 .substreams = 1,
3149 .channels_min = 2,
3150 .channels_max = 2,
3151 /* NID is set in alc_build_pcms */
3152};
3153
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003154/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01003155static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003156 .substreams = 0,
3157 .channels_min = 0,
3158 .channels_max = 0,
3159};
3160
Linus Torvalds1da177e2005-04-16 15:20:36 -07003161static int alc_build_pcms(struct hda_codec *codec)
3162{
3163 struct alc_spec *spec = codec->spec;
3164 struct hda_pcm *info = spec->pcm_rec;
3165 int i;
3166
3167 codec->num_pcms = 1;
3168 codec->pcm_info = info;
3169
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003170 if (spec->no_analog)
3171 goto skip_analog;
3172
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003173 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
3174 "%s Analog", codec->chip_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003175 info->name = spec->stream_name_analog;
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003176
Takashi Iwai4a471b72005-12-07 13:56:29 +01003177 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003178 if (snd_BUG_ON(!spec->multiout.dac_nids))
3179 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003180 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3181 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3182 }
3183 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003184 if (snd_BUG_ON(!spec->adc_nids))
3185 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003186 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3187 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3188 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003189
Takashi Iwai4a471b72005-12-07 13:56:29 +01003190 if (spec->channel_mode) {
3191 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3192 for (i = 0; i < spec->num_channel_mode; i++) {
3193 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3194 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3195 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003196 }
3197 }
3198
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003199 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02003200 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003201 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003202 snprintf(spec->stream_name_digital,
3203 sizeof(spec->stream_name_digital),
3204 "%s Digital", codec->chip_name);
Takashi Iwaie08a0072006-09-07 17:52:14 +02003205 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08003206 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003207 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003208 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01003209 if (spec->dig_out_type)
3210 info->pcm_type = spec->dig_out_type;
3211 else
3212 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003213 if (spec->multiout.dig_out_nid &&
3214 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003215 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
3216 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3217 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01003218 if (spec->dig_in_nid &&
3219 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003220 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
3221 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3222 }
Takashi Iwai963f8032008-08-11 10:04:40 +02003223 /* FIXME: do we need this for all Realtek codec models? */
3224 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003225 }
3226
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003227 if (spec->no_analog)
3228 return 0;
3229
Takashi Iwaie08a0072006-09-07 17:52:14 +02003230 /* If the use of more than one ADC is requested for the current
3231 * model, configure a second analog capture-only PCM.
3232 */
3233 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01003234 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
3235 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003236 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003237 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003238 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01003239 if (spec->alt_dac_nid) {
3240 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3241 *spec->stream_analog_alt_playback;
3242 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3243 spec->alt_dac_nid;
3244 } else {
3245 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3246 alc_pcm_null_stream;
3247 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
3248 }
3249 if (spec->num_adc_nids > 1) {
3250 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3251 *spec->stream_analog_alt_capture;
3252 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
3253 spec->adc_nids[1];
3254 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
3255 spec->num_adc_nids - 1;
3256 } else {
3257 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3258 alc_pcm_null_stream;
3259 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003260 }
3261 }
3262
Linus Torvalds1da177e2005-04-16 15:20:36 -07003263 return 0;
3264}
3265
Takashi Iwai603c4012008-07-30 15:01:44 +02003266static void alc_free_kctls(struct hda_codec *codec)
3267{
3268 struct alc_spec *spec = codec->spec;
3269
3270 if (spec->kctls.list) {
3271 struct snd_kcontrol_new *kctl = spec->kctls.list;
3272 int i;
3273 for (i = 0; i < spec->kctls.used; i++)
3274 kfree(kctl[i].name);
3275 }
3276 snd_array_free(&spec->kctls);
3277}
3278
Linus Torvalds1da177e2005-04-16 15:20:36 -07003279static void alc_free(struct hda_codec *codec)
3280{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003281 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003282
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003283 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003284 return;
3285
Takashi Iwai603c4012008-07-30 15:01:44 +02003286 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003287 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09003288 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003289}
3290
Takashi Iwaie044c392008-10-27 16:56:24 +01003291#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01003292static int alc_resume(struct hda_codec *codec)
3293{
Takashi Iwaie044c392008-10-27 16:56:24 +01003294 codec->patch_ops.init(codec);
3295 snd_hda_codec_resume_amp(codec);
3296 snd_hda_codec_resume_cache(codec);
3297 return 0;
3298}
Takashi Iwaie044c392008-10-27 16:56:24 +01003299#endif
3300
Linus Torvalds1da177e2005-04-16 15:20:36 -07003301/*
3302 */
3303static struct hda_codec_ops alc_patch_ops = {
3304 .build_controls = alc_build_controls,
3305 .build_pcms = alc_build_pcms,
3306 .init = alc_init,
3307 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003308 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01003309#ifdef SND_HDA_NEEDS_RESUME
3310 .resume = alc_resume,
3311#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02003312#ifdef CONFIG_SND_HDA_POWER_SAVE
3313 .check_power_status = alc_check_power_status,
3314#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003315};
3316
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003317
3318/*
3319 * Test configuration for debugging
3320 *
3321 * Almost all inputs/outputs are enabled. I/O pins can be configured via
3322 * enum controls.
3323 */
3324#ifdef CONFIG_SND_DEBUG
3325static hda_nid_t alc880_test_dac_nids[4] = {
3326 0x02, 0x03, 0x04, 0x05
3327};
3328
3329static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003330 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003331 .items = {
3332 { "In-1", 0x0 },
3333 { "In-2", 0x1 },
3334 { "In-3", 0x2 },
3335 { "In-4", 0x3 },
3336 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003337 { "Front", 0x5 },
3338 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003339 },
3340};
3341
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003342static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003343 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003344 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003345 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003346 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003347};
3348
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003349static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
3350 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003351{
3352 static char *texts[] = {
3353 "N/A", "Line Out", "HP Out",
3354 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
3355 };
3356 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3357 uinfo->count = 1;
3358 uinfo->value.enumerated.items = 8;
3359 if (uinfo->value.enumerated.item >= 8)
3360 uinfo->value.enumerated.item = 7;
3361 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3362 return 0;
3363}
3364
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003365static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
3366 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003367{
3368 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3369 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3370 unsigned int pin_ctl, item = 0;
3371
3372 pin_ctl = snd_hda_codec_read(codec, nid, 0,
3373 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3374 if (pin_ctl & AC_PINCTL_OUT_EN) {
3375 if (pin_ctl & AC_PINCTL_HP_EN)
3376 item = 2;
3377 else
3378 item = 1;
3379 } else if (pin_ctl & AC_PINCTL_IN_EN) {
3380 switch (pin_ctl & AC_PINCTL_VREFEN) {
3381 case AC_PINCTL_VREF_HIZ: item = 3; break;
3382 case AC_PINCTL_VREF_50: item = 4; break;
3383 case AC_PINCTL_VREF_GRD: item = 5; break;
3384 case AC_PINCTL_VREF_80: item = 6; break;
3385 case AC_PINCTL_VREF_100: item = 7; break;
3386 }
3387 }
3388 ucontrol->value.enumerated.item[0] = item;
3389 return 0;
3390}
3391
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003392static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
3393 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003394{
3395 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3396 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3397 static unsigned int ctls[] = {
3398 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
3399 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
3400 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
3401 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
3402 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
3403 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
3404 };
3405 unsigned int old_ctl, new_ctl;
3406
3407 old_ctl = snd_hda_codec_read(codec, nid, 0,
3408 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3409 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
3410 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003411 int val;
3412 snd_hda_codec_write_cache(codec, nid, 0,
3413 AC_VERB_SET_PIN_WIDGET_CONTROL,
3414 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003415 val = ucontrol->value.enumerated.item[0] >= 3 ?
3416 HDA_AMP_MUTE : 0;
3417 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3418 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003419 return 1;
3420 }
3421 return 0;
3422}
3423
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003424static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
3425 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003426{
3427 static char *texts[] = {
3428 "Front", "Surround", "CLFE", "Side"
3429 };
3430 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3431 uinfo->count = 1;
3432 uinfo->value.enumerated.items = 4;
3433 if (uinfo->value.enumerated.item >= 4)
3434 uinfo->value.enumerated.item = 3;
3435 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3436 return 0;
3437}
3438
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003439static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
3440 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003441{
3442 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3443 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3444 unsigned int sel;
3445
3446 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
3447 ucontrol->value.enumerated.item[0] = sel & 3;
3448 return 0;
3449}
3450
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003451static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
3452 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003453{
3454 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3455 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3456 unsigned int sel;
3457
3458 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
3459 if (ucontrol->value.enumerated.item[0] != sel) {
3460 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003461 snd_hda_codec_write_cache(codec, nid, 0,
3462 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003463 return 1;
3464 }
3465 return 0;
3466}
3467
3468#define PIN_CTL_TEST(xname,nid) { \
3469 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3470 .name = xname, \
3471 .info = alc_test_pin_ctl_info, \
3472 .get = alc_test_pin_ctl_get, \
3473 .put = alc_test_pin_ctl_put, \
3474 .private_value = nid \
3475 }
3476
3477#define PIN_SRC_TEST(xname,nid) { \
3478 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3479 .name = xname, \
3480 .info = alc_test_pin_src_info, \
3481 .get = alc_test_pin_src_get, \
3482 .put = alc_test_pin_src_put, \
3483 .private_value = nid \
3484 }
3485
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003486static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003487 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3488 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3489 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
3490 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003491 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3492 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
3493 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
3494 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003495 PIN_CTL_TEST("Front Pin Mode", 0x14),
3496 PIN_CTL_TEST("Surround Pin Mode", 0x15),
3497 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
3498 PIN_CTL_TEST("Side Pin Mode", 0x17),
3499 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
3500 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
3501 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
3502 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
3503 PIN_SRC_TEST("In-1 Pin Source", 0x18),
3504 PIN_SRC_TEST("In-2 Pin Source", 0x19),
3505 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
3506 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
3507 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
3508 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
3509 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
3510 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
3511 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
3512 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
3513 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
3514 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
3515 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
3516 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003517 {
3518 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3519 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01003520 .info = alc_ch_mode_info,
3521 .get = alc_ch_mode_get,
3522 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003523 },
3524 { } /* end */
3525};
3526
3527static struct hda_verb alc880_test_init_verbs[] = {
3528 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003529 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3530 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3531 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3532 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3533 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3534 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3535 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3536 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003537 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003538 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3539 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3540 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3541 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003542 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003543 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3544 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3545 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3546 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003547 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003548 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3549 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3550 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3551 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003552 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02003553 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3554 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02003555 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3556 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3557 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003558 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02003559 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3560 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3561 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3562 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003563 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02003564 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003565 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003566 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003567 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003568 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003569 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003570 /* Analog input/passthru */
3571 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3572 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3573 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3574 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3575 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003576 { }
3577};
3578#endif
3579
Linus Torvalds1da177e2005-04-16 15:20:36 -07003580/*
3581 */
3582
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003583static const char *alc880_models[ALC880_MODEL_LAST] = {
3584 [ALC880_3ST] = "3stack",
3585 [ALC880_TCL_S700] = "tcl",
3586 [ALC880_3ST_DIG] = "3stack-digout",
3587 [ALC880_CLEVO] = "clevo",
3588 [ALC880_5ST] = "5stack",
3589 [ALC880_5ST_DIG] = "5stack-digout",
3590 [ALC880_W810] = "w810",
3591 [ALC880_Z71V] = "z71v",
3592 [ALC880_6ST] = "6stack",
3593 [ALC880_6ST_DIG] = "6stack-digout",
3594 [ALC880_ASUS] = "asus",
3595 [ALC880_ASUS_W1V] = "asus-w1v",
3596 [ALC880_ASUS_DIG] = "asus-dig",
3597 [ALC880_ASUS_DIG2] = "asus-dig2",
3598 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003599 [ALC880_UNIWILL_P53] = "uniwill-p53",
3600 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003601 [ALC880_F1734] = "F1734",
3602 [ALC880_LG] = "lg",
3603 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003604 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003605#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003606 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003607#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003608 [ALC880_AUTO] = "auto",
3609};
3610
3611static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003612 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003613 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
3614 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
3615 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
3616 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
3617 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
3618 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
3619 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
3620 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003621 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
3622 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003623 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
3624 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
3625 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
3626 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
3627 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
3628 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
3629 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
3630 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
3631 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
3632 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02003633 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003634 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
3635 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
3636 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01003637 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003638 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003639 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
3640 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003641 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
3642 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003643 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
3644 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
3645 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
3646 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003647 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
3648 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003649 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003650 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003651 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003652 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003653 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
3654 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003655 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003656 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003657 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003658 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003659 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02003660 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003661 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003662 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003663 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003664 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
3665 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003666 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003667 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
3668 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
3669 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
3670 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003671 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
3672 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003673 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003674 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003675 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
3676 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003677 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
3678 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
3679 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01003680 /* default Intel */
3681 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003682 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
3683 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003684 {}
3685};
3686
Takashi Iwai16ded522005-06-10 19:58:24 +02003687/*
Kailang Yangdf694da2005-12-05 19:42:22 +01003688 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02003689 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003690static struct alc_config_preset alc880_presets[] = {
3691 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003692 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003693 .init_verbs = { alc880_volume_init_verbs,
3694 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003695 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003696 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003697 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3698 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003699 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003700 .input_mux = &alc880_capture_source,
3701 },
3702 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003703 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003704 .init_verbs = { alc880_volume_init_verbs,
3705 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003706 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003707 .dac_nids = alc880_dac_nids,
3708 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003709 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3710 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003711 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003712 .input_mux = &alc880_capture_source,
3713 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003714 [ALC880_TCL_S700] = {
3715 .mixers = { alc880_tcl_s700_mixer },
3716 .init_verbs = { alc880_volume_init_verbs,
3717 alc880_pin_tcl_S700_init_verbs,
3718 alc880_gpio2_init_verbs },
3719 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3720 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01003721 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
3722 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01003723 .hp_nid = 0x03,
3724 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3725 .channel_mode = alc880_2_jack_modes,
3726 .input_mux = &alc880_capture_source,
3727 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003728 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003729 .mixers = { alc880_three_stack_mixer,
3730 alc880_five_stack_mixer},
3731 .init_verbs = { alc880_volume_init_verbs,
3732 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003733 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3734 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003735 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3736 .channel_mode = alc880_fivestack_modes,
3737 .input_mux = &alc880_capture_source,
3738 },
3739 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003740 .mixers = { alc880_three_stack_mixer,
3741 alc880_five_stack_mixer },
3742 .init_verbs = { alc880_volume_init_verbs,
3743 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003744 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3745 .dac_nids = alc880_dac_nids,
3746 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003747 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3748 .channel_mode = alc880_fivestack_modes,
3749 .input_mux = &alc880_capture_source,
3750 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003751 [ALC880_6ST] = {
3752 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003753 .init_verbs = { alc880_volume_init_verbs,
3754 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003755 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3756 .dac_nids = alc880_6st_dac_nids,
3757 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3758 .channel_mode = alc880_sixstack_modes,
3759 .input_mux = &alc880_6stack_capture_source,
3760 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003761 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003762 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003763 .init_verbs = { alc880_volume_init_verbs,
3764 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003765 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3766 .dac_nids = alc880_6st_dac_nids,
3767 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003768 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3769 .channel_mode = alc880_sixstack_modes,
3770 .input_mux = &alc880_6stack_capture_source,
3771 },
3772 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003773 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003774 .init_verbs = { alc880_volume_init_verbs,
3775 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003776 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003777 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
3778 .dac_nids = alc880_w810_dac_nids,
3779 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003780 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3781 .channel_mode = alc880_w810_modes,
3782 .input_mux = &alc880_capture_source,
3783 },
3784 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003785 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003786 .init_verbs = { alc880_volume_init_verbs,
3787 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003788 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
3789 .dac_nids = alc880_z71v_dac_nids,
3790 .dig_out_nid = ALC880_DIGOUT_NID,
3791 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003792 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3793 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02003794 .input_mux = &alc880_capture_source,
3795 },
3796 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003797 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003798 .init_verbs = { alc880_volume_init_verbs,
3799 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003800 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
3801 .dac_nids = alc880_f1734_dac_nids,
3802 .hp_nid = 0x02,
3803 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3804 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01003805 .input_mux = &alc880_f1734_capture_source,
3806 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003807 .init_hook = alc880_uniwill_p53_init_hook,
Takashi Iwai16ded522005-06-10 19:58:24 +02003808 },
3809 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003810 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003811 .init_verbs = { alc880_volume_init_verbs,
3812 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003813 alc880_gpio1_init_verbs },
3814 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3815 .dac_nids = alc880_asus_dac_nids,
3816 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3817 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003818 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003819 .input_mux = &alc880_capture_source,
3820 },
3821 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003822 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003823 .init_verbs = { alc880_volume_init_verbs,
3824 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003825 alc880_gpio1_init_verbs },
3826 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3827 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003828 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003829 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3830 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003831 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003832 .input_mux = &alc880_capture_source,
3833 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003834 [ALC880_ASUS_DIG2] = {
3835 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003836 .init_verbs = { alc880_volume_init_verbs,
3837 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01003838 alc880_gpio2_init_verbs }, /* use GPIO2 */
3839 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3840 .dac_nids = alc880_asus_dac_nids,
3841 .dig_out_nid = ALC880_DIGOUT_NID,
3842 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3843 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003844 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003845 .input_mux = &alc880_capture_source,
3846 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003847 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003848 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003849 .init_verbs = { alc880_volume_init_verbs,
3850 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003851 alc880_gpio1_init_verbs },
3852 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3853 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003854 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003855 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3856 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003857 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003858 .input_mux = &alc880_capture_source,
3859 },
3860 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01003861 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02003862 .init_verbs = { alc880_volume_init_verbs,
3863 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003864 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3865 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003866 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003867 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3868 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003869 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003870 .input_mux = &alc880_capture_source,
3871 },
Kailang Yangccc656c2006-10-17 12:32:26 +02003872 [ALC880_UNIWILL] = {
3873 .mixers = { alc880_uniwill_mixer },
3874 .init_verbs = { alc880_volume_init_verbs,
3875 alc880_uniwill_init_verbs },
3876 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3877 .dac_nids = alc880_asus_dac_nids,
3878 .dig_out_nid = ALC880_DIGOUT_NID,
3879 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3880 .channel_mode = alc880_threestack_modes,
3881 .need_dac_fix = 1,
3882 .input_mux = &alc880_capture_source,
3883 .unsol_event = alc880_uniwill_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003884 .init_hook = alc880_uniwill_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02003885 },
3886 [ALC880_UNIWILL_P53] = {
3887 .mixers = { alc880_uniwill_p53_mixer },
3888 .init_verbs = { alc880_volume_init_verbs,
3889 alc880_uniwill_p53_init_verbs },
3890 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3891 .dac_nids = alc880_asus_dac_nids,
3892 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003893 .channel_mode = alc880_threestack_modes,
3894 .input_mux = &alc880_capture_source,
3895 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003896 .init_hook = alc880_uniwill_p53_init_hook,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003897 },
3898 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01003899 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003900 .init_verbs = { alc880_volume_init_verbs,
3901 alc880_uniwill_p53_init_verbs,
3902 alc880_beep_init_verbs },
3903 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3904 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02003905 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003906 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3907 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02003908 .input_mux = &alc880_capture_source,
3909 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003910 .init_hook = alc880_uniwill_p53_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02003911 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003912 [ALC880_CLEVO] = {
3913 .mixers = { alc880_three_stack_mixer },
3914 .init_verbs = { alc880_volume_init_verbs,
3915 alc880_pin_clevo_init_verbs },
3916 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3917 .dac_nids = alc880_dac_nids,
3918 .hp_nid = 0x03,
3919 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3920 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003921 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003922 .input_mux = &alc880_capture_source,
3923 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003924 [ALC880_LG] = {
3925 .mixers = { alc880_lg_mixer },
3926 .init_verbs = { alc880_volume_init_verbs,
3927 alc880_lg_init_verbs },
3928 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
3929 .dac_nids = alc880_lg_dac_nids,
3930 .dig_out_nid = ALC880_DIGOUT_NID,
3931 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
3932 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003933 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003934 .input_mux = &alc880_lg_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003935 .unsol_event = alc_automute_amp_unsol_event,
3936 .init_hook = alc880_lg_init_hook,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003937#ifdef CONFIG_SND_HDA_POWER_SAVE
3938 .loopbacks = alc880_lg_loopbacks,
3939#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003940 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003941 [ALC880_LG_LW] = {
3942 .mixers = { alc880_lg_lw_mixer },
3943 .init_verbs = { alc880_volume_init_verbs,
3944 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003945 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01003946 .dac_nids = alc880_dac_nids,
3947 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003948 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
3949 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01003950 .input_mux = &alc880_lg_lw_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003951 .unsol_event = alc_automute_amp_unsol_event,
3952 .init_hook = alc880_lg_lw_init_hook,
Takashi Iwaid6815182006-03-23 16:06:23 +01003953 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003954 [ALC880_MEDION_RIM] = {
3955 .mixers = { alc880_medion_rim_mixer },
3956 .init_verbs = { alc880_volume_init_verbs,
3957 alc880_medion_rim_init_verbs,
3958 alc_gpio2_init_verbs },
3959 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3960 .dac_nids = alc880_dac_nids,
3961 .dig_out_nid = ALC880_DIGOUT_NID,
3962 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3963 .channel_mode = alc880_2_jack_modes,
3964 .input_mux = &alc880_medion_rim_capture_source,
3965 .unsol_event = alc880_medion_rim_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003966 .init_hook = alc880_medion_rim_init_hook,
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003967 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003968#ifdef CONFIG_SND_DEBUG
3969 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003970 .mixers = { alc880_test_mixer },
3971 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003972 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
3973 .dac_nids = alc880_test_dac_nids,
3974 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003975 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
3976 .channel_mode = alc880_test_modes,
3977 .input_mux = &alc880_test_capture_source,
3978 },
3979#endif
3980};
3981
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003982/*
3983 * Automatic parse of I/O pins from the BIOS configuration
3984 */
3985
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003986enum {
3987 ALC_CTL_WIDGET_VOL,
3988 ALC_CTL_WIDGET_MUTE,
3989 ALC_CTL_BIND_MUTE,
3990};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003991static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003992 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
3993 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01003994 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003995};
3996
3997/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003998static int add_control(struct alc_spec *spec, int type, const char *name,
3999 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004000{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004001 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004002
Takashi Iwai603c4012008-07-30 15:01:44 +02004003 snd_array_init(&spec->kctls, sizeof(*knew), 32);
4004 knew = snd_array_new(&spec->kctls);
4005 if (!knew)
4006 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004007 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07004008 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004009 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004010 return -ENOMEM;
4011 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004012 return 0;
4013}
4014
4015#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
4016#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
4017#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
4018#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
4019#define alc880_is_input_pin(nid) ((nid) >= 0x18)
4020#define alc880_input_pin_idx(nid) ((nid) - 0x18)
4021#define alc880_idx_to_dac(nid) ((nid) + 0x02)
4022#define alc880_dac_to_idx(nid) ((nid) - 0x02)
4023#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
4024#define alc880_idx_to_selector(nid) ((nid) + 0x10)
4025#define ALC880_PIN_CD_NID 0x1c
4026
4027/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004028static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
4029 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004030{
4031 hda_nid_t nid;
4032 int assigned[4];
4033 int i, j;
4034
4035 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004036 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004037
4038 /* check the pins hardwired to audio widget */
4039 for (i = 0; i < cfg->line_outs; i++) {
4040 nid = cfg->line_out_pins[i];
4041 if (alc880_is_fixed_pin(nid)) {
4042 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01004043 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004044 assigned[idx] = 1;
4045 }
4046 }
4047 /* left pins can be connect to any audio widget */
4048 for (i = 0; i < cfg->line_outs; i++) {
4049 nid = cfg->line_out_pins[i];
4050 if (alc880_is_fixed_pin(nid))
4051 continue;
4052 /* search for an empty channel */
4053 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004054 if (!assigned[j]) {
4055 spec->multiout.dac_nids[i] =
4056 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004057 assigned[j] = 1;
4058 break;
4059 }
4060 }
4061 }
4062 spec->multiout.num_dacs = cfg->line_outs;
4063 return 0;
4064}
4065
4066/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01004067static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
4068 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004069{
4070 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004071 static const char *chname[4] = {
4072 "Front", "Surround", NULL /*CLFE*/, "Side"
4073 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004074 hda_nid_t nid;
4075 int i, err;
4076
4077 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004078 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004079 continue;
4080 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4081 if (i == 2) {
4082 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004083 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4084 "Center Playback Volume",
4085 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
4086 HDA_OUTPUT));
4087 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004088 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004089 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4090 "LFE Playback Volume",
4091 HDA_COMPOSE_AMP_VAL(nid, 2, 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_BIND_MUTE,
4096 "Center Playback Switch",
4097 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
4098 HDA_INPUT));
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 "LFE Playback Switch",
4103 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
4104 HDA_INPUT));
4105 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004106 return err;
4107 } else {
4108 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004109 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4110 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4111 HDA_OUTPUT));
4112 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004113 return err;
4114 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004115 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4116 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4117 HDA_INPUT));
4118 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004119 return err;
4120 }
4121 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004122 return 0;
4123}
4124
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004125/* add playback controls for speaker and HP outputs */
4126static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
4127 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004128{
4129 hda_nid_t nid;
4130 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004131 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004132
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004133 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004134 return 0;
4135
4136 if (alc880_is_fixed_pin(pin)) {
4137 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01004138 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004139 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004140 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004141 else
4142 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004143 /* control HP volume/switch on the output mixer amp */
4144 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004145 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004146 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4147 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
4148 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004149 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004150 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004151 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4152 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
4153 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004154 return err;
4155 } else if (alc880_is_multi_pin(pin)) {
4156 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004157 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004158 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004159 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4160 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
4161 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004162 return err;
4163 }
4164 return 0;
4165}
4166
4167/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004168static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4169 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01004170 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004171{
4172 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01004173 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004174
4175 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004176 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4177 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4178 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004179 return err;
4180 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004181 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4182 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4183 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004184 return err;
4185 return 0;
4186}
4187
4188/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01004189static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
4190 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004191{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004192 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004193 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004194
4195 for (i = 0; i < AUTO_PIN_LAST; i++) {
4196 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01004197 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01004198 err = new_analog_input(spec, cfg->input_pins[i],
4199 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01004200 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004201 if (err < 0)
4202 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004203 imux->items[imux->num_items].label =
4204 auto_pin_cfg_labels[i];
4205 imux->items[imux->num_items].index =
4206 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004207 imux->num_items++;
4208 }
4209 }
4210 return 0;
4211}
4212
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004213static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
4214 unsigned int pin_type)
4215{
4216 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4217 pin_type);
4218 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01004219 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4220 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004221}
4222
Kailang Yangdf694da2005-12-05 19:42:22 +01004223static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
4224 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004225 int dac_idx)
4226{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004227 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004228 /* need the manual connection? */
4229 if (alc880_is_multi_pin(nid)) {
4230 struct alc_spec *spec = codec->spec;
4231 int idx = alc880_multi_pin_idx(nid);
4232 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
4233 AC_VERB_SET_CONNECT_SEL,
4234 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
4235 }
4236}
4237
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004238static int get_pin_type(int line_out_type)
4239{
4240 if (line_out_type == AUTO_PIN_HP_OUT)
4241 return PIN_HP;
4242 else
4243 return PIN_OUT;
4244}
4245
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004246static void alc880_auto_init_multi_out(struct hda_codec *codec)
4247{
4248 struct alc_spec *spec = codec->spec;
4249 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02004250
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004251 for (i = 0; i < spec->autocfg.line_outs; i++) {
4252 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004253 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4254 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004255 }
4256}
4257
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004258static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004259{
4260 struct alc_spec *spec = codec->spec;
4261 hda_nid_t pin;
4262
Takashi Iwai82bc9552006-03-21 11:24:42 +01004263 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004264 if (pin) /* connect to front */
4265 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004266 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004267 if (pin) /* connect to front */
4268 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
4269}
4270
4271static void alc880_auto_init_analog_input(struct hda_codec *codec)
4272{
4273 struct alc_spec *spec = codec->spec;
4274 int i;
4275
4276 for (i = 0; i < AUTO_PIN_LAST; i++) {
4277 hda_nid_t nid = spec->autocfg.input_pins[i];
4278 if (alc880_is_input_pin(nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01004279 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01004280 if (nid != ALC880_PIN_CD_NID &&
4281 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004282 snd_hda_codec_write(codec, nid, 0,
4283 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004284 AMP_OUT_MUTE);
4285 }
4286 }
4287}
4288
4289/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004290/* return 1 if successful, 0 if the proper config is not found,
4291 * or a negative error code
4292 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004293static int alc880_parse_auto_config(struct hda_codec *codec)
4294{
4295 struct alc_spec *spec = codec->spec;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004296 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +01004297 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004298
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004299 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4300 alc880_ignore);
4301 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004302 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004303 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004304 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01004305
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004306 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
4307 if (err < 0)
4308 return err;
4309 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
4310 if (err < 0)
4311 return err;
4312 err = alc880_auto_create_extra_out(spec,
4313 spec->autocfg.speaker_pins[0],
4314 "Speaker");
4315 if (err < 0)
4316 return err;
4317 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
4318 "Headphone");
4319 if (err < 0)
4320 return err;
4321 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
4322 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004323 return err;
4324
4325 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4326
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004327 /* check multiple SPDIF-out (for recent codecs) */
4328 for (i = 0; i < spec->autocfg.dig_outs; i++) {
4329 hda_nid_t dig_nid;
4330 err = snd_hda_get_connections(codec,
4331 spec->autocfg.dig_out_pins[i],
4332 &dig_nid, 1);
4333 if (err < 0)
4334 continue;
4335 if (!i)
4336 spec->multiout.dig_out_nid = dig_nid;
4337 else {
4338 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
4339 spec->slave_dig_outs[i - 1] = dig_nid;
4340 if (i == ARRAY_SIZE(spec->slave_dig_outs) - 1)
4341 break;
4342 }
4343 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004344 if (spec->autocfg.dig_in_pin)
4345 spec->dig_in_nid = ALC880_DIGIN_NID;
4346
Takashi Iwai603c4012008-07-30 15:01:44 +02004347 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01004348 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004349
Takashi Iwaid88897e2008-10-31 15:01:37 +01004350 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004351
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004352 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004353 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004354
Takashi Iwai4a79ba32009-04-22 16:31:35 +02004355 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
4356
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004357 return 1;
4358}
4359
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004360/* additional initialization for auto-configuration model */
4361static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004362{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004363 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004364 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004365 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004366 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004367 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02004368 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004369}
4370
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004371static void set_capture_mixer(struct alc_spec *spec)
4372{
Takashi Iwaia23b6882009-03-23 15:21:36 +01004373 static struct snd_kcontrol_new *caps[2][3] = {
4374 { alc_capture_mixer_nosrc1,
4375 alc_capture_mixer_nosrc2,
4376 alc_capture_mixer_nosrc3 },
4377 { alc_capture_mixer1,
4378 alc_capture_mixer2,
4379 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004380 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01004381 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
4382 int mux;
4383 if (spec->input_mux && spec->input_mux->num_items > 1)
4384 mux = 1;
4385 else
4386 mux = 0;
4387 spec->cap_mixer = caps[mux][spec->num_adc_nids - 1];
4388 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004389}
4390
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004391#define set_beep_amp(spec, nid, idx, dir) \
4392 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
4393
4394/*
4395 * OK, here we have finally the patch for ALC880
4396 */
4397
Linus Torvalds1da177e2005-04-16 15:20:36 -07004398static int patch_alc880(struct hda_codec *codec)
4399{
4400 struct alc_spec *spec;
4401 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01004402 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004403
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004404 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004405 if (spec == NULL)
4406 return -ENOMEM;
4407
4408 codec->spec = spec;
4409
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004410 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
4411 alc880_models,
4412 alc880_cfg_tbl);
4413 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +02004414 printk(KERN_INFO "hda_codec: Unknown model for %s, "
4415 "trying auto-probe from BIOS...\n", codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004416 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004417 }
4418
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004419 if (board_config == ALC880_AUTO) {
4420 /* automatic parse from the BIOS config */
4421 err = alc880_parse_auto_config(codec);
4422 if (err < 0) {
4423 alc_free(codec);
4424 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004425 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004426 printk(KERN_INFO
4427 "hda_codec: Cannot set up configuration "
4428 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004429 board_config = ALC880_3ST;
4430 }
4431 }
4432
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09004433 err = snd_hda_attach_beep_device(codec, 0x1);
4434 if (err < 0) {
4435 alc_free(codec);
4436 return err;
4437 }
4438
Kailang Yangdf694da2005-12-05 19:42:22 +01004439 if (board_config != ALC880_AUTO)
4440 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004441
Linus Torvalds1da177e2005-04-16 15:20:36 -07004442 spec->stream_analog_playback = &alc880_pcm_analog_playback;
4443 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01004444 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004445
Linus Torvalds1da177e2005-04-16 15:20:36 -07004446 spec->stream_digital_playback = &alc880_pcm_digital_playback;
4447 spec->stream_digital_capture = &alc880_pcm_digital_capture;
4448
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004449 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004450 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01004451 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004452 /* get type */
4453 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004454 if (wcap != AC_WID_AUD_IN) {
4455 spec->adc_nids = alc880_adc_nids_alt;
4456 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004457 } else {
4458 spec->adc_nids = alc880_adc_nids;
4459 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004460 }
4461 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004462 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004463 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004464
Takashi Iwai2134ea42008-01-10 16:53:55 +01004465 spec->vmaster_nid = 0x0c;
4466
Linus Torvalds1da177e2005-04-16 15:20:36 -07004467 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004468 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004469 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02004470#ifdef CONFIG_SND_HDA_POWER_SAVE
4471 if (!spec->loopback.amplist)
4472 spec->loopback.amplist = alc880_loopbacks;
4473#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01004474 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004475
4476 return 0;
4477}
4478
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004479
Linus Torvalds1da177e2005-04-16 15:20:36 -07004480/*
4481 * ALC260 support
4482 */
4483
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004484static hda_nid_t alc260_dac_nids[1] = {
4485 /* front */
4486 0x02,
4487};
4488
4489static hda_nid_t alc260_adc_nids[1] = {
4490 /* ADC0 */
4491 0x04,
4492};
4493
Kailang Yangdf694da2005-12-05 19:42:22 +01004494static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004495 /* ADC1 */
4496 0x05,
4497};
4498
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004499/* NIDs used when simultaneous access to both ADCs makes sense. Note that
4500 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
4501 */
4502static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004503 /* ADC0, ADC1 */
4504 0x04, 0x05
4505};
4506
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004507#define ALC260_DIGOUT_NID 0x03
4508#define ALC260_DIGIN_NID 0x06
4509
4510static struct hda_input_mux alc260_capture_source = {
4511 .num_items = 4,
4512 .items = {
4513 { "Mic", 0x0 },
4514 { "Front Mic", 0x1 },
4515 { "Line", 0x2 },
4516 { "CD", 0x4 },
4517 },
4518};
4519
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004520/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004521 * headphone jack and the internal CD lines since these are the only pins at
4522 * which audio can appear. For flexibility, also allow the option of
4523 * recording the mixer output on the second ADC (ADC0 doesn't have a
4524 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004525 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004526static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
4527 {
4528 .num_items = 3,
4529 .items = {
4530 { "Mic/Line", 0x0 },
4531 { "CD", 0x4 },
4532 { "Headphone", 0x2 },
4533 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004534 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004535 {
4536 .num_items = 4,
4537 .items = {
4538 { "Mic/Line", 0x0 },
4539 { "CD", 0x4 },
4540 { "Headphone", 0x2 },
4541 { "Mixer", 0x5 },
4542 },
4543 },
4544
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004545};
4546
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004547/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
4548 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004549 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004550static struct hda_input_mux alc260_acer_capture_sources[2] = {
4551 {
4552 .num_items = 4,
4553 .items = {
4554 { "Mic", 0x0 },
4555 { "Line", 0x2 },
4556 { "CD", 0x4 },
4557 { "Headphone", 0x5 },
4558 },
4559 },
4560 {
4561 .num_items = 5,
4562 .items = {
4563 { "Mic", 0x0 },
4564 { "Line", 0x2 },
4565 { "CD", 0x4 },
4566 { "Headphone", 0x6 },
4567 { "Mixer", 0x5 },
4568 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004569 },
4570};
Michael Schwingencc959482009-02-22 18:58:45 +01004571
4572/* Maxdata Favorit 100XS */
4573static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
4574 {
4575 .num_items = 2,
4576 .items = {
4577 { "Line/Mic", 0x0 },
4578 { "CD", 0x4 },
4579 },
4580 },
4581 {
4582 .num_items = 3,
4583 .items = {
4584 { "Line/Mic", 0x0 },
4585 { "CD", 0x4 },
4586 { "Mixer", 0x5 },
4587 },
4588 },
4589};
4590
Linus Torvalds1da177e2005-04-16 15:20:36 -07004591/*
4592 * This is just place-holder, so there's something for alc_build_pcms to look
4593 * at when it calculates the maximum number of channels. ALC260 has no mixer
4594 * element which allows changing the channel mode, so the verb list is
4595 * never used.
4596 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004597static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004598 { 2, NULL },
4599};
4600
Kailang Yangdf694da2005-12-05 19:42:22 +01004601
4602/* Mixer combinations
4603 *
4604 * basic: base_output + input + pc_beep + capture
4605 * HP: base_output + input + capture_alt
4606 * HP_3013: hp_3013 + input + capture
4607 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004608 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01004609 */
4610
4611static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004612 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004613 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004614 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4615 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4616 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4617 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4618 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004619};
Kailang Yangdf694da2005-12-05 19:42:22 +01004620
4621static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004622 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4623 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4624 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4625 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4626 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4627 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4628 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
4629 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004630 { } /* end */
4631};
4632
Takashi Iwaibec15c32008-01-28 18:16:30 +01004633/* update HP, line and mono out pins according to the master switch */
4634static void alc260_hp_master_update(struct hda_codec *codec,
4635 hda_nid_t hp, hda_nid_t line,
4636 hda_nid_t mono)
4637{
4638 struct alc_spec *spec = codec->spec;
4639 unsigned int val = spec->master_sw ? PIN_HP : 0;
4640 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004641 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004642 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004643 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004644 val);
4645 /* mono (speaker) depending on the HP jack sense */
4646 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004647 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004648 val);
4649}
4650
4651static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
4652 struct snd_ctl_elem_value *ucontrol)
4653{
4654 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4655 struct alc_spec *spec = codec->spec;
4656 *ucontrol->value.integer.value = spec->master_sw;
4657 return 0;
4658}
4659
4660static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
4661 struct snd_ctl_elem_value *ucontrol)
4662{
4663 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4664 struct alc_spec *spec = codec->spec;
4665 int val = !!*ucontrol->value.integer.value;
4666 hda_nid_t hp, line, mono;
4667
4668 if (val == spec->master_sw)
4669 return 0;
4670 spec->master_sw = val;
4671 hp = (kcontrol->private_value >> 16) & 0xff;
4672 line = (kcontrol->private_value >> 8) & 0xff;
4673 mono = kcontrol->private_value & 0xff;
4674 alc260_hp_master_update(codec, hp, line, mono);
4675 return 1;
4676}
4677
4678static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
4679 {
4680 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4681 .name = "Master Playback Switch",
4682 .info = snd_ctl_boolean_mono_info,
4683 .get = alc260_hp_master_sw_get,
4684 .put = alc260_hp_master_sw_put,
4685 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
4686 },
4687 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4688 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
4689 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4690 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4691 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
4692 HDA_OUTPUT),
4693 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4694 { } /* end */
4695};
4696
4697static struct hda_verb alc260_hp_unsol_verbs[] = {
4698 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4699 {},
4700};
4701
4702static void alc260_hp_automute(struct hda_codec *codec)
4703{
4704 struct alc_spec *spec = codec->spec;
4705 unsigned int present;
4706
4707 present = snd_hda_codec_read(codec, 0x10, 0,
4708 AC_VERB_GET_PIN_SENSE, 0);
4709 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4710 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
4711}
4712
4713static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
4714{
4715 if ((res >> 26) == ALC880_HP_EVENT)
4716 alc260_hp_automute(codec);
4717}
4718
Kailang Yangdf694da2005-12-05 19:42:22 +01004719static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01004720 {
4721 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4722 .name = "Master Playback Switch",
4723 .info = snd_ctl_boolean_mono_info,
4724 .get = alc260_hp_master_sw_get,
4725 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004726 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01004727 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004728 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4729 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4730 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
4731 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
4732 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4733 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01004734 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4735 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02004736 { } /* end */
4737};
4738
Kailang Yang3f878302008-08-26 13:02:23 +02004739static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
4740 .ops = &snd_hda_bind_vol,
4741 .values = {
4742 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
4743 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
4744 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
4745 0
4746 },
4747};
4748
4749static struct hda_bind_ctls alc260_dc7600_bind_switch = {
4750 .ops = &snd_hda_bind_sw,
4751 .values = {
4752 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
4753 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
4754 0
4755 },
4756};
4757
4758static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
4759 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
4760 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
4761 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
4762 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4763 { } /* end */
4764};
4765
Takashi Iwaibec15c32008-01-28 18:16:30 +01004766static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
4767 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4768 {},
4769};
4770
4771static void alc260_hp_3013_automute(struct hda_codec *codec)
4772{
4773 struct alc_spec *spec = codec->spec;
4774 unsigned int present;
4775
4776 present = snd_hda_codec_read(codec, 0x15, 0,
4777 AC_VERB_GET_PIN_SENSE, 0);
4778 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004779 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01004780}
4781
4782static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
4783 unsigned int res)
4784{
4785 if ((res >> 26) == ALC880_HP_EVENT)
4786 alc260_hp_3013_automute(codec);
4787}
4788
Kailang Yang3f878302008-08-26 13:02:23 +02004789static void alc260_hp_3012_automute(struct hda_codec *codec)
4790{
4791 unsigned int present, bits;
4792
4793 present = snd_hda_codec_read(codec, 0x10, 0,
4794 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
4795
4796 bits = present ? 0 : PIN_OUT;
4797 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4798 bits);
4799 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4800 bits);
4801 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4802 bits);
4803}
4804
4805static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
4806 unsigned int res)
4807{
4808 if ((res >> 26) == ALC880_HP_EVENT)
4809 alc260_hp_3012_automute(codec);
4810}
4811
4812/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004813 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
4814 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004815static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004816 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004817 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004818 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004819 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4820 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4821 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
4822 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004823 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004824 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4825 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004826 { } /* end */
4827};
4828
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004829/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
4830 * versions of the ALC260 don't act on requests to enable mic bias from NID
4831 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
4832 * datasheet doesn't mention this restriction. At this stage it's not clear
4833 * whether this behaviour is intentional or is a hardware bug in chip
4834 * revisions available in early 2006. Therefore for now allow the
4835 * "Headphone Jack Mode" control to span all choices, but if it turns out
4836 * that the lack of mic bias for this NID is intentional we could change the
4837 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4838 *
4839 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
4840 * don't appear to make the mic bias available from the "line" jack, even
4841 * though the NID used for this jack (0x14) can supply it. The theory is
4842 * that perhaps Acer have included blocking capacitors between the ALC260
4843 * and the output jack. If this turns out to be the case for all such
4844 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
4845 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01004846 *
4847 * The C20x Tablet series have a mono internal speaker which is controlled
4848 * via the chip's Mono sum widget and pin complex, so include the necessary
4849 * controls for such models. On models without a "mono speaker" the control
4850 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004851 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004852static struct snd_kcontrol_new alc260_acer_mixer[] = {
4853 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4854 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004855 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004856 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01004857 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004858 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01004859 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004860 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4861 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4862 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4863 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4864 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4865 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4866 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4867 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004868 { } /* end */
4869};
4870
Michael Schwingencc959482009-02-22 18:58:45 +01004871/* Maxdata Favorit 100XS: one output and one input (0x12) jack
4872 */
4873static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
4874 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4875 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
4876 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
4877 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4878 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4879 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4880 { } /* end */
4881};
4882
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004883/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
4884 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
4885 */
4886static struct snd_kcontrol_new alc260_will_mixer[] = {
4887 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4888 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4889 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4890 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4891 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4892 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4893 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4894 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4895 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4896 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004897 { } /* end */
4898};
4899
4900/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
4901 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
4902 */
4903static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
4904 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4905 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4906 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4907 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4908 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4909 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
4910 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
4911 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4912 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4913 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4914 { } /* end */
4915};
4916
Kailang Yangdf694da2005-12-05 19:42:22 +01004917/*
4918 * initialization verbs
4919 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004920static struct hda_verb alc260_init_verbs[] = {
4921 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004922 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004923 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004924 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004925 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004926 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004927 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004928 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004929 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02004930 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004931 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01004932 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004933 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02004934 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004935 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02004936 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004937 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02004938 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4939 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02004940 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004941 /* set connection select to line in (default select for this ADC) */
4942 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02004943 /* mute capture amp left and right */
4944 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4945 /* set connection select to line in (default select for this ADC) */
4946 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02004947 /* set vol=0 Line-Out mixer amp left and right */
4948 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4949 /* unmute pin widget amp left and right (no gain on this amp) */
4950 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4951 /* set vol=0 HP mixer amp left and right */
4952 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4953 /* unmute pin widget amp left and right (no gain on this amp) */
4954 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4955 /* set vol=0 Mono mixer amp left and right */
4956 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4957 /* unmute pin widget amp left and right (no gain on this amp) */
4958 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4959 /* unmute LINE-2 out pin */
4960 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004961 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4962 * Line In 2 = 0x03
4963 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004964 /* mute analog inputs */
4965 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4966 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4967 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4968 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4969 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004970 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004971 /* mute Front out path */
4972 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4973 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4974 /* mute Headphone out path */
4975 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4976 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4977 /* mute Mono out path */
4978 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4979 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004980 { }
4981};
4982
Takashi Iwai474167d2006-05-17 17:17:43 +02004983#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01004984static struct hda_verb alc260_hp_init_verbs[] = {
4985 /* Headphone and output */
4986 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4987 /* mono output */
4988 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4989 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4990 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4991 /* Mic2 (front panel) pin widget for input and vref at 80% */
4992 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4993 /* Line In pin widget for input */
4994 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4995 /* Line-2 pin widget for output */
4996 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4997 /* CD pin widget for input */
4998 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4999 /* unmute amp left and right */
5000 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5001 /* set connection select to line in (default select for this ADC) */
5002 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5003 /* unmute Line-Out mixer amp left and right (volume = 0) */
5004 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5005 /* mute pin widget amp left and right (no gain on this amp) */
5006 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5007 /* unmute HP mixer amp left and right (volume = 0) */
5008 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5009 /* mute pin widget amp left and right (no gain on this amp) */
5010 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005011 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5012 * Line In 2 = 0x03
5013 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005014 /* mute analog inputs */
5015 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5016 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5017 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5018 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5019 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005020 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5021 /* Unmute Front out path */
5022 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5023 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5024 /* Unmute Headphone out path */
5025 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5026 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5027 /* Unmute Mono out path */
5028 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5029 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5030 { }
5031};
Takashi Iwai474167d2006-05-17 17:17:43 +02005032#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005033
5034static struct hda_verb alc260_hp_3013_init_verbs[] = {
5035 /* Line out and output */
5036 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5037 /* mono output */
5038 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5039 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5040 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5041 /* Mic2 (front panel) pin widget for input and vref at 80% */
5042 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5043 /* Line In pin widget for input */
5044 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5045 /* Headphone pin widget for output */
5046 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5047 /* CD pin widget for input */
5048 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5049 /* unmute amp left and right */
5050 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5051 /* set connection select to line in (default select for this ADC) */
5052 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5053 /* unmute Line-Out mixer amp left and right (volume = 0) */
5054 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5055 /* mute pin widget amp left and right (no gain on this amp) */
5056 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5057 /* unmute HP mixer amp left and right (volume = 0) */
5058 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5059 /* mute pin widget amp left and right (no gain on this amp) */
5060 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005061 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5062 * Line In 2 = 0x03
5063 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005064 /* mute analog inputs */
5065 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5066 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5067 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5068 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5069 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005070 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5071 /* Unmute Front out path */
5072 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5073 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5074 /* Unmute Headphone out path */
5075 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5076 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5077 /* Unmute Mono out path */
5078 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5079 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5080 { }
5081};
5082
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005083/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005084 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
5085 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005086 */
5087static struct hda_verb alc260_fujitsu_init_verbs[] = {
5088 /* Disable all GPIOs */
5089 {0x01, AC_VERB_SET_GPIO_MASK, 0},
5090 /* Internal speaker is connected to headphone pin */
5091 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5092 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
5093 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005094 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
5095 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5096 /* Ensure all other unused pins are disabled and muted. */
5097 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5098 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005099 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005100 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005101 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005102 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5103 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5104 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005105
Jonathan Woithef7ace402006-02-28 11:46:14 +01005106 /* Disable digital (SPDIF) pins */
5107 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5108 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005109
Kailang Yangea1fb292008-08-26 12:58:38 +02005110 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01005111 * when acting as an output.
5112 */
5113 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5114
5115 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01005116 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5117 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5118 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5119 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5120 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5121 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5122 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5123 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5124 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005125
Jonathan Woithef7ace402006-02-28 11:46:14 +01005126 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
5127 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5128 /* Unmute Line1 pin widget output buffer since it starts as an output.
5129 * If the pin mode is changed by the user the pin mode control will
5130 * take care of enabling the pin's input/output buffers as needed.
5131 * Therefore there's no need to enable the input buffer at this
5132 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005133 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005134 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02005135 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005136 * mixer ctrl)
5137 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005138 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005139
Jonathan Woithef7ace402006-02-28 11:46:14 +01005140 /* Mute capture amp left and right */
5141 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005142 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01005143 * in (on mic1 pin)
5144 */
5145 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005146
Jonathan Woithef7ace402006-02-28 11:46:14 +01005147 /* Do the same for the second ADC: mute capture input amp and
5148 * set ADC connection to line in (on mic1 pin)
5149 */
5150 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5151 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005152
Jonathan Woithef7ace402006-02-28 11:46:14 +01005153 /* Mute all inputs to mixer widget (even unconnected ones) */
5154 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5155 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5156 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5157 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5158 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5159 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5160 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5161 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005162
5163 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005164};
5165
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005166/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
5167 * similar laptops (adapted from Fujitsu init verbs).
5168 */
5169static struct hda_verb alc260_acer_init_verbs[] = {
5170 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
5171 * the headphone jack. Turn this on and rely on the standard mute
5172 * methods whenever the user wants to turn these outputs off.
5173 */
5174 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5175 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5176 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5177 /* Internal speaker/Headphone jack is connected to Line-out pin */
5178 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5179 /* Internal microphone/Mic jack is connected to Mic1 pin */
5180 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5181 /* Line In jack is connected to Line1 pin */
5182 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01005183 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
5184 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005185 /* Ensure all other unused pins are disabled and muted. */
5186 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5187 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005188 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5189 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5190 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5191 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5192 /* Disable digital (SPDIF) pins */
5193 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5194 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5195
Kailang Yangea1fb292008-08-26 12:58:38 +02005196 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005197 * bus when acting as outputs.
5198 */
5199 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5200 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5201
5202 /* Start with output sum widgets muted and their output gains at min */
5203 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5204 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5205 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5206 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5207 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5208 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5209 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5210 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5211 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5212
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005213 /* Unmute Line-out pin widget amp left and right
5214 * (no equiv mixer ctrl)
5215 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005216 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01005217 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
5218 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005219 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5220 * inputs. If the pin mode is changed by the user the pin mode control
5221 * will take care of enabling the pin's input/output buffers as needed.
5222 * Therefore there's no need to enable the input buffer at this
5223 * stage.
5224 */
5225 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5226 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5227
5228 /* Mute capture amp left and right */
5229 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5230 /* Set ADC connection select to match default mixer setting - mic
5231 * (on mic1 pin)
5232 */
5233 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5234
5235 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005236 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005237 */
5238 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005239 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005240
5241 /* Mute all inputs to mixer widget (even unconnected ones) */
5242 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5243 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5244 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5245 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5246 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5247 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5248 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5249 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5250
5251 { }
5252};
5253
Michael Schwingencc959482009-02-22 18:58:45 +01005254/* Initialisation sequence for Maxdata Favorit 100XS
5255 * (adapted from Acer init verbs).
5256 */
5257static struct hda_verb alc260_favorit100_init_verbs[] = {
5258 /* GPIO 0 enables the output jack.
5259 * Turn this on and rely on the standard mute
5260 * methods whenever the user wants to turn these outputs off.
5261 */
5262 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5263 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5264 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5265 /* Line/Mic input jack is connected to Mic1 pin */
5266 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5267 /* Ensure all other unused pins are disabled and muted. */
5268 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5269 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5270 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5271 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5272 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5273 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5274 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5275 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5276 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5277 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5278 /* Disable digital (SPDIF) pins */
5279 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5280 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5281
5282 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
5283 * bus when acting as outputs.
5284 */
5285 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5286 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5287
5288 /* Start with output sum widgets muted and their output gains at min */
5289 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5290 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5291 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5292 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5293 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5294 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5295 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5296 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5297 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5298
5299 /* Unmute Line-out pin widget amp left and right
5300 * (no equiv mixer ctrl)
5301 */
5302 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5303 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5304 * inputs. If the pin mode is changed by the user the pin mode control
5305 * will take care of enabling the pin's input/output buffers as needed.
5306 * Therefore there's no need to enable the input buffer at this
5307 * stage.
5308 */
5309 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5310
5311 /* Mute capture amp left and right */
5312 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5313 /* Set ADC connection select to match default mixer setting - mic
5314 * (on mic1 pin)
5315 */
5316 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5317
5318 /* Do similar with the second ADC: mute capture input amp and
5319 * set ADC connection to mic to match ALSA's default state.
5320 */
5321 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5322 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5323
5324 /* Mute all inputs to mixer widget (even unconnected ones) */
5325 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5326 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5327 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5328 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5329 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5330 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5331 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5332 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5333
5334 { }
5335};
5336
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005337static struct hda_verb alc260_will_verbs[] = {
5338 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5339 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
5340 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
5341 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5342 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5343 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
5344 {}
5345};
5346
5347static struct hda_verb alc260_replacer_672v_verbs[] = {
5348 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5349 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5350 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
5351
5352 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5353 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5354 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5355
5356 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5357 {}
5358};
5359
5360/* toggle speaker-output according to the hp-jack state */
5361static void alc260_replacer_672v_automute(struct hda_codec *codec)
5362{
5363 unsigned int present;
5364
5365 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
5366 present = snd_hda_codec_read(codec, 0x0f, 0,
5367 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5368 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005369 snd_hda_codec_write_cache(codec, 0x01, 0,
5370 AC_VERB_SET_GPIO_DATA, 1);
5371 snd_hda_codec_write_cache(codec, 0x0f, 0,
5372 AC_VERB_SET_PIN_WIDGET_CONTROL,
5373 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005374 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005375 snd_hda_codec_write_cache(codec, 0x01, 0,
5376 AC_VERB_SET_GPIO_DATA, 0);
5377 snd_hda_codec_write_cache(codec, 0x0f, 0,
5378 AC_VERB_SET_PIN_WIDGET_CONTROL,
5379 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005380 }
5381}
5382
5383static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
5384 unsigned int res)
5385{
5386 if ((res >> 26) == ALC880_HP_EVENT)
5387 alc260_replacer_672v_automute(codec);
5388}
5389
Kailang Yang3f878302008-08-26 13:02:23 +02005390static struct hda_verb alc260_hp_dc7600_verbs[] = {
5391 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
5392 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5393 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5394 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5395 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5396 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5397 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5398 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5399 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5400 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5401 {}
5402};
5403
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005404/* Test configuration for debugging, modelled after the ALC880 test
5405 * configuration.
5406 */
5407#ifdef CONFIG_SND_DEBUG
5408static hda_nid_t alc260_test_dac_nids[1] = {
5409 0x02,
5410};
5411static hda_nid_t alc260_test_adc_nids[2] = {
5412 0x04, 0x05,
5413};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005414/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02005415 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005416 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005417 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005418static struct hda_input_mux alc260_test_capture_sources[2] = {
5419 {
5420 .num_items = 7,
5421 .items = {
5422 { "MIC1 pin", 0x0 },
5423 { "MIC2 pin", 0x1 },
5424 { "LINE1 pin", 0x2 },
5425 { "LINE2 pin", 0x3 },
5426 { "CD pin", 0x4 },
5427 { "LINE-OUT pin", 0x5 },
5428 { "HP-OUT pin", 0x6 },
5429 },
5430 },
5431 {
5432 .num_items = 8,
5433 .items = {
5434 { "MIC1 pin", 0x0 },
5435 { "MIC2 pin", 0x1 },
5436 { "LINE1 pin", 0x2 },
5437 { "LINE2 pin", 0x3 },
5438 { "CD pin", 0x4 },
5439 { "Mixer", 0x5 },
5440 { "LINE-OUT pin", 0x6 },
5441 { "HP-OUT pin", 0x7 },
5442 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005443 },
5444};
5445static struct snd_kcontrol_new alc260_test_mixer[] = {
5446 /* Output driver widgets */
5447 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5448 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5449 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5450 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
5451 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5452 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
5453
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005454 /* Modes for retasking pin widgets
5455 * Note: the ALC260 doesn't seem to act on requests to enable mic
5456 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
5457 * mention this restriction. At this stage it's not clear whether
5458 * this behaviour is intentional or is a hardware bug in chip
5459 * revisions available at least up until early 2006. Therefore for
5460 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
5461 * choices, but if it turns out that the lack of mic bias for these
5462 * NIDs is intentional we could change their modes from
5463 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5464 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005465 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
5466 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
5467 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
5468 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
5469 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
5470 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
5471
5472 /* Loopback mixer controls */
5473 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
5474 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
5475 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
5476 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
5477 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
5478 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
5479 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
5480 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
5481 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5482 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005483 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
5484 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
5485 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
5486 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005487
5488 /* Controls for GPIO pins, assuming they are configured as outputs */
5489 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
5490 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
5491 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
5492 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
5493
Jonathan Woithe92621f12006-02-28 11:47:47 +01005494 /* Switches to allow the digital IO pins to be enabled. The datasheet
5495 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02005496 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01005497 */
5498 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
5499 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
5500
Jonathan Woithef8225f62008-01-08 12:16:54 +01005501 /* A switch allowing EAPD to be enabled. Some laptops seem to use
5502 * this output to turn on an external amplifier.
5503 */
5504 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
5505 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
5506
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005507 { } /* end */
5508};
5509static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005510 /* Enable all GPIOs as outputs with an initial value of 0 */
5511 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
5512 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5513 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
5514
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005515 /* Enable retasking pins as output, initially without power amp */
5516 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5517 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5518 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5519 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5520 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5521 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5522
Jonathan Woithe92621f12006-02-28 11:47:47 +01005523 /* Disable digital (SPDIF) pins initially, but users can enable
5524 * them via a mixer switch. In the case of SPDIF-out, this initverb
5525 * payload also sets the generation to 0, output to be in "consumer"
5526 * PCM format, copyright asserted, no pre-emphasis and no validity
5527 * control.
5528 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005529 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5530 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5531
Kailang Yangea1fb292008-08-26 12:58:38 +02005532 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005533 * OUT1 sum bus when acting as an output.
5534 */
5535 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5536 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
5537 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5538 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
5539
5540 /* Start with output sum widgets muted and their output gains at min */
5541 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5542 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5543 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5544 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5545 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5546 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5547 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5548 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5549 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5550
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005551 /* Unmute retasking pin widget output buffers since the default
5552 * state appears to be output. As the pin mode is changed by the
5553 * user the pin mode control will take care of enabling the pin's
5554 * input/output buffers as needed.
5555 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005556 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5557 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5558 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5559 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5560 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5561 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5562 /* Also unmute the mono-out pin widget */
5563 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5564
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005565 /* Mute capture amp left and right */
5566 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005567 /* Set ADC connection select to match default mixer setting (mic1
5568 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005569 */
5570 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5571
5572 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01005573 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005574 */
5575 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5576 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5577
5578 /* Mute all inputs to mixer widget (even unconnected ones) */
5579 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5580 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5581 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5582 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5583 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5584 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5585 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5586 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5587
5588 { }
5589};
5590#endif
5591
Takashi Iwai63300792008-01-24 15:31:36 +01005592#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
5593#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07005594
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005595#define alc260_pcm_digital_playback alc880_pcm_digital_playback
5596#define alc260_pcm_digital_capture alc880_pcm_digital_capture
5597
Kailang Yangdf694da2005-12-05 19:42:22 +01005598/*
5599 * for BIOS auto-configuration
5600 */
5601
5602static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02005603 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01005604{
5605 hda_nid_t nid_vol;
5606 unsigned long vol_val, sw_val;
5607 char name[32];
5608 int err;
5609
5610 if (nid >= 0x0f && nid < 0x11) {
5611 nid_vol = nid - 0x7;
5612 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5613 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5614 } else if (nid == 0x11) {
5615 nid_vol = nid - 0x7;
5616 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
5617 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
5618 } else if (nid >= 0x12 && nid <= 0x15) {
5619 nid_vol = 0x08;
5620 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5621 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5622 } else
5623 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02005624
Takashi Iwai863b4512008-10-21 17:01:47 +02005625 if (!(*vol_bits & (1 << nid_vol))) {
5626 /* first control for the volume widget */
5627 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
5628 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
5629 if (err < 0)
5630 return err;
5631 *vol_bits |= (1 << nid_vol);
5632 }
Kailang Yangdf694da2005-12-05 19:42:22 +01005633 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005634 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
5635 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005636 return err;
5637 return 1;
5638}
5639
5640/* add playback controls from the parsed DAC table */
5641static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
5642 const struct auto_pin_cfg *cfg)
5643{
5644 hda_nid_t nid;
5645 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02005646 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005647
5648 spec->multiout.num_dacs = 1;
5649 spec->multiout.dac_nids = spec->private_dac_nids;
5650 spec->multiout.dac_nids[0] = 0x02;
5651
5652 nid = cfg->line_out_pins[0];
5653 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005654 err = alc260_add_playback_controls(spec, nid, "Front", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005655 if (err < 0)
5656 return err;
5657 }
5658
Takashi Iwai82bc9552006-03-21 11:24:42 +01005659 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005660 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005661 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005662 if (err < 0)
5663 return err;
5664 }
5665
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005666 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005667 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005668 err = alc260_add_playback_controls(spec, nid, "Headphone",
5669 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005670 if (err < 0)
5671 return err;
5672 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005673 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005674}
5675
5676/* create playback/capture controls for input pins */
5677static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
5678 const struct auto_pin_cfg *cfg)
5679{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005680 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005681 int i, err, idx;
5682
5683 for (i = 0; i < AUTO_PIN_LAST; i++) {
5684 if (cfg->input_pins[i] >= 0x12) {
5685 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005686 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005687 auto_pin_cfg_labels[i], idx,
5688 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005689 if (err < 0)
5690 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005691 imux->items[imux->num_items].label =
5692 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005693 imux->items[imux->num_items].index = idx;
5694 imux->num_items++;
5695 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005696 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01005697 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005698 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005699 auto_pin_cfg_labels[i], idx,
5700 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005701 if (err < 0)
5702 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005703 imux->items[imux->num_items].label =
5704 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005705 imux->items[imux->num_items].index = idx;
5706 imux->num_items++;
5707 }
5708 }
5709 return 0;
5710}
5711
5712static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
5713 hda_nid_t nid, int pin_type,
5714 int sel_idx)
5715{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005716 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01005717 /* need the manual connection? */
5718 if (nid >= 0x12) {
5719 int idx = nid - 0x12;
5720 snd_hda_codec_write(codec, idx + 0x0b, 0,
5721 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01005722 }
5723}
5724
5725static void alc260_auto_init_multi_out(struct hda_codec *codec)
5726{
5727 struct alc_spec *spec = codec->spec;
5728 hda_nid_t nid;
5729
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005730 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005731 if (nid) {
5732 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5733 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
5734 }
Kailang Yangea1fb292008-08-26 12:58:38 +02005735
Takashi Iwai82bc9552006-03-21 11:24:42 +01005736 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005737 if (nid)
5738 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
5739
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005740 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005741 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005742 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005743}
Kailang Yangdf694da2005-12-05 19:42:22 +01005744
5745#define ALC260_PIN_CD_NID 0x16
5746static void alc260_auto_init_analog_input(struct hda_codec *codec)
5747{
5748 struct alc_spec *spec = codec->spec;
5749 int i;
5750
5751 for (i = 0; i < AUTO_PIN_LAST; i++) {
5752 hda_nid_t nid = spec->autocfg.input_pins[i];
5753 if (nid >= 0x12) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01005754 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01005755 if (nid != ALC260_PIN_CD_NID &&
5756 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005757 snd_hda_codec_write(codec, nid, 0,
5758 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01005759 AMP_OUT_MUTE);
5760 }
5761 }
5762}
5763
5764/*
5765 * generic initialization of ADC, input mixers and output mixers
5766 */
5767static struct hda_verb alc260_volume_init_verbs[] = {
5768 /*
5769 * Unmute ADC0-1 and set the default input to mic-in
5770 */
5771 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5772 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5773 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5774 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005775
Kailang Yangdf694da2005-12-05 19:42:22 +01005776 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5777 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005778 * Note: PASD motherboards uses the Line In 2 as the input for
5779 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01005780 */
5781 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005782 /* mute analog inputs */
5783 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5784 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5785 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5786 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5787 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005788
5789 /*
5790 * Set up output mixers (0x08 - 0x0a)
5791 */
5792 /* set vol=0 to output mixers */
5793 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5794 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5795 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5796 /* set up input amps for analog loopback */
5797 /* Amp Indices: DAC = 0, mixer = 1 */
5798 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5799 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5800 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5801 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5802 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5803 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005804
Kailang Yangdf694da2005-12-05 19:42:22 +01005805 { }
5806};
5807
5808static int alc260_parse_auto_config(struct hda_codec *codec)
5809{
5810 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005811 int err;
5812 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
5813
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005814 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5815 alc260_ignore);
5816 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005817 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005818 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
5819 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01005820 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02005821 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01005822 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005823 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
5824 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005825 return err;
5826
5827 spec->multiout.max_channels = 2;
5828
Takashi Iwai0852d7a2009-02-11 11:35:15 +01005829 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01005830 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02005831 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01005832 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01005833
Takashi Iwaid88897e2008-10-31 15:01:37 +01005834 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01005835
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005836 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005837 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005838
Takashi Iwai4a79ba32009-04-22 16:31:35 +02005839 alc_ssid_check(codec, 0x10, 0x15, 0x0f);
5840
Kailang Yangdf694da2005-12-05 19:42:22 +01005841 return 1;
5842}
5843
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005844/* additional initialization for auto-configuration model */
5845static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01005846{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005847 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005848 alc260_auto_init_multi_out(codec);
5849 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005850 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02005851 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005852}
5853
Takashi Iwaicb53c622007-08-10 17:21:45 +02005854#ifdef CONFIG_SND_HDA_POWER_SAVE
5855static struct hda_amp_list alc260_loopbacks[] = {
5856 { 0x07, HDA_INPUT, 0 },
5857 { 0x07, HDA_INPUT, 1 },
5858 { 0x07, HDA_INPUT, 2 },
5859 { 0x07, HDA_INPUT, 3 },
5860 { 0x07, HDA_INPUT, 4 },
5861 { } /* end */
5862};
5863#endif
5864
Kailang Yangdf694da2005-12-05 19:42:22 +01005865/*
5866 * ALC260 configurations
5867 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005868static const char *alc260_models[ALC260_MODEL_LAST] = {
5869 [ALC260_BASIC] = "basic",
5870 [ALC260_HP] = "hp",
5871 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02005872 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005873 [ALC260_FUJITSU_S702X] = "fujitsu",
5874 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005875 [ALC260_WILL] = "will",
5876 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01005877 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005878#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005879 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005880#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005881 [ALC260_AUTO] = "auto",
5882};
5883
5884static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01005885 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005886 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01005887 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01005888 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01005889 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005890 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02005891 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02005892 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005893 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
5894 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
5895 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
5896 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
5897 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
5898 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
5899 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
5900 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
5901 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005902 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01005903 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02005904 {}
5905};
5906
Kailang Yangdf694da2005-12-05 19:42:22 +01005907static struct alc_config_preset alc260_presets[] = {
5908 [ALC260_BASIC] = {
5909 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005910 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01005911 .init_verbs = { alc260_init_verbs },
5912 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5913 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005914 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Kailang Yangdf694da2005-12-05 19:42:22 +01005915 .adc_nids = alc260_adc_nids,
5916 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5917 .channel_mode = alc260_modes,
5918 .input_mux = &alc260_capture_source,
5919 },
5920 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005921 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005922 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005923 .init_verbs = { alc260_init_verbs,
5924 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005925 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5926 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005927 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5928 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01005929 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5930 .channel_mode = alc260_modes,
5931 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005932 .unsol_event = alc260_hp_unsol_event,
5933 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005934 },
Kailang Yang3f878302008-08-26 13:02:23 +02005935 [ALC260_HP_DC7600] = {
5936 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005937 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02005938 .init_verbs = { alc260_init_verbs,
5939 alc260_hp_dc7600_verbs },
5940 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5941 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005942 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5943 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02005944 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5945 .channel_mode = alc260_modes,
5946 .input_mux = &alc260_capture_source,
5947 .unsol_event = alc260_hp_3012_unsol_event,
5948 .init_hook = alc260_hp_3012_automute,
5949 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005950 [ALC260_HP_3013] = {
5951 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005952 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005953 .init_verbs = { alc260_hp_3013_init_verbs,
5954 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005955 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5956 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005957 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5958 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01005959 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5960 .channel_mode = alc260_modes,
5961 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005962 .unsol_event = alc260_hp_3013_unsol_event,
5963 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005964 },
5965 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005966 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01005967 .init_verbs = { alc260_fujitsu_init_verbs },
5968 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5969 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005970 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5971 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01005972 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5973 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005974 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
5975 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01005976 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005977 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005978 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005979 .init_verbs = { alc260_acer_init_verbs },
5980 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5981 .dac_nids = alc260_dac_nids,
5982 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5983 .adc_nids = alc260_dual_adc_nids,
5984 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5985 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005986 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
5987 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005988 },
Michael Schwingencc959482009-02-22 18:58:45 +01005989 [ALC260_FAVORIT100] = {
5990 .mixers = { alc260_favorit100_mixer },
5991 .init_verbs = { alc260_favorit100_init_verbs },
5992 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5993 .dac_nids = alc260_dac_nids,
5994 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5995 .adc_nids = alc260_dual_adc_nids,
5996 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5997 .channel_mode = alc260_modes,
5998 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
5999 .input_mux = alc260_favorit100_capture_sources,
6000 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006001 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006002 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006003 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
6004 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6005 .dac_nids = alc260_dac_nids,
6006 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6007 .adc_nids = alc260_adc_nids,
6008 .dig_out_nid = ALC260_DIGOUT_NID,
6009 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6010 .channel_mode = alc260_modes,
6011 .input_mux = &alc260_capture_source,
6012 },
6013 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006014 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006015 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
6016 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6017 .dac_nids = alc260_dac_nids,
6018 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6019 .adc_nids = alc260_adc_nids,
6020 .dig_out_nid = ALC260_DIGOUT_NID,
6021 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6022 .channel_mode = alc260_modes,
6023 .input_mux = &alc260_capture_source,
6024 .unsol_event = alc260_replacer_672v_unsol_event,
6025 .init_hook = alc260_replacer_672v_automute,
6026 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006027#ifdef CONFIG_SND_DEBUG
6028 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006029 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006030 .init_verbs = { alc260_test_init_verbs },
6031 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
6032 .dac_nids = alc260_test_dac_nids,
6033 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
6034 .adc_nids = alc260_test_adc_nids,
6035 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6036 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006037 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
6038 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006039 },
6040#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006041};
6042
Linus Torvalds1da177e2005-04-16 15:20:36 -07006043static int patch_alc260(struct hda_codec *codec)
6044{
6045 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006046 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006047
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006048 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006049 if (spec == NULL)
6050 return -ENOMEM;
6051
6052 codec->spec = spec;
6053
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006054 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
6055 alc260_models,
6056 alc260_cfg_tbl);
6057 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +02006058 snd_printd(KERN_INFO "hda_codec: Unknown model for %s, "
6059 "trying auto-probe from BIOS...\n",
6060 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01006061 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02006062 }
6063
Kailang Yangdf694da2005-12-05 19:42:22 +01006064 if (board_config == ALC260_AUTO) {
6065 /* automatic parse from the BIOS config */
6066 err = alc260_parse_auto_config(codec);
6067 if (err < 0) {
6068 alc_free(codec);
6069 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006070 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006071 printk(KERN_INFO
6072 "hda_codec: Cannot set up configuration "
6073 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006074 board_config = ALC260_BASIC;
6075 }
Takashi Iwai16ded522005-06-10 19:58:24 +02006076 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006077
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09006078 err = snd_hda_attach_beep_device(codec, 0x1);
6079 if (err < 0) {
6080 alc_free(codec);
6081 return err;
6082 }
6083
Kailang Yangdf694da2005-12-05 19:42:22 +01006084 if (board_config != ALC260_AUTO)
6085 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006086
Linus Torvalds1da177e2005-04-16 15:20:36 -07006087 spec->stream_analog_playback = &alc260_pcm_analog_playback;
6088 spec->stream_analog_capture = &alc260_pcm_analog_capture;
6089
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006090 spec->stream_digital_playback = &alc260_pcm_digital_playback;
6091 spec->stream_digital_capture = &alc260_pcm_digital_capture;
6092
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006093 if (!spec->adc_nids && spec->input_mux) {
6094 /* check whether NID 0x04 is valid */
6095 unsigned int wcap = get_wcaps(codec, 0x04);
6096 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
6097 /* get type */
6098 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
6099 spec->adc_nids = alc260_adc_nids_alt;
6100 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
6101 } else {
6102 spec->adc_nids = alc260_adc_nids;
6103 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
6104 }
6105 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006106 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006107 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006108
Takashi Iwai2134ea42008-01-10 16:53:55 +01006109 spec->vmaster_nid = 0x08;
6110
Linus Torvalds1da177e2005-04-16 15:20:36 -07006111 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006112 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006113 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006114#ifdef CONFIG_SND_HDA_POWER_SAVE
6115 if (!spec->loopback.amplist)
6116 spec->loopback.amplist = alc260_loopbacks;
6117#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01006118 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006119
6120 return 0;
6121}
6122
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006123
Linus Torvalds1da177e2005-04-16 15:20:36 -07006124/*
6125 * ALC882 support
6126 *
6127 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
6128 * configuration. Each pin widget can choose any input DACs and a mixer.
6129 * Each ADC is connected from a mixer of all inputs. This makes possible
6130 * 6-channel independent captures.
6131 *
6132 * In addition, an independent DAC for the multi-playback (not used in this
6133 * driver yet).
6134 */
Kailang Yangdf694da2005-12-05 19:42:22 +01006135#define ALC882_DIGOUT_NID 0x06
6136#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07006137
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01006138static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07006139 { 8, NULL }
6140};
6141
6142static hda_nid_t alc882_dac_nids[4] = {
6143 /* front, rear, clfe, rear_surr */
6144 0x02, 0x03, 0x04, 0x05
6145};
6146
Kailang Yangdf694da2005-12-05 19:42:22 +01006147/* identical with ALC880 */
6148#define alc882_adc_nids alc880_adc_nids
6149#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07006150
Takashi Iwaie1406342008-02-11 18:32:32 +01006151static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
6152static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
6153
Linus Torvalds1da177e2005-04-16 15:20:36 -07006154/* input MUX */
6155/* FIXME: should be a matrix-type input source selection */
6156
6157static struct hda_input_mux alc882_capture_source = {
6158 .num_items = 4,
6159 .items = {
6160 { "Mic", 0x0 },
6161 { "Front Mic", 0x1 },
6162 { "Line", 0x2 },
6163 { "CD", 0x4 },
6164 },
6165};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006166
6167static struct hda_input_mux mb5_capture_source = {
6168 .num_items = 3,
6169 .items = {
6170 { "Mic", 0x1 },
6171 { "Line", 0x2 },
6172 { "CD", 0x4 },
6173 },
6174};
6175
Kailang Yangdf694da2005-12-05 19:42:22 +01006176/*
Kailang Yang272a5272007-05-14 11:00:38 +02006177 * 2ch mode
6178 */
6179static struct hda_verb alc882_3ST_ch2_init[] = {
6180 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6181 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6182 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6183 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6184 { } /* end */
6185};
6186
6187/*
6188 * 6ch mode
6189 */
6190static struct hda_verb alc882_3ST_ch6_init[] = {
6191 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6192 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6193 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6194 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6195 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6196 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6197 { } /* end */
6198};
6199
6200static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
6201 { 2, alc882_3ST_ch2_init },
6202 { 6, alc882_3ST_ch6_init },
6203};
6204
6205/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006206 * 6ch mode
6207 */
6208static struct hda_verb alc882_sixstack_ch6_init[] = {
6209 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6210 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6211 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6212 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6213 { } /* end */
6214};
6215
6216/*
6217 * 8ch mode
6218 */
6219static struct hda_verb alc882_sixstack_ch8_init[] = {
6220 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6221 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6222 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6223 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6224 { } /* end */
6225};
6226
6227static struct hda_channel_mode alc882_sixstack_modes[2] = {
6228 { 6, alc882_sixstack_ch6_init },
6229 { 8, alc882_sixstack_ch8_init },
6230};
6231
Takashi Iwai87350ad2007-08-16 18:19:38 +02006232/*
6233 * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
6234 */
6235
6236/*
6237 * 2ch mode
6238 */
6239static struct hda_verb alc885_mbp_ch2_init[] = {
6240 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6241 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6242 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6243 { } /* end */
6244};
6245
6246/*
6247 * 6ch mode
6248 */
6249static struct hda_verb alc885_mbp_ch6_init[] = {
6250 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6251 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6252 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6253 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6254 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6255 { } /* end */
6256};
6257
6258static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
6259 { 2, alc885_mbp_ch2_init },
6260 { 6, alc885_mbp_ch6_init },
6261};
6262
6263
Linus Torvalds1da177e2005-04-16 15:20:36 -07006264/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6265 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6266 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01006267static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02006268 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006269 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006270 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006271 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006272 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6273 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006274 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6275 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006276 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006277 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006278 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6279 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6280 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6281 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6282 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6283 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006284 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006285 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6286 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006287 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006288 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006289 { } /* end */
6290};
6291
Takashi Iwai87350ad2007-08-16 18:19:38 +02006292static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01006293 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6294 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
6295 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
6296 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
6297 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6298 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006299 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
6300 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01006301 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006302 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
6303 { } /* end */
6304};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006305
6306static struct snd_kcontrol_new alc885_mb5_mixer[] = {
6307 HDA_CODEC_VOLUME("Front Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
6308 HDA_BIND_MUTE ("Front Playback Switch", 0x0d, 0x02, HDA_INPUT),
6309 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6310 HDA_BIND_MUTE ("Line-Out Playback Switch", 0x0c, 0x02, HDA_INPUT),
6311 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6312 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6313 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
6314 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
6315 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
6316 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0x00, HDA_INPUT),
6317 { } /* end */
6318};
Kailang Yangbdd148a2007-05-08 15:19:08 +02006319static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
6320 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6321 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6322 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6323 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6324 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6325 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6326 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6327 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6328 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02006329 { } /* end */
6330};
6331
Kailang Yang272a5272007-05-14 11:00:38 +02006332static struct snd_kcontrol_new alc882_targa_mixer[] = {
6333 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6334 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6335 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6336 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6337 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6338 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6339 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6340 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6341 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006342 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006343 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6344 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006345 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006346 { } /* end */
6347};
6348
6349/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
6350 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
6351 */
6352static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
6353 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6354 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6355 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6356 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
6357 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6358 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6359 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6360 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6361 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
6362 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
6363 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6364 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006365 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006366 { } /* end */
6367};
6368
Takashi Iwai914759b2007-09-06 14:52:04 +02006369static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
6370 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6371 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6372 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6373 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6374 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6375 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6376 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6377 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6378 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6379 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02006380 { } /* end */
6381};
6382
Kailang Yangdf694da2005-12-05 19:42:22 +01006383static struct snd_kcontrol_new alc882_chmode_mixer[] = {
6384 {
6385 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6386 .name = "Channel Mode",
6387 .info = alc_ch_mode_info,
6388 .get = alc_ch_mode_get,
6389 .put = alc_ch_mode_put,
6390 },
6391 { } /* end */
6392};
6393
Linus Torvalds1da177e2005-04-16 15:20:36 -07006394static struct hda_verb alc882_init_verbs[] = {
6395 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006396 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6397 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6398 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006399 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006400 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6401 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6402 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006403 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006404 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6405 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6406 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006407 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006408 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6409 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6410 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006411
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006412 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006413 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006414 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006415 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006416 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006417 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006418 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006419 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006420 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006421 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006422 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006423 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006424 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006425 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006426 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006427 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006428 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006429 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006430 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6431 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006432 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006433 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6434 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006435 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006436 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6437 /* Line-2 In: Headphone output (output 0 - 0x0c) */
6438 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6439 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6440 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006441 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006442 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006443
6444 /* FIXME: use matrix-type input source selection */
6445 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6446 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02006447 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6448 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6449 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6450 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006451 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006452 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6453 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6454 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6455 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006456 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006457 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6458 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6459 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6460 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6461 /* ADC1: mute amp left and right */
6462 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006463 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02006464 /* ADC2: mute amp left and right */
6465 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006466 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02006467 /* ADC3: mute amp left and right */
6468 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006469 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006470
6471 { }
6472};
6473
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006474static struct hda_verb alc882_eapd_verbs[] = {
6475 /* change to EAPD mode */
6476 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006477 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006478 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006479};
6480
Tobin Davis9102cd12006-12-15 10:02:12 +01006481/* Mac Pro test */
6482static struct snd_kcontrol_new alc882_macpro_mixer[] = {
6483 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6484 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6485 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
6486 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
6487 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006488 /* FIXME: this looks suspicious...
Tobin Davis9102cd12006-12-15 10:02:12 +01006489 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
6490 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006491 */
Tobin Davis9102cd12006-12-15 10:02:12 +01006492 { } /* end */
6493};
6494
6495static struct hda_verb alc882_macpro_init_verbs[] = {
6496 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6497 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6498 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6499 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6500 /* Front Pin: output 0 (0x0c) */
6501 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6502 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6503 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6504 /* Front Mic pin: input vref at 80% */
6505 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6506 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6507 /* Speaker: output */
6508 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6509 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6510 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
6511 /* Headphone output (output 0 - 0x0c) */
6512 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6513 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6514 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6515
6516 /* FIXME: use matrix-type input source selection */
6517 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6518 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6519 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6520 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6521 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6522 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6523 /* Input mixer2 */
6524 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6525 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6526 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6527 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6528 /* Input mixer3 */
6529 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6530 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6531 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6532 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6533 /* ADC1: mute amp left and right */
6534 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6535 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6536 /* ADC2: mute amp left and right */
6537 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6538 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6539 /* ADC3: mute amp left and right */
6540 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6541 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6542
6543 { }
6544};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006545
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006546/* Macbook 5,1 */
6547static struct hda_verb alc885_mb5_init_verbs[] = {
6548 /* Front mixer */
6549 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6550 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6551 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6552 /* LineOut mixer */
6553 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6554 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6555 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6556 /* Front Pin: output 0 (0x0d) */
6557 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
6558 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6559 {0x18, AC_VERB_SET_CONNECT_SEL, 0x01},
6560 /* HP Pin: output 0 (0x0c) */
6561 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6562 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6563 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6564 /* Front Mic pin: input vref at 80% */
6565 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6566 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6567 /* Line In pin */
6568 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6569 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6570
6571 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6572 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6573 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6574 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6575 { }
6576};
6577
Takashi Iwai87350ad2007-08-16 18:19:38 +02006578/* Macbook Pro rev3 */
6579static struct hda_verb alc885_mbp3_init_verbs[] = {
6580 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6581 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6582 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6583 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6584 /* Rear mixer */
6585 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6586 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6587 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6588 /* Front Pin: output 0 (0x0c) */
6589 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6590 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6591 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6592 /* HP Pin: output 0 (0x0d) */
6593 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
6594 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6595 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6596 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6597 /* Mic (rear) pin: input vref at 80% */
6598 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6599 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6600 /* Front Mic pin: input vref at 80% */
6601 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6602 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6603 /* Line In pin: use output 1 when in LineOut mode */
6604 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6605 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6606 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
6607
6608 /* FIXME: use matrix-type input source selection */
6609 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6610 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6611 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6612 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6613 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6614 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6615 /* Input mixer2 */
6616 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6617 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6618 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6619 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6620 /* Input mixer3 */
6621 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6622 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6623 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6624 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6625 /* ADC1: mute amp left and right */
6626 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6627 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6628 /* ADC2: mute amp left and right */
6629 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6630 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6631 /* ADC3: mute amp left and right */
6632 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6633 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6634
6635 { }
6636};
6637
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006638/* iMac 24 mixer. */
6639static struct snd_kcontrol_new alc885_imac24_mixer[] = {
6640 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6641 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
6642 { } /* end */
6643};
6644
6645/* iMac 24 init verbs. */
6646static struct hda_verb alc885_imac24_init_verbs[] = {
6647 /* Internal speakers: output 0 (0x0c) */
6648 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6649 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6650 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6651 /* Internal speakers: output 0 (0x0c) */
6652 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6653 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6654 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
6655 /* Headphone: output 0 (0x0c) */
6656 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6657 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6658 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6659 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6660 /* Front Mic: input vref at 80% */
6661 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6662 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6663 { }
6664};
6665
6666/* Toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006667static void alc885_imac24_automute_init_hook(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006668{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006669 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006670
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006671 spec->autocfg.hp_pins[0] = 0x14;
6672 spec->autocfg.speaker_pins[0] = 0x18;
6673 spec->autocfg.speaker_pins[1] = 0x1a;
6674 alc_automute_amp(codec);
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006675}
6676
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006677static void alc885_mbp3_init_hook(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006678{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006679 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006680
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006681 spec->autocfg.hp_pins[0] = 0x15;
6682 spec->autocfg.speaker_pins[0] = 0x14;
6683 alc_automute_amp(codec);
Takashi Iwai87350ad2007-08-16 18:19:38 +02006684}
6685
6686
Kailang Yang272a5272007-05-14 11:00:38 +02006687static struct hda_verb alc882_targa_verbs[] = {
6688 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6689 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6690
6691 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6692 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006693
Kailang Yang272a5272007-05-14 11:00:38 +02006694 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6695 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6696 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6697
6698 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6699 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
6700 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
6701 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
6702 { } /* end */
6703};
6704
6705/* toggle speaker-output according to the hp-jack state */
6706static void alc882_targa_automute(struct hda_codec *codec)
6707{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006708 struct alc_spec *spec = codec->spec;
6709 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006710 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006711 spec->jack_present ? 1 : 3);
6712}
6713
6714static void alc882_targa_init_hook(struct hda_codec *codec)
6715{
6716 struct alc_spec *spec = codec->spec;
6717
6718 spec->autocfg.hp_pins[0] = 0x14;
6719 spec->autocfg.speaker_pins[0] = 0x1b;
6720 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02006721}
6722
6723static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
6724{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006725 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02006726 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02006727}
6728
6729static struct hda_verb alc882_asus_a7j_verbs[] = {
6730 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6731 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6732
6733 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6734 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6735 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006736
Kailang Yang272a5272007-05-14 11:00:38 +02006737 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6738 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6739 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6740
6741 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6742 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6743 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6744 { } /* end */
6745};
6746
Takashi Iwai914759b2007-09-06 14:52:04 +02006747static struct hda_verb alc882_asus_a7m_verbs[] = {
6748 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6749 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6750
6751 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6752 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6753 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006754
Takashi Iwai914759b2007-09-06 14:52:04 +02006755 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6756 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6757 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6758
6759 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6760 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6761 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6762 { } /* end */
6763};
6764
Tobin Davis9102cd12006-12-15 10:02:12 +01006765static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
6766{
6767 unsigned int gpiostate, gpiomask, gpiodir;
6768
6769 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
6770 AC_VERB_GET_GPIO_DATA, 0);
6771
6772 if (!muted)
6773 gpiostate |= (1 << pin);
6774 else
6775 gpiostate &= ~(1 << pin);
6776
6777 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
6778 AC_VERB_GET_GPIO_MASK, 0);
6779 gpiomask |= (1 << pin);
6780
6781 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
6782 AC_VERB_GET_GPIO_DIRECTION, 0);
6783 gpiodir |= (1 << pin);
6784
6785
6786 snd_hda_codec_write(codec, codec->afg, 0,
6787 AC_VERB_SET_GPIO_MASK, gpiomask);
6788 snd_hda_codec_write(codec, codec->afg, 0,
6789 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
6790
6791 msleep(1);
6792
6793 snd_hda_codec_write(codec, codec->afg, 0,
6794 AC_VERB_SET_GPIO_DATA, gpiostate);
6795}
6796
Takashi Iwai7debbe52007-08-16 15:01:03 +02006797/* set up GPIO at initialization */
6798static void alc885_macpro_init_hook(struct hda_codec *codec)
6799{
6800 alc882_gpio_mute(codec, 0, 0);
6801 alc882_gpio_mute(codec, 1, 0);
6802}
6803
6804/* set up GPIO and update auto-muting at initialization */
6805static void alc885_imac24_init_hook(struct hda_codec *codec)
6806{
6807 alc885_macpro_init_hook(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006808 alc885_imac24_automute_init_hook(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02006809}
6810
Kailang Yangdf694da2005-12-05 19:42:22 +01006811/*
6812 * generic initialization of ADC, input mixers and output mixers
6813 */
6814static struct hda_verb alc882_auto_init_verbs[] = {
6815 /*
6816 * Unmute ADC0-2 and set the default input to mic-in
6817 */
6818 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6819 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6820 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6821 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6822 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6823 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6824
Takashi Iwaicb53c622007-08-10 17:21:45 +02006825 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01006826 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006827 * Note: PASD motherboards uses the Line In 2 as the input for
6828 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006829 */
6830 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006831 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6832 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6833 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6834 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6835 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006836
6837 /*
6838 * Set up output mixers (0x0c - 0x0f)
6839 */
6840 /* set vol=0 to output mixers */
6841 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6842 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6843 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6844 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6845 /* set up input amps for analog loopback */
6846 /* Amp Indices: DAC = 0, mixer = 1 */
6847 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6848 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6849 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6850 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6851 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6852 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6853 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6854 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6855 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6856 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6857
6858 /* FIXME: use matrix-type input source selection */
6859 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6860 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6861 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6862 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6863 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6864 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6865 /* Input mixer2 */
6866 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6867 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6868 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6869 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6870 /* Input mixer3 */
6871 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6872 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6873 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6874 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6875
6876 { }
6877};
6878
Takashi Iwaicb53c622007-08-10 17:21:45 +02006879#ifdef CONFIG_SND_HDA_POWER_SAVE
6880#define alc882_loopbacks alc880_loopbacks
6881#endif
6882
Kailang Yangdf694da2005-12-05 19:42:22 +01006883/* pcm configuration: identiacal with ALC880 */
6884#define alc882_pcm_analog_playback alc880_pcm_analog_playback
6885#define alc882_pcm_analog_capture alc880_pcm_analog_capture
6886#define alc882_pcm_digital_playback alc880_pcm_digital_playback
6887#define alc882_pcm_digital_capture alc880_pcm_digital_capture
6888
6889/*
6890 * configuration and preset
6891 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006892static const char *alc882_models[ALC882_MODEL_LAST] = {
6893 [ALC882_3ST_DIG] = "3stack-dig",
6894 [ALC882_6ST_DIG] = "6stack-dig",
6895 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02006896 [ALC882_W2JC] = "w2jc",
Takashi Iwai0438a002007-09-06 14:54:11 +02006897 [ALC882_TARGA] = "targa",
6898 [ALC882_ASUS_A7J] = "asus-a7j",
6899 [ALC882_ASUS_A7M] = "asus-a7m",
Tobin Davis9102cd12006-12-15 10:02:12 +01006900 [ALC885_MACPRO] = "macpro",
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006901 [ALC885_MB5] = "mb5",
Takashi Iwai87350ad2007-08-16 18:19:38 +02006902 [ALC885_MBP3] = "mbp3",
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006903 [ALC885_IMAC24] = "imac24",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006904 [ALC882_AUTO] = "auto",
6905};
6906
6907static struct snd_pci_quirk alc882_cfg_tbl[] = {
6908 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02006909 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Kailang Yangac8842a2007-09-20 12:51:39 +02006910 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
Takashi Iwai914759b2007-09-06 14:52:04 +02006911 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006912 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Claudio Matsuokac5d9f1c2007-07-19 23:18:32 +02006913 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
Tobin Davis7b9470d2006-12-28 13:56:48 +01006914 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006915 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Jiang zhe44447042008-01-28 12:28:24 +01006916 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006917 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
6918 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
6919 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yangdf694da2005-12-05 19:42:22 +01006920 {}
6921};
6922
6923static struct alc_config_preset alc882_presets[] = {
6924 [ALC882_3ST_DIG] = {
6925 .mixers = { alc882_base_mixer },
6926 .init_verbs = { alc882_init_verbs },
6927 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6928 .dac_nids = alc882_dac_nids,
6929 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006930 .dig_in_nid = ALC882_DIGIN_NID,
6931 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6932 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006933 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01006934 .input_mux = &alc882_capture_source,
6935 },
6936 [ALC882_6ST_DIG] = {
6937 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6938 .init_verbs = { alc882_init_verbs },
6939 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6940 .dac_nids = alc882_dac_nids,
6941 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006942 .dig_in_nid = ALC882_DIGIN_NID,
6943 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6944 .channel_mode = alc882_sixstack_modes,
6945 .input_mux = &alc882_capture_source,
6946 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006947 [ALC882_ARIMA] = {
6948 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6949 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
6950 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6951 .dac_nids = alc882_dac_nids,
6952 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6953 .channel_mode = alc882_sixstack_modes,
6954 .input_mux = &alc882_capture_source,
6955 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02006956 [ALC882_W2JC] = {
6957 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
6958 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6959 alc880_gpio1_init_verbs },
6960 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6961 .dac_nids = alc882_dac_nids,
6962 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6963 .channel_mode = alc880_threestack_modes,
6964 .need_dac_fix = 1,
6965 .input_mux = &alc882_capture_source,
6966 .dig_out_nid = ALC882_DIGOUT_NID,
6967 },
Takashi Iwai87350ad2007-08-16 18:19:38 +02006968 [ALC885_MBP3] = {
6969 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
6970 .init_verbs = { alc885_mbp3_init_verbs,
6971 alc880_gpio1_init_verbs },
6972 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6973 .dac_nids = alc882_dac_nids,
6974 .channel_mode = alc885_mbp_6ch_modes,
6975 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
6976 .input_mux = &alc882_capture_source,
6977 .dig_out_nid = ALC882_DIGOUT_NID,
6978 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006979 .unsol_event = alc_automute_amp_unsol_event,
6980 .init_hook = alc885_mbp3_init_hook,
Takashi Iwai87350ad2007-08-16 18:19:38 +02006981 },
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006982 [ALC885_MB5] = {
6983 .mixers = { alc885_mb5_mixer },
6984 .init_verbs = { alc885_mb5_init_verbs,
6985 alc880_gpio1_init_verbs },
6986 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6987 .dac_nids = alc882_dac_nids,
6988 .channel_mode = alc885_mbp_6ch_modes,
6989 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
6990 .input_mux = &mb5_capture_source,
6991 .dig_out_nid = ALC882_DIGOUT_NID,
6992 .dig_in_nid = ALC882_DIGIN_NID,
6993 },
Tobin Davis9102cd12006-12-15 10:02:12 +01006994 [ALC885_MACPRO] = {
6995 .mixers = { alc882_macpro_mixer },
6996 .init_verbs = { alc882_macpro_init_verbs },
6997 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6998 .dac_nids = alc882_dac_nids,
6999 .dig_out_nid = ALC882_DIGOUT_NID,
7000 .dig_in_nid = ALC882_DIGIN_NID,
7001 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
7002 .channel_mode = alc882_ch_modes,
7003 .input_mux = &alc882_capture_source,
Takashi Iwai7debbe52007-08-16 15:01:03 +02007004 .init_hook = alc885_macpro_init_hook,
Tobin Davis9102cd12006-12-15 10:02:12 +01007005 },
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007006 [ALC885_IMAC24] = {
7007 .mixers = { alc885_imac24_mixer },
7008 .init_verbs = { alc885_imac24_init_verbs },
7009 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7010 .dac_nids = alc882_dac_nids,
7011 .dig_out_nid = ALC882_DIGOUT_NID,
7012 .dig_in_nid = ALC882_DIGIN_NID,
7013 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
7014 .channel_mode = alc882_ch_modes,
7015 .input_mux = &alc882_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007016 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai7debbe52007-08-16 15:01:03 +02007017 .init_hook = alc885_imac24_init_hook,
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007018 },
Kailang Yang272a5272007-05-14 11:00:38 +02007019 [ALC882_TARGA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007020 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Kailang Yang272a5272007-05-14 11:00:38 +02007021 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
7022 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7023 .dac_nids = alc882_dac_nids,
7024 .dig_out_nid = ALC882_DIGOUT_NID,
7025 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
7026 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01007027 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02007028 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
7029 .channel_mode = alc882_3ST_6ch_modes,
7030 .need_dac_fix = 1,
7031 .input_mux = &alc882_capture_source,
7032 .unsol_event = alc882_targa_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007033 .init_hook = alc882_targa_init_hook,
Kailang Yang272a5272007-05-14 11:00:38 +02007034 },
7035 [ALC882_ASUS_A7J] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007036 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Kailang Yang272a5272007-05-14 11:00:38 +02007037 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
7038 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7039 .dac_nids = alc882_dac_nids,
7040 .dig_out_nid = ALC882_DIGOUT_NID,
7041 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
7042 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01007043 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02007044 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
7045 .channel_mode = alc882_3ST_6ch_modes,
7046 .need_dac_fix = 1,
7047 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02007048 },
Takashi Iwai914759b2007-09-06 14:52:04 +02007049 [ALC882_ASUS_A7M] = {
7050 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
7051 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
7052 alc880_gpio1_init_verbs,
7053 alc882_asus_a7m_verbs },
7054 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7055 .dac_nids = alc882_dac_nids,
7056 .dig_out_nid = ALC882_DIGOUT_NID,
7057 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
7058 .channel_mode = alc880_threestack_modes,
7059 .need_dac_fix = 1,
7060 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02007061 },
Kailang Yangdf694da2005-12-05 19:42:22 +01007062};
7063
7064
7065/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02007066 * Pin config fixes
7067 */
Kailang Yangea1fb292008-08-26 12:58:38 +02007068enum {
Takashi Iwaif95474e2007-07-10 00:47:43 +02007069 PINFIX_ABIT_AW9D_MAX
7070};
7071
7072static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
7073 { 0x15, 0x01080104 }, /* side */
7074 { 0x16, 0x01011012 }, /* rear */
7075 { 0x17, 0x01016011 }, /* clfe */
7076 { }
7077};
7078
7079static const struct alc_pincfg *alc882_pin_fixes[] = {
7080 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
7081};
7082
7083static struct snd_pci_quirk alc882_pinfix_tbl[] = {
7084 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
7085 {}
7086};
7087
7088/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007089 * BIOS auto configuration
7090 */
7091static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
7092 hda_nid_t nid, int pin_type,
7093 int dac_idx)
7094{
7095 /* set as output */
7096 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007097 int idx;
7098
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007099 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01007100 if (spec->multiout.dac_nids[dac_idx] == 0x25)
7101 idx = 4;
7102 else
7103 idx = spec->multiout.dac_nids[dac_idx] - 2;
Kailang Yangdf694da2005-12-05 19:42:22 +01007104 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
7105
7106}
7107
7108static void alc882_auto_init_multi_out(struct hda_codec *codec)
7109{
7110 struct alc_spec *spec = codec->spec;
7111 int i;
7112
7113 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007114 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007115 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01007116 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007117 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007118 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01007119 }
7120}
7121
7122static void alc882_auto_init_hp_out(struct hda_codec *codec)
7123{
7124 struct alc_spec *spec = codec->spec;
7125 hda_nid_t pin;
7126
Takashi Iwaieb06ed82006-09-20 17:10:27 +02007127 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007128 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007129 /* use dac 0 */
7130 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007131 pin = spec->autocfg.speaker_pins[0];
7132 if (pin)
7133 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01007134}
7135
7136#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
7137#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
7138
7139static void alc882_auto_init_analog_input(struct hda_codec *codec)
7140{
7141 struct alc_spec *spec = codec->spec;
7142 int i;
7143
7144 for (i = 0; i < AUTO_PIN_LAST; i++) {
7145 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai7194cae2008-03-06 16:58:17 +01007146 if (!nid)
7147 continue;
Takashi Iwai23f0c042009-02-26 13:03:58 +01007148 alc_set_input_pin(codec, nid, AUTO_PIN_FRONT_MIC /*i*/);
Takashi Iwai7194cae2008-03-06 16:58:17 +01007149 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
7150 snd_hda_codec_write(codec, nid, 0,
7151 AC_VERB_SET_AMP_GAIN_MUTE,
7152 AMP_OUT_MUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01007153 }
7154}
7155
Takashi Iwaif511b012008-08-15 16:46:42 +02007156static void alc882_auto_init_input_src(struct hda_codec *codec)
7157{
7158 struct alc_spec *spec = codec->spec;
Takashi Iwaif511b012008-08-15 16:46:42 +02007159 int c;
7160
7161 for (c = 0; c < spec->num_adc_nids; c++) {
7162 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
7163 hda_nid_t nid = spec->capsrc_nids[c];
Herton Ronaldo Krzesinskib98b7b32009-01-29 13:18:31 -02007164 unsigned int mux_idx;
7165 const struct hda_input_mux *imux;
Takashi Iwaif511b012008-08-15 16:46:42 +02007166 int conns, mute, idx, item;
7167
7168 conns = snd_hda_get_connections(codec, nid, conn_list,
7169 ARRAY_SIZE(conn_list));
7170 if (conns < 0)
7171 continue;
Herton Ronaldo Krzesinskib98b7b32009-01-29 13:18:31 -02007172 mux_idx = c >= spec->num_mux_defs ? 0 : c;
7173 imux = &spec->input_mux[mux_idx];
Takashi Iwaif511b012008-08-15 16:46:42 +02007174 for (idx = 0; idx < conns; idx++) {
7175 /* if the current connection is the selected one,
7176 * unmute it as default - otherwise mute it
7177 */
7178 mute = AMP_IN_MUTE(idx);
7179 for (item = 0; item < imux->num_items; item++) {
7180 if (imux->items[item].index == idx) {
7181 if (spec->cur_mux[c] == item)
7182 mute = AMP_IN_UNMUTE(idx);
7183 break;
7184 }
7185 }
Herton Ronaldo Krzesinskib98b7b32009-01-29 13:18:31 -02007186 /* check if we have a selector or mixer
7187 * we could check for the widget type instead, but
7188 * just check for Amp-In presence (in case of mixer
7189 * without amp-in there is something wrong, this
7190 * function shouldn't be used or capsrc nid is wrong)
7191 */
7192 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
7193 snd_hda_codec_write(codec, nid, 0,
7194 AC_VERB_SET_AMP_GAIN_MUTE,
7195 mute);
7196 else if (mute != AMP_IN_MUTE(idx))
7197 snd_hda_codec_write(codec, nid, 0,
7198 AC_VERB_SET_CONNECT_SEL,
7199 idx);
Takashi Iwaif511b012008-08-15 16:46:42 +02007200 }
7201 }
7202}
7203
Takashi Iwai776e1842007-08-29 15:07:11 +02007204/* add mic boosts if needed */
7205static int alc_auto_add_mic_boost(struct hda_codec *codec)
7206{
7207 struct alc_spec *spec = codec->spec;
7208 int err;
7209 hda_nid_t nid;
7210
7211 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01007212 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02007213 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7214 "Mic Boost",
7215 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
7216 if (err < 0)
7217 return err;
7218 }
7219 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01007220 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02007221 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7222 "Front Mic Boost",
7223 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
7224 if (err < 0)
7225 return err;
7226 }
7227 return 0;
7228}
7229
Kailang Yangdf694da2005-12-05 19:42:22 +01007230/* almost identical with ALC880 parser... */
7231static int alc882_parse_auto_config(struct hda_codec *codec)
7232{
7233 struct alc_spec *spec = codec->spec;
7234 int err = alc880_parse_auto_config(codec);
7235
7236 if (err < 0)
7237 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02007238 else if (!err)
7239 return 0; /* no config found */
7240
7241 err = alc_auto_add_mic_boost(codec);
7242 if (err < 0)
7243 return err;
7244
7245 /* hack - override the init verbs */
7246 spec->init_verbs[0] = alc882_auto_init_verbs;
7247
7248 return 1; /* config found */
Kailang Yangdf694da2005-12-05 19:42:22 +01007249}
7250
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007251/* additional initialization for auto-configuration model */
7252static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01007253{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007254 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007255 alc882_auto_init_multi_out(codec);
7256 alc882_auto_init_hp_out(codec);
7257 alc882_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02007258 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007259 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02007260 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01007261}
7262
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007263static int patch_alc883(struct hda_codec *codec); /* called in patch_alc882() */
7264
Linus Torvalds1da177e2005-04-16 15:20:36 -07007265static int patch_alc882(struct hda_codec *codec)
7266{
7267 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007268 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007269
Takashi Iwaie560d8d2005-09-09 14:21:46 +02007270 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007271 if (spec == NULL)
7272 return -ENOMEM;
7273
Linus Torvalds1da177e2005-04-16 15:20:36 -07007274 codec->spec = spec;
7275
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007276 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
7277 alc882_models,
7278 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007279
Kailang Yangdf694da2005-12-05 19:42:22 +01007280 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01007281 /* Pick up systems that don't supply PCI SSID */
7282 switch (codec->subsystem_id) {
7283 case 0x106b0c00: /* Mac Pro */
7284 board_config = ALC885_MACPRO;
7285 break;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007286 case 0x106b1000: /* iMac 24 */
Peter Korsgaardf3911c52008-09-27 09:13:45 +02007287 case 0x106b2800: /* AppleTV */
Mark Eggleston3077e442009-01-31 17:57:54 +01007288 case 0x106b3e00: /* iMac 24 Aluminium */
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007289 board_config = ALC885_IMAC24;
7290 break;
Luke Yelavich2d466382009-02-23 13:00:33 +11007291 case 0x106b00a0: /* MacBookPro3,1 - Another revision */
Takashi Iwaic7e07572008-06-26 14:42:51 +02007292 case 0x106b00a1: /* Macbook (might be wrong - PCI SSID?) */
David Woodhouse9c95c432008-09-18 13:37:13 -07007293 case 0x106b00a4: /* MacbookPro4,1 */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007294 case 0x106b2c00: /* Macbook Pro rev3 */
Torben Schulzeb4c41d2009-05-18 15:02:35 +02007295 /* Macbook 3.1 (0x106b3600) is handled by patch_alc883() */
Luke Yelavich2a884642009-01-28 15:58:38 +11007296 case 0x106b3800: /* MacbookPro4,1 - latter revision */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007297 board_config = ALC885_MBP3;
7298 break;
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007299 case 0x106b3f00: /* Macbook 5,1 */
Takashi Iwai7442f9d2009-05-14 18:20:33 +02007300 case 0x106b4000: /* Macbook Pro 5,1 - FIXME: HP jack sense
7301 * seems not working, so apparently
7302 * no perfect solution yet
7303 */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007304 board_config = ALC885_MB5;
7305 break;
Tobin Davis081d17c2007-02-15 17:46:18 +01007306 default:
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007307 /* ALC889A is handled better as ALC888-compatible */
Clive Messer669faba2008-09-30 15:49:13 +02007308 if (codec->revision_id == 0x100101 ||
7309 codec->revision_id == 0x100103) {
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007310 alc_free(codec);
7311 return patch_alc883(codec);
7312 }
Takashi Iwai6c627f32009-05-18 12:33:36 +02007313 printk(KERN_INFO "hda_codec: Unknown model for %s, "
7314 "trying auto-probe from BIOS...\n",
7315 codec->chip_name);
Tobin Davis081d17c2007-02-15 17:46:18 +01007316 board_config = ALC882_AUTO;
7317 }
Kailang Yangdf694da2005-12-05 19:42:22 +01007318 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007319
Takashi Iwaif95474e2007-07-10 00:47:43 +02007320 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
7321
Kailang Yangdf694da2005-12-05 19:42:22 +01007322 if (board_config == ALC882_AUTO) {
7323 /* automatic parse from the BIOS config */
7324 err = alc882_parse_auto_config(codec);
7325 if (err < 0) {
7326 alc_free(codec);
7327 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007328 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007329 printk(KERN_INFO
7330 "hda_codec: Cannot set up configuration "
7331 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007332 board_config = ALC882_3ST_DIG;
7333 }
7334 }
7335
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09007336 err = snd_hda_attach_beep_device(codec, 0x1);
7337 if (err < 0) {
7338 alc_free(codec);
7339 return err;
7340 }
7341
Kailang Yangdf694da2005-12-05 19:42:22 +01007342 if (board_config != ALC882_AUTO)
7343 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007344
Kailang Yangdf694da2005-12-05 19:42:22 +01007345 spec->stream_analog_playback = &alc882_pcm_analog_playback;
7346 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01007347 /* FIXME: setup DAC5 */
7348 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
7349 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007350
Kailang Yangdf694da2005-12-05 19:42:22 +01007351 spec->stream_digital_playback = &alc882_pcm_digital_playback;
7352 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007353
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007354 spec->capture_style = CAPT_MIX; /* matrix-style capture */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007355 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01007356 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01007357 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007358 /* get type */
7359 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01007360 if (wcap != AC_WID_AUD_IN) {
7361 spec->adc_nids = alc882_adc_nids_alt;
7362 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
Takashi Iwaie1406342008-02-11 18:32:32 +01007363 spec->capsrc_nids = alc882_capsrc_nids_alt;
Kailang Yangdf694da2005-12-05 19:42:22 +01007364 } else {
7365 spec->adc_nids = alc882_adc_nids;
7366 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +01007367 spec->capsrc_nids = alc882_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +01007368 }
7369 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007370 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007371 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007372
Takashi Iwai2134ea42008-01-10 16:53:55 +01007373 spec->vmaster_nid = 0x0c;
7374
Linus Torvalds1da177e2005-04-16 15:20:36 -07007375 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01007376 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007377 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02007378#ifdef CONFIG_SND_HDA_POWER_SAVE
7379 if (!spec->loopback.amplist)
7380 spec->loopback.amplist = alc882_loopbacks;
7381#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01007382 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007383
7384 return 0;
7385}
7386
7387/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007388 * ALC883 support
7389 *
7390 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
7391 * configuration. Each pin widget can choose any input DACs and a mixer.
7392 * Each ADC is connected from a mixer of all inputs. This makes possible
7393 * 6-channel independent captures.
7394 *
7395 * In addition, an independent DAC for the multi-playback (not used in this
7396 * driver yet).
7397 */
7398#define ALC883_DIGOUT_NID 0x06
7399#define ALC883_DIGIN_NID 0x0a
7400
Wu Fengguang3ab90932008-11-17 09:51:09 +01007401#define ALC1200_DIGOUT_NID 0x10
7402
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007403static hda_nid_t alc883_dac_nids[4] = {
7404 /* front, rear, clfe, rear_surr */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01007405 0x02, 0x03, 0x04, 0x05
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007406};
7407
7408static hda_nid_t alc883_adc_nids[2] = {
7409 /* ADC1-2 */
7410 0x08, 0x09,
7411};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007412
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007413static hda_nid_t alc883_adc_nids_alt[1] = {
7414 /* ADC1 */
7415 0x08,
7416};
7417
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08007418static hda_nid_t alc883_adc_nids_rev[2] = {
7419 /* ADC2-1 */
7420 0x09, 0x08
7421};
7422
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007423#define alc889_adc_nids alc880_adc_nids
7424
Takashi Iwaie1406342008-02-11 18:32:32 +01007425static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 };
7426
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08007427static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
7428
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007429#define alc889_capsrc_nids alc882_capsrc_nids
7430
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007431/* input MUX */
7432/* FIXME: should be a matrix-type input source selection */
7433
7434static struct hda_input_mux alc883_capture_source = {
7435 .num_items = 4,
7436 .items = {
7437 { "Mic", 0x0 },
7438 { "Front Mic", 0x1 },
7439 { "Line", 0x2 },
7440 { "CD", 0x4 },
7441 },
7442};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007443
Jiang zhe17bba1b2008-06-04 12:11:07 +02007444static struct hda_input_mux alc883_3stack_6ch_intel = {
7445 .num_items = 4,
7446 .items = {
7447 { "Mic", 0x1 },
7448 { "Front Mic", 0x0 },
7449 { "Line", 0x2 },
7450 { "CD", 0x4 },
7451 },
7452};
7453
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007454static struct hda_input_mux alc883_lenovo_101e_capture_source = {
7455 .num_items = 2,
7456 .items = {
7457 { "Mic", 0x1 },
7458 { "Line", 0x2 },
7459 },
7460};
7461
Kailang Yang272a5272007-05-14 11:00:38 +02007462static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
7463 .num_items = 4,
7464 .items = {
7465 { "Mic", 0x0 },
7466 { "iMic", 0x1 },
7467 { "Line", 0x2 },
7468 { "CD", 0x4 },
7469 },
7470};
7471
Jiang zhefb97dc62008-03-06 11:07:11 +01007472static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
7473 .num_items = 2,
7474 .items = {
7475 { "Mic", 0x0 },
7476 { "Int Mic", 0x1 },
7477 },
7478};
7479
Kailang Yange2757d52008-08-26 13:17:46 +02007480static struct hda_input_mux alc883_lenovo_sky_capture_source = {
7481 .num_items = 3,
7482 .items = {
7483 { "Mic", 0x0 },
7484 { "Front Mic", 0x1 },
7485 { "Line", 0x4 },
7486 },
7487};
7488
7489static struct hda_input_mux alc883_asus_eee1601_capture_source = {
7490 .num_items = 2,
7491 .items = {
7492 { "Mic", 0x0 },
7493 { "Line", 0x2 },
7494 },
7495};
7496
Torben Schulzeb4c41d2009-05-18 15:02:35 +02007497static struct hda_input_mux alc889A_mb31_capture_source = {
7498 .num_items = 2,
7499 .items = {
7500 { "Mic", 0x0 },
7501 /* Front Mic (0x01) unused */
7502 { "Line", 0x2 },
7503 /* Line 2 (0x03) unused */
7504 /* CD (0x04) unsused? */
7505 },
7506};
7507
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007508/*
7509 * 2ch mode
7510 */
7511static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
7512 { 2, NULL }
7513};
7514
7515/*
7516 * 2ch mode
7517 */
7518static struct hda_verb alc883_3ST_ch2_init[] = {
7519 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7520 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7521 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7522 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7523 { } /* end */
7524};
7525
7526/*
Tobin Davisb2011312007-09-17 12:45:11 +02007527 * 4ch mode
7528 */
7529static struct hda_verb alc883_3ST_ch4_init[] = {
7530 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7531 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7532 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7533 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7534 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7535 { } /* end */
7536};
7537
7538/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007539 * 6ch mode
7540 */
7541static struct hda_verb alc883_3ST_ch6_init[] = {
7542 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7543 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7544 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7545 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7546 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7547 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7548 { } /* end */
7549};
7550
Tobin Davisb2011312007-09-17 12:45:11 +02007551static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007552 { 2, alc883_3ST_ch2_init },
Tobin Davisb2011312007-09-17 12:45:11 +02007553 { 4, alc883_3ST_ch4_init },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007554 { 6, alc883_3ST_ch6_init },
7555};
7556
7557/*
Jiang zhe17bba1b2008-06-04 12:11:07 +02007558 * 2ch mode
7559 */
7560static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7561 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7562 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7563 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7564 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7565 { } /* end */
7566};
7567
7568/*
7569 * 4ch mode
7570 */
7571static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7572 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7573 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7574 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7575 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7576 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7577 { } /* end */
7578};
7579
7580/*
7581 * 6ch mode
7582 */
7583static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7584 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7585 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7586 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7587 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7588 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7589 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7590 { } /* end */
7591};
7592
7593static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7594 { 2, alc883_3ST_ch2_intel_init },
7595 { 4, alc883_3ST_ch4_intel_init },
7596 { 6, alc883_3ST_ch6_intel_init },
7597};
7598
7599/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007600 * 6ch mode
7601 */
7602static struct hda_verb alc883_sixstack_ch6_init[] = {
7603 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7604 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7605 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7606 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7607 { } /* end */
7608};
7609
7610/*
7611 * 8ch mode
7612 */
7613static struct hda_verb alc883_sixstack_ch8_init[] = {
7614 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7615 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7616 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7617 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7618 { } /* end */
7619};
7620
7621static struct hda_channel_mode alc883_sixstack_modes[2] = {
7622 { 6, alc883_sixstack_ch6_init },
7623 { 8, alc883_sixstack_ch8_init },
7624};
7625
Torben Schulzeb4c41d2009-05-18 15:02:35 +02007626/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
7627static struct hda_verb alc889A_mb31_ch2_init[] = {
7628 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7629 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7630 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7631 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7632 { } /* end */
7633};
7634
7635/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
7636static struct hda_verb alc889A_mb31_ch4_init[] = {
7637 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7638 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7639 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7640 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7641 { } /* end */
7642};
7643
7644/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
7645static struct hda_verb alc889A_mb31_ch5_init[] = {
7646 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
7647 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7648 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7649 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7650 { } /* end */
7651};
7652
7653/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
7654static struct hda_verb alc889A_mb31_ch6_init[] = {
7655 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
7656 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
7657 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7658 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7659 { } /* end */
7660};
7661
7662static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
7663 { 2, alc889A_mb31_ch2_init },
7664 { 4, alc889A_mb31_ch4_init },
7665 { 5, alc889A_mb31_ch5_init },
7666 { 6, alc889A_mb31_ch6_init },
7667};
7668
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007669static struct hda_verb alc883_medion_eapd_verbs[] = {
7670 /* eanable EAPD on medion laptop */
7671 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7672 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7673 { }
7674};
7675
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007676/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7677 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7678 */
7679
7680static struct snd_kcontrol_new alc883_base_mixer[] = {
7681 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7682 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7683 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7684 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7685 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7686 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7687 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7688 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7689 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7690 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7691 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7692 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7693 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7694 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7695 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7696 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007697 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007698 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7699 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007700 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007701 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007702 { } /* end */
7703};
7704
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007705static struct snd_kcontrol_new alc883_mitac_mixer[] = {
7706 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7707 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7708 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7709 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7710 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7711 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7712 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7713 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7714 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7715 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7716 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7717 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7718 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007719 { } /* end */
7720};
7721
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007722static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007723 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7724 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7725 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7726 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7727 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7728 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7729 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7730 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7731 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7732 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01007733 { } /* end */
7734};
7735
Jiang zhefb97dc62008-03-06 11:07:11 +01007736static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
7737 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7738 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7739 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7740 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7741 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7742 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7743 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7744 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7745 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7746 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01007747 { } /* end */
7748};
7749
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007750static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
7751 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7752 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7753 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7754 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7755 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7756 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7757 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7758 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007759 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007760 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7761 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007762 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007763 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007764 { } /* end */
7765};
7766
7767static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
7768 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7769 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7770 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7771 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7772 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7773 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7774 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7775 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7776 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7777 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7778 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7779 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7780 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7781 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007782 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007783 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7784 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007785 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007786 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007787 { } /* end */
7788};
7789
Jiang zhe17bba1b2008-06-04 12:11:07 +02007790static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
7791 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7792 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7793 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7794 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7795 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7796 HDA_OUTPUT),
7797 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7798 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7799 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7800 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7801 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7802 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7803 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7804 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7805 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7806 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
7807 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7808 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7809 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7810 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02007811 { } /* end */
7812};
7813
Takashi Iwaid1d985f2006-11-23 19:27:12 +01007814static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02007815 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007816 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007817 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007818 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007819 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7820 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007821 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7822 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007823 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7824 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7825 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7826 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7827 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7828 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007829 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007830 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7831 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007832 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007833 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007834 { } /* end */
7835};
7836
Kailang Yangccc656c2006-10-17 12:32:26 +02007837static struct snd_kcontrol_new alc883_tagra_mixer[] = {
7838 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7839 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7840 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7841 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7842 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7843 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7844 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7845 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7846 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7847 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7848 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7849 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7850 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7851 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007852 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007853 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007854 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007855};
Kailang Yangccc656c2006-10-17 12:32:26 +02007856
7857static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
7858 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7859 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7860 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7861 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7862 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7863 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007864 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007865 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02007866 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7867 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7868 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007869 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007870};
Kailang Yangccc656c2006-10-17 12:32:26 +02007871
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007872static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
7873 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7874 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01007875 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7876 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007877 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7878 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7879 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7880 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007881 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007882};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007883
Kailang Yang272a5272007-05-14 11:00:38 +02007884static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
7885 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7886 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
7887 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7888 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7889 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7890 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7891 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7892 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7893 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007894 { } /* end */
7895};
7896
7897static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
7898 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7899 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7900 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7901 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7902 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7903 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7904 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7905 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7906 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007907 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02007908};
Kailang Yang272a5272007-05-14 11:00:38 +02007909
Tobin Davis2880a862007-08-07 11:50:26 +02007910static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02007911 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7912 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007913 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007914 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7915 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02007916 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7917 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7918 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007919 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02007920};
Tobin Davis2880a862007-08-07 11:50:26 +02007921
Kailang Yange2757d52008-08-26 13:17:46 +02007922static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
7923 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7924 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7925 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
7926 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
7927 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
7928 0x0d, 1, 0x0, HDA_OUTPUT),
7929 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
7930 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
7931 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
7932 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7933 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02007934 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7935 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7936 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7937 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7938 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7939 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7940 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7941 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7942 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7943 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02007944 { } /* end */
7945};
7946
Torben Schulzeb4c41d2009-05-18 15:02:35 +02007947static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
7948 /* Output mixers */
7949 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7950 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7951 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7952 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7953 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
7954 HDA_OUTPUT),
7955 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
7956 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
7957 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
7958 /* Output switches */
7959 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
7960 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
7961 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
7962 /* Boost mixers */
7963 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
7964 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
7965 /* Input mixers */
7966 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7967 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
7968 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7969 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7970 { } /* end */
7971};
7972
Kailang Yange2757d52008-08-26 13:17:46 +02007973static struct hda_bind_ctls alc883_bind_cap_vol = {
7974 .ops = &snd_hda_bind_vol,
7975 .values = {
7976 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
7977 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7978 0
7979 },
7980};
7981
7982static struct hda_bind_ctls alc883_bind_cap_switch = {
7983 .ops = &snd_hda_bind_sw,
7984 .values = {
7985 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
7986 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7987 0
7988 },
7989};
7990
7991static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
7992 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7993 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7994 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7995 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7996 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7997 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7998 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7999 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008000 { } /* end */
8001};
8002
8003static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02008004 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
8005 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
8006 {
8007 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8008 /* .name = "Capture Source", */
8009 .name = "Input Source",
8010 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01008011 .info = alc_mux_enum_info,
8012 .get = alc_mux_enum_get,
8013 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02008014 },
8015 { } /* end */
8016};
8017
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008018static struct snd_kcontrol_new alc883_chmode_mixer[] = {
8019 {
8020 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8021 .name = "Channel Mode",
8022 .info = alc_ch_mode_info,
8023 .get = alc_ch_mode_get,
8024 .put = alc_ch_mode_put,
8025 },
8026 { } /* end */
8027};
8028
8029static struct hda_verb alc883_init_verbs[] = {
8030 /* ADC1: mute amp left and right */
Kailang Yange2757d52008-08-26 13:17:46 +02008031 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008032 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8033 /* ADC2: mute amp left and right */
8034 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8035 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8036 /* Front mixer: unmute input/output amp left and right (volume = 0) */
8037 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8038 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8039 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8040 /* Rear mixer */
8041 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8042 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8043 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8044 /* CLFE mixer */
8045 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8046 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8047 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8048 /* Side mixer */
8049 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8050 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8051 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8052
Takashi Iwaicb53c622007-08-10 17:21:45 +02008053 /* mute analog input loopbacks */
8054 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8055 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8056 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8057 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8058 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008059
8060 /* Front Pin: output 0 (0x0c) */
8061 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8062 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8063 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8064 /* Rear Pin: output 1 (0x0d) */
8065 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8066 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8067 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8068 /* CLFE Pin: output 2 (0x0e) */
8069 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8070 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8071 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
8072 /* Side Pin: output 3 (0x0f) */
8073 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8074 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8075 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8076 /* Mic (rear) pin: input vref at 80% */
8077 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8078 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8079 /* Front Mic pin: input vref at 80% */
8080 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8081 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8082 /* Line In pin: input */
8083 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8084 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8085 /* Line-2 In: Headphone output (output 0 - 0x0c) */
8086 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8087 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8088 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8089 /* CD pin widget for input */
8090 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8091
8092 /* FIXME: use matrix-type input source selection */
8093 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8094 /* Input mixer2 */
8095 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yange2757d52008-08-26 13:17:46 +02008096 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8097 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8098 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008099 /* Input mixer3 */
8100 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yange2757d52008-08-26 13:17:46 +02008101 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8102 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8103 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008104 { }
8105};
8106
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008107/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008108static void alc883_mitac_init_hook(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008109{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008110 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008111
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008112 spec->autocfg.hp_pins[0] = 0x15;
8113 spec->autocfg.speaker_pins[0] = 0x14;
8114 spec->autocfg.speaker_pins[1] = 0x17;
8115 alc_automute_amp(codec);
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008116}
8117
8118/* auto-toggle front mic */
8119/*
8120static void alc883_mitac_mic_automute(struct hda_codec *codec)
8121{
8122 unsigned int present;
8123 unsigned char bits;
8124
8125 present = snd_hda_codec_read(codec, 0x18, 0,
8126 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8127 bits = present ? HDA_AMP_MUTE : 0;
8128 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
8129}
8130*/
8131
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008132static struct hda_verb alc883_mitac_verbs[] = {
8133 /* HP */
8134 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8135 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8136 /* Subwoofer */
8137 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8138 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8139
8140 /* enable unsolicited event */
8141 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8142 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
8143
8144 { } /* end */
8145};
8146
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008147static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008148 /* HP */
8149 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8150 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8151 /* Int speaker */
8152 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
8153 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8154
8155 /* enable unsolicited event */
8156 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008157 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01008158
8159 { } /* end */
8160};
8161
Jiang zhefb97dc62008-03-06 11:07:11 +01008162static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
8163 /* HP */
8164 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8165 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8166 /* Subwoofer */
8167 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8168 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8169
8170 /* enable unsolicited event */
8171 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8172
8173 { } /* end */
8174};
8175
Kailang Yangccc656c2006-10-17 12:32:26 +02008176static struct hda_verb alc883_tagra_verbs[] = {
8177 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8178 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8179
8180 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8181 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008182
Kailang Yangccc656c2006-10-17 12:32:26 +02008183 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8184 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8185 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8186
8187 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008188 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
8189 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
8190 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
Kailang Yangccc656c2006-10-17 12:32:26 +02008191
8192 { } /* end */
8193};
8194
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008195static struct hda_verb alc883_lenovo_101e_verbs[] = {
8196 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8197 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
8198 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
8199 { } /* end */
8200};
8201
Kailang Yang272a5272007-05-14 11:00:38 +02008202static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
8203 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8204 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8205 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8206 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8207 { } /* end */
8208};
8209
8210static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
8211 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8212 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8213 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8214 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
8215 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8216 { } /* end */
8217};
8218
Kailang Yang189609a2007-08-20 11:31:23 +02008219static struct hda_verb alc883_haier_w66_verbs[] = {
8220 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8221 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8222
8223 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8224
8225 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8226 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8227 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8228 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8229 { } /* end */
8230};
8231
Kailang Yange2757d52008-08-26 13:17:46 +02008232static struct hda_verb alc888_lenovo_sky_verbs[] = {
8233 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8234 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8235 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8236 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8237 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8238 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8239 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8240 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8241 { } /* end */
8242};
8243
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008244static struct hda_verb alc888_6st_dell_verbs[] = {
8245 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8246 { }
8247};
8248
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008249static void alc888_3st_hp_init_hook(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008250{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008251 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008252
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008253 spec->autocfg.hp_pins[0] = 0x1b;
8254 spec->autocfg.speaker_pins[0] = 0x14;
8255 spec->autocfg.speaker_pins[1] = 0x16;
8256 spec->autocfg.speaker_pins[2] = 0x18;
8257 alc_automute_amp(codec);
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008258}
8259
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008260static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008261 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01008262 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
8263 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008264 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008265 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008266};
8267
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008268/*
8269 * 2ch mode
8270 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008271static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008272 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8273 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8274 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
8275 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008276 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008277};
8278
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008279/*
8280 * 4ch mode
8281 */
8282static struct hda_verb alc888_3st_hp_4ch_init[] = {
8283 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8284 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8285 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8286 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8287 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8288 { } /* end */
8289};
8290
8291/*
8292 * 6ch mode
8293 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008294static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008295 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8296 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008297 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008298 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8299 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008300 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8301 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008302};
8303
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008304static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008305 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008306 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008307 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008308};
8309
Kailang Yang272a5272007-05-14 11:00:38 +02008310/* toggle front-jack and RCA according to the hp-jack state */
8311static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
8312{
8313 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008314
Kailang Yang272a5272007-05-14 11:00:38 +02008315 present = snd_hda_codec_read(codec, 0x1b, 0,
8316 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008317 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8318 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8319 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8320 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008321}
8322
8323/* toggle RCA according to the front-jack state */
8324static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
8325{
8326 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008327
Kailang Yang272a5272007-05-14 11:00:38 +02008328 present = snd_hda_codec_read(codec, 0x14, 0,
8329 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008330 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8331 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008332}
Takashi Iwai47fd8302007-08-10 17:11:07 +02008333
Kailang Yang272a5272007-05-14 11:00:38 +02008334static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
8335 unsigned int res)
8336{
8337 if ((res >> 26) == ALC880_HP_EVENT)
8338 alc888_lenovo_ms7195_front_automute(codec);
8339 if ((res >> 26) == ALC880_FRONT_EVENT)
8340 alc888_lenovo_ms7195_rca_automute(codec);
8341}
8342
8343static struct hda_verb alc883_medion_md2_verbs[] = {
8344 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8345 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8346
8347 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8348
8349 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8350 { } /* end */
8351};
8352
8353/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008354static void alc883_medion_md2_init_hook(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02008355{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008356 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008357
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008358 spec->autocfg.hp_pins[0] = 0x14;
8359 spec->autocfg.speaker_pins[0] = 0x15;
8360 alc_automute_amp(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02008361}
8362
Kailang Yangccc656c2006-10-17 12:32:26 +02008363/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008364#define alc883_tagra_init_hook alc882_targa_init_hook
8365#define alc883_tagra_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01008366
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008367static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
8368{
8369 unsigned int present;
8370
8371 present = snd_hda_codec_read(codec, 0x18, 0,
8372 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8373 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
8374 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8375}
8376
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008377static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008378{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008379 struct alc_spec *spec = codec->spec;
8380
8381 spec->autocfg.hp_pins[0] = 0x15;
8382 spec->autocfg.speaker_pins[0] = 0x14;
8383 alc_automute_amp(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008384 alc883_clevo_m720_mic_automute(codec);
8385}
8386
8387static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01008388 unsigned int res)
8389{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008390 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008391 case ALC880_MIC_EVENT:
8392 alc883_clevo_m720_mic_automute(codec);
8393 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008394 default:
8395 alc_automute_amp_unsol_event(codec, res);
8396 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008397 }
Jiang zhe368c7a92008-03-04 11:20:33 +01008398}
8399
Jiang zhefb97dc62008-03-06 11:07:11 +01008400/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008401static void alc883_2ch_fujitsu_pi2515_init_hook(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008402{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008403 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008404
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008405 spec->autocfg.hp_pins[0] = 0x14;
8406 spec->autocfg.speaker_pins[0] = 0x15;
8407 alc_automute_amp(codec);
Jiang zhefb97dc62008-03-06 11:07:11 +01008408}
8409
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008410static void alc883_haier_w66_init_hook(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008411{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008412 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008413
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008414 spec->autocfg.hp_pins[0] = 0x1b;
8415 spec->autocfg.speaker_pins[0] = 0x14;
8416 alc_automute_amp(codec);
Kailang Yang189609a2007-08-20 11:31:23 +02008417}
8418
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008419static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
8420{
8421 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008422 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008423
8424 present = snd_hda_codec_read(codec, 0x14, 0,
8425 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008426 bits = present ? HDA_AMP_MUTE : 0;
8427 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8428 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008429}
8430
8431static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
8432{
8433 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008434 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008435
8436 present = snd_hda_codec_read(codec, 0x1b, 0,
8437 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008438 bits = present ? HDA_AMP_MUTE : 0;
8439 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8440 HDA_AMP_MUTE, bits);
8441 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8442 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008443}
8444
8445static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
8446 unsigned int res)
8447{
8448 if ((res >> 26) == ALC880_HP_EVENT)
8449 alc883_lenovo_101e_all_automute(codec);
8450 if ((res >> 26) == ALC880_FRONT_EVENT)
8451 alc883_lenovo_101e_ispeaker_automute(codec);
8452}
8453
Takashi Iwai676a9b52007-08-16 15:23:35 +02008454/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008455static void alc883_acer_aspire_init_hook(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02008456{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008457 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008458
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008459 spec->autocfg.hp_pins[0] = 0x14;
8460 spec->autocfg.speaker_pins[0] = 0x15;
8461 spec->autocfg.speaker_pins[1] = 0x16;
8462 alc_automute_amp(codec);
Takashi Iwai676a9b52007-08-16 15:23:35 +02008463}
8464
Kailang Yangd1a991a2007-08-15 16:21:59 +02008465static struct hda_verb alc883_acer_eapd_verbs[] = {
8466 /* HP Pin: output 0 (0x0c) */
8467 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8468 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8469 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8470 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02008471 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8472 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008473 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008474 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
8475 /* eanable EAPD on medion laptop */
8476 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8477 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02008478 /* enable unsolicited event */
8479 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008480 { }
8481};
8482
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008483static void alc888_6st_dell_init_hook(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008484{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008485 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008486
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008487 spec->autocfg.hp_pins[0] = 0x1b;
8488 spec->autocfg.speaker_pins[0] = 0x14;
8489 spec->autocfg.speaker_pins[1] = 0x15;
8490 spec->autocfg.speaker_pins[2] = 0x16;
8491 spec->autocfg.speaker_pins[3] = 0x17;
8492 alc_automute_amp(codec);
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008493}
8494
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008495static void alc888_lenovo_sky_init_hook(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008496{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008497 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008498
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008499 spec->autocfg.hp_pins[0] = 0x1b;
8500 spec->autocfg.speaker_pins[0] = 0x14;
8501 spec->autocfg.speaker_pins[1] = 0x15;
8502 spec->autocfg.speaker_pins[2] = 0x16;
8503 spec->autocfg.speaker_pins[3] = 0x17;
8504 spec->autocfg.speaker_pins[4] = 0x1a;
8505 alc_automute_amp(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008506}
8507
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008508/*
8509 * generic initialization of ADC, input mixers and output mixers
8510 */
8511static struct hda_verb alc883_auto_init_verbs[] = {
8512 /*
8513 * Unmute ADC0-2 and set the default input to mic-in
8514 */
8515 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8516 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8517 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8518 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8519
Takashi Iwaicb53c622007-08-10 17:21:45 +02008520 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008521 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008522 * Note: PASD motherboards uses the Line In 2 as the input for
8523 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008524 */
8525 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008526 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8527 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8528 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8529 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8530 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008531
8532 /*
8533 * Set up output mixers (0x0c - 0x0f)
8534 */
8535 /* set vol=0 to output mixers */
8536 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8537 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8538 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8539 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8540 /* set up input amps for analog loopback */
8541 /* Amp Indices: DAC = 0, mixer = 1 */
8542 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8543 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8544 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8545 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8546 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8547 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8548 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8549 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8550 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8551 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8552
8553 /* FIXME: use matrix-type input source selection */
8554 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8555 /* Input mixer1 */
8556 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8557 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8558 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008559 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008560 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
8561 /* Input mixer2 */
8562 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8563 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8564 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008565 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Andy Shevchenkoe3cde642007-12-03 16:50:58 +01008566 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008567
8568 { }
8569};
8570
Kailang Yange2757d52008-08-26 13:17:46 +02008571static struct hda_verb alc888_asus_m90v_verbs[] = {
8572 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8573 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8574 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8575 /* enable unsolicited event */
8576 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8577 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8578 { } /* end */
8579};
8580
8581static void alc883_nb_mic_automute(struct hda_codec *codec)
8582{
8583 unsigned int present;
8584
8585 present = snd_hda_codec_read(codec, 0x18, 0,
8586 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8587 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8588 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
8589 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8590 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
8591}
8592
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008593static void alc883_M90V_init_hook(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02008594{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008595 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02008596
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008597 spec->autocfg.hp_pins[0] = 0x1b;
8598 spec->autocfg.speaker_pins[0] = 0x14;
8599 spec->autocfg.speaker_pins[1] = 0x15;
8600 spec->autocfg.speaker_pins[2] = 0x16;
8601 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008602}
8603
8604static void alc883_mode2_unsol_event(struct hda_codec *codec,
8605 unsigned int res)
8606{
8607 switch (res >> 26) {
Kailang Yange2757d52008-08-26 13:17:46 +02008608 case ALC880_MIC_EVENT:
8609 alc883_nb_mic_automute(codec);
8610 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008611 default:
8612 alc_sku_unsol_event(codec, res);
8613 break;
Kailang Yange2757d52008-08-26 13:17:46 +02008614 }
8615}
8616
8617static void alc883_mode2_inithook(struct hda_codec *codec)
8618{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008619 alc883_M90V_init_hook(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008620 alc883_nb_mic_automute(codec);
8621}
8622
8623static struct hda_verb alc888_asus_eee1601_verbs[] = {
8624 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8625 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8626 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8627 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8628 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8629 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
8630 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
8631 /* enable unsolicited event */
8632 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8633 { } /* end */
8634};
8635
Kailang Yange2757d52008-08-26 13:17:46 +02008636static void alc883_eee1601_inithook(struct hda_codec *codec)
8637{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008638 struct alc_spec *spec = codec->spec;
8639
8640 spec->autocfg.hp_pins[0] = 0x14;
8641 spec->autocfg.speaker_pins[0] = 0x1b;
8642 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008643}
8644
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008645static struct hda_verb alc889A_mb31_verbs[] = {
8646 /* Init rear pin (used as headphone output) */
8647 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
8648 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
8649 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8650 /* Init line pin (used as output in 4ch and 6ch mode) */
8651 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
8652 /* Init line 2 pin (used as headphone out by default) */
8653 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
8654 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
8655 { } /* end */
8656};
8657
8658/* Mute speakers according to the headphone jack state */
8659static void alc889A_mb31_automute(struct hda_codec *codec)
8660{
8661 unsigned int present;
8662
8663 /* Mute only in 2ch or 4ch mode */
8664 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
8665 == 0x00) {
8666 present = snd_hda_codec_read(codec, 0x15, 0,
8667 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
8668 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8669 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8670 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8671 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8672 }
8673}
8674
8675static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
8676{
8677 if ((res >> 26) == ALC880_HP_EVENT)
8678 alc889A_mb31_automute(codec);
8679}
8680
Takashi Iwaicb53c622007-08-10 17:21:45 +02008681#ifdef CONFIG_SND_HDA_POWER_SAVE
8682#define alc883_loopbacks alc880_loopbacks
8683#endif
8684
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008685/* pcm configuration: identiacal with ALC880 */
8686#define alc883_pcm_analog_playback alc880_pcm_analog_playback
8687#define alc883_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +01008688#define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008689#define alc883_pcm_digital_playback alc880_pcm_digital_playback
8690#define alc883_pcm_digital_capture alc880_pcm_digital_capture
8691
8692/*
8693 * configuration and preset
8694 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008695static const char *alc883_models[ALC883_MODEL_LAST] = {
8696 [ALC883_3ST_2ch_DIG] = "3stack-dig",
8697 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
8698 [ALC883_3ST_6ch] = "3stack-6ch",
8699 [ALC883_6ST_DIG] = "6stack-dig",
8700 [ALC883_TARGA_DIG] = "targa-dig",
8701 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008702 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02008703 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008704 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008705 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02008706 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008707 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008708 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02008709 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
8710 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02008711 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02008712 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008713 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008714 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008715 [ALC883_MITAC] = "mitac",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008716 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01008717 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008718 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02008719 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Wu Fengguang3ab90932008-11-17 09:51:09 +01008720 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008721 [ALC889A_MB31] = "mb31",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008722 [ALC883_AUTO] = "auto",
8723};
8724
8725static struct snd_pci_quirk alc883_cfg_tbl[] = {
8726 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008727 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01008728 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01008729 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008730 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
8731 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02008732 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008733 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
8734 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008735 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
8736 ALC888_ACER_ASPIRE_4930G),
Takashi Iwaib3bdb302009-02-18 13:16:26 +01008737 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC883_AUTO),
Takashi Iwai94683502009-02-13 09:31:20 +01008738 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC883_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008739 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
8740 ALC888_ACER_ASPIRE_4930G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01008741 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
8742 ALC888_ACER_ASPIRE_4930G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02008743 /* default Acer -- disabled as it causes more problems.
8744 * model=auto should work fine now
8745 */
8746 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008747 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Tobin Davisfebe3372007-06-12 11:27:46 +02008748 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008749 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
8750 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01008751 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01008752 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03008753 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Kailang Yanga01c30c2008-10-15 11:14:58 +02008754 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008755 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01008756 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01008757 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02008758 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Travis Place97ec7102008-05-23 18:31:46 +02008759 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008760 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008761 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008762 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
8763 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02008764 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008765 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Tobin Davis57b14f22007-04-18 23:05:36 +02008766 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008767 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
8768 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
8769 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Jiang zhe4383fae2008-04-14 12:58:57 +02008770 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008771 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01008772 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008773 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
8774 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
8775 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
8776 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
8777 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
8778 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
8779 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
8780 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
8781 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008782 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
8783 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02008784 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01008785 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01008786 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01008787 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02008788 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008789 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008790 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008791 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
8792 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
Takashi Iwaidea0a502009-02-09 17:14:52 +01008793 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04008794 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008795 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02008796 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01008797 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02008798 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008799 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02008800 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02008801 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008802 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
8803 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02008804 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02008805 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01008806 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01008807 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02008808 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008809 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
8810 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008811 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Wu Fengguang4b558992009-01-12 09:18:58 +08008812 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC883_3ST_6ch_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008813 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008814 {}
8815};
8816
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08008817static hda_nid_t alc883_slave_dig_outs[] = {
8818 ALC1200_DIGOUT_NID, 0,
8819};
8820
Wu Fengguangb25c9da2009-02-06 15:02:27 +08008821static hda_nid_t alc1200_slave_dig_outs[] = {
8822 ALC883_DIGOUT_NID, 0,
8823};
8824
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008825static struct alc_config_preset alc883_presets[] = {
8826 [ALC883_3ST_2ch_DIG] = {
8827 .mixers = { alc883_3ST_2ch_mixer },
8828 .init_verbs = { alc883_init_verbs },
8829 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8830 .dac_nids = alc883_dac_nids,
8831 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008832 .dig_in_nid = ALC883_DIGIN_NID,
8833 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8834 .channel_mode = alc883_3ST_2ch_modes,
8835 .input_mux = &alc883_capture_source,
8836 },
8837 [ALC883_3ST_6ch_DIG] = {
8838 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8839 .init_verbs = { alc883_init_verbs },
8840 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8841 .dac_nids = alc883_dac_nids,
8842 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008843 .dig_in_nid = ALC883_DIGIN_NID,
8844 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8845 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008846 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008847 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008848 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008849 [ALC883_3ST_6ch] = {
8850 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8851 .init_verbs = { alc883_init_verbs },
8852 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8853 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008854 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8855 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008856 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008857 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008858 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02008859 [ALC883_3ST_6ch_INTEL] = {
8860 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
8861 .init_verbs = { alc883_init_verbs },
8862 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8863 .dac_nids = alc883_dac_nids,
8864 .dig_out_nid = ALC883_DIGOUT_NID,
8865 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08008866 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +02008867 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
8868 .channel_mode = alc883_3ST_6ch_intel_modes,
8869 .need_dac_fix = 1,
8870 .input_mux = &alc883_3stack_6ch_intel,
8871 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008872 [ALC883_6ST_DIG] = {
8873 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
8874 .init_verbs = { alc883_init_verbs },
8875 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8876 .dac_nids = alc883_dac_nids,
8877 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008878 .dig_in_nid = ALC883_DIGIN_NID,
8879 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8880 .channel_mode = alc883_sixstack_modes,
8881 .input_mux = &alc883_capture_source,
8882 },
Kailang Yangccc656c2006-10-17 12:32:26 +02008883 [ALC883_TARGA_DIG] = {
8884 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
8885 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8886 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8887 .dac_nids = alc883_dac_nids,
8888 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008889 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8890 .channel_mode = alc883_3ST_6ch_modes,
8891 .need_dac_fix = 1,
8892 .input_mux = &alc883_capture_source,
8893 .unsol_event = alc883_tagra_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008894 .init_hook = alc883_tagra_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02008895 },
8896 [ALC883_TARGA_2ch_DIG] = {
8897 .mixers = { alc883_tagra_2ch_mixer},
8898 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8899 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8900 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008901 .adc_nids = alc883_adc_nids_alt,
8902 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangccc656c2006-10-17 12:32:26 +02008903 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008904 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8905 .channel_mode = alc883_3ST_2ch_modes,
8906 .input_mux = &alc883_capture_source,
8907 .unsol_event = alc883_tagra_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008908 .init_hook = alc883_tagra_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02008909 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008910 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008911 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008912 /* On TravelMate laptops, GPIO 0 enables the internal speaker
8913 * and the headphone jack. Turn this on and rely on the
8914 * standard mute methods whenever the user wants to turn
8915 * these outputs off.
8916 */
8917 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
8918 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8919 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008920 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8921 .channel_mode = alc883_3ST_2ch_modes,
8922 .input_mux = &alc883_capture_source,
8923 },
Tobin Davis2880a862007-08-07 11:50:26 +02008924 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008925 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02008926 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02008927 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8928 .dac_nids = alc883_dac_nids,
8929 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02008930 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8931 .channel_mode = alc883_3ST_2ch_modes,
8932 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008933 .unsol_event = alc_automute_amp_unsol_event,
8934 .init_hook = alc883_acer_aspire_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +02008935 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008936 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008937 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008938 alc883_chmode_mixer },
8939 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
8940 alc888_acer_aspire_4930g_verbs },
8941 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8942 .dac_nids = alc883_dac_nids,
8943 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
8944 .adc_nids = alc883_adc_nids_rev,
8945 .capsrc_nids = alc883_capsrc_nids_rev,
8946 .dig_out_nid = ALC883_DIGOUT_NID,
8947 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8948 .channel_mode = alc883_3ST_6ch_modes,
8949 .need_dac_fix = 1,
8950 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008951 ARRAY_SIZE(alc888_2_capture_sources),
8952 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008953 .unsol_event = alc_automute_amp_unsol_event,
8954 .init_hook = alc888_acer_aspire_4930g_init_hook,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008955 },
Tobin Davisc07584c2006-10-13 12:32:16 +02008956 [ALC883_MEDION] = {
8957 .mixers = { alc883_fivestack_mixer,
8958 alc883_chmode_mixer },
8959 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008960 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02008961 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8962 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008963 .adc_nids = alc883_adc_nids_alt,
8964 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Tobin Davisc07584c2006-10-13 12:32:16 +02008965 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8966 .channel_mode = alc883_sixstack_modes,
8967 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008968 },
Kailang Yang272a5272007-05-14 11:00:38 +02008969 [ALC883_MEDION_MD2] = {
8970 .mixers = { alc883_medion_md2_mixer},
8971 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
8972 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8973 .dac_nids = alc883_dac_nids,
8974 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008975 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8976 .channel_mode = alc883_3ST_2ch_modes,
8977 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008978 .unsol_event = alc_automute_amp_unsol_event,
8979 .init_hook = alc883_medion_md2_init_hook,
Kailang Yangea1fb292008-08-26 12:58:38 +02008980 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008981 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008982 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008983 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
8984 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8985 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008986 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8987 .channel_mode = alc883_3ST_2ch_modes,
8988 .input_mux = &alc883_capture_source,
8989 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008990 [ALC883_CLEVO_M720] = {
8991 .mixers = { alc883_clevo_m720_mixer },
8992 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01008993 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8994 .dac_nids = alc883_dac_nids,
8995 .dig_out_nid = ALC883_DIGOUT_NID,
8996 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8997 .channel_mode = alc883_3ST_2ch_modes,
8998 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008999 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009000 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +01009001 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009002 [ALC883_LENOVO_101E_2ch] = {
9003 .mixers = { alc883_lenovo_101e_2ch_mixer},
9004 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
9005 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9006 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009007 .adc_nids = alc883_adc_nids_alt,
9008 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009009 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9010 .channel_mode = alc883_3ST_2ch_modes,
9011 .input_mux = &alc883_lenovo_101e_capture_source,
9012 .unsol_event = alc883_lenovo_101e_unsol_event,
9013 .init_hook = alc883_lenovo_101e_all_automute,
9014 },
Kailang Yang272a5272007-05-14 11:00:38 +02009015 [ALC883_LENOVO_NB0763] = {
9016 .mixers = { alc883_lenovo_nb0763_mixer },
9017 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
9018 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9019 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02009020 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9021 .channel_mode = alc883_3ST_2ch_modes,
9022 .need_dac_fix = 1,
9023 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009024 .unsol_event = alc_automute_amp_unsol_event,
9025 .init_hook = alc883_medion_md2_init_hook,
Kailang Yang272a5272007-05-14 11:00:38 +02009026 },
9027 [ALC888_LENOVO_MS7195_DIG] = {
9028 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9029 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
9030 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9031 .dac_nids = alc883_dac_nids,
9032 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009033 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9034 .channel_mode = alc883_3ST_6ch_modes,
9035 .need_dac_fix = 1,
9036 .input_mux = &alc883_capture_source,
9037 .unsol_event = alc883_lenovo_ms7195_unsol_event,
9038 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02009039 },
9040 [ALC883_HAIER_W66] = {
9041 .mixers = { alc883_tagra_2ch_mixer},
9042 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
9043 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9044 .dac_nids = alc883_dac_nids,
9045 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02009046 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9047 .channel_mode = alc883_3ST_2ch_modes,
9048 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009049 .unsol_event = alc_automute_amp_unsol_event,
9050 .init_hook = alc883_haier_w66_init_hook,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009051 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009052 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009053 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009054 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009055 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9056 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009057 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
9058 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009059 .need_dac_fix = 1,
9060 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009061 .unsol_event = alc_automute_amp_unsol_event,
9062 .init_hook = alc888_3st_hp_init_hook,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009063 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009064 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01009065 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009066 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
9067 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9068 .dac_nids = alc883_dac_nids,
9069 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009070 .dig_in_nid = ALC883_DIGIN_NID,
9071 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9072 .channel_mode = alc883_sixstack_modes,
9073 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009074 .unsol_event = alc_automute_amp_unsol_event,
9075 .init_hook = alc888_6st_dell_init_hook,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009076 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009077 [ALC883_MITAC] = {
9078 .mixers = { alc883_mitac_mixer },
9079 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
9080 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9081 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009082 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9083 .channel_mode = alc883_3ST_2ch_modes,
9084 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009085 .unsol_event = alc_automute_amp_unsol_event,
9086 .init_hook = alc883_mitac_init_hook,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009087 },
Jiang zhefb97dc62008-03-06 11:07:11 +01009088 [ALC883_FUJITSU_PI2515] = {
9089 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
9090 .init_verbs = { alc883_init_verbs,
9091 alc883_2ch_fujitsu_pi2515_verbs},
9092 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9093 .dac_nids = alc883_dac_nids,
9094 .dig_out_nid = ALC883_DIGOUT_NID,
9095 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9096 .channel_mode = alc883_3ST_2ch_modes,
9097 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009098 .unsol_event = alc_automute_amp_unsol_event,
9099 .init_hook = alc883_2ch_fujitsu_pi2515_init_hook,
Jiang zhefb97dc62008-03-06 11:07:11 +01009100 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009101 [ALC888_FUJITSU_XA3530] = {
9102 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
9103 .init_verbs = { alc883_init_verbs,
9104 alc888_fujitsu_xa3530_verbs },
9105 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9106 .dac_nids = alc883_dac_nids,
9107 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9108 .adc_nids = alc883_adc_nids_rev,
9109 .capsrc_nids = alc883_capsrc_nids_rev,
9110 .dig_out_nid = ALC883_DIGOUT_NID,
9111 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
9112 .channel_mode = alc888_4ST_8ch_intel_modes,
9113 .num_mux_defs =
9114 ARRAY_SIZE(alc888_2_capture_sources),
9115 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009116 .unsol_event = alc_automute_amp_unsol_event,
9117 .init_hook = alc888_fujitsu_xa3530_init_hook,
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009118 },
Kailang Yange2757d52008-08-26 13:17:46 +02009119 [ALC888_LENOVO_SKY] = {
9120 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
9121 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
9122 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9123 .dac_nids = alc883_dac_nids,
9124 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +02009125 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9126 .channel_mode = alc883_sixstack_modes,
9127 .need_dac_fix = 1,
9128 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009129 .unsol_event = alc_automute_amp_unsol_event,
9130 .init_hook = alc888_lenovo_sky_init_hook,
Kailang Yange2757d52008-08-26 13:17:46 +02009131 },
9132 [ALC888_ASUS_M90V] = {
9133 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9134 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
9135 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9136 .dac_nids = alc883_dac_nids,
9137 .dig_out_nid = ALC883_DIGOUT_NID,
9138 .dig_in_nid = ALC883_DIGIN_NID,
9139 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9140 .channel_mode = alc883_3ST_6ch_modes,
9141 .need_dac_fix = 1,
9142 .input_mux = &alc883_fujitsu_pi2515_capture_source,
9143 .unsol_event = alc883_mode2_unsol_event,
9144 .init_hook = alc883_mode2_inithook,
9145 },
9146 [ALC888_ASUS_EEE1601] = {
9147 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009148 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +02009149 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
9150 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9151 .dac_nids = alc883_dac_nids,
9152 .dig_out_nid = ALC883_DIGOUT_NID,
9153 .dig_in_nid = ALC883_DIGIN_NID,
9154 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9155 .channel_mode = alc883_3ST_2ch_modes,
9156 .need_dac_fix = 1,
9157 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009158 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +02009159 .init_hook = alc883_eee1601_inithook,
9160 },
Wu Fengguang3ab90932008-11-17 09:51:09 +01009161 [ALC1200_ASUS_P5Q] = {
9162 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9163 .init_verbs = { alc883_init_verbs },
9164 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9165 .dac_nids = alc883_dac_nids,
9166 .dig_out_nid = ALC1200_DIGOUT_NID,
9167 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +08009168 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +01009169 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9170 .channel_mode = alc883_sixstack_modes,
9171 .input_mux = &alc883_capture_source,
9172 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009173 [ALC889A_MB31] = {
9174 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
9175 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
9176 alc880_gpio1_init_verbs },
9177 .adc_nids = alc883_adc_nids,
9178 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
9179 .dac_nids = alc883_dac_nids,
9180 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9181 .channel_mode = alc889A_mb31_6ch_modes,
9182 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
9183 .input_mux = &alc889A_mb31_capture_source,
9184 .dig_out_nid = ALC883_DIGOUT_NID,
9185 .unsol_event = alc889A_mb31_unsol_event,
9186 .init_hook = alc889A_mb31_automute,
9187 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009188};
9189
9190
9191/*
9192 * BIOS auto configuration
9193 */
9194static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
9195 hda_nid_t nid, int pin_type,
9196 int dac_idx)
9197{
9198 /* set as output */
9199 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009200 int idx;
9201
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009202 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009203 if (spec->multiout.dac_nids[dac_idx] == 0x25)
9204 idx = 4;
9205 else
9206 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009207 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
9208
9209}
9210
9211static void alc883_auto_init_multi_out(struct hda_codec *codec)
9212{
9213 struct alc_spec *spec = codec->spec;
9214 int i;
9215
9216 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009217 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009218 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009219 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009220 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009221 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009222 }
9223}
9224
9225static void alc883_auto_init_hp_out(struct hda_codec *codec)
9226{
9227 struct alc_spec *spec = codec->spec;
9228 hda_nid_t pin;
9229
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009230 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009231 if (pin) /* connect to front */
9232 /* use dac 0 */
9233 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009234 pin = spec->autocfg.speaker_pins[0];
9235 if (pin)
9236 alc883_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009237}
9238
9239#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
9240#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
9241
9242static void alc883_auto_init_analog_input(struct hda_codec *codec)
9243{
9244 struct alc_spec *spec = codec->spec;
9245 int i;
9246
9247 for (i = 0; i < AUTO_PIN_LAST; i++) {
9248 hda_nid_t nid = spec->autocfg.input_pins[i];
9249 if (alc883_is_input_pin(nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01009250 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01009251 if (nid != ALC883_PIN_CD_NID &&
9252 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009253 snd_hda_codec_write(codec, nid, 0,
9254 AC_VERB_SET_AMP_GAIN_MUTE,
9255 AMP_OUT_MUTE);
9256 }
9257 }
9258}
9259
Takashi Iwaif511b012008-08-15 16:46:42 +02009260#define alc883_auto_init_input_src alc882_auto_init_input_src
9261
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009262/* almost identical with ALC880 parser... */
9263static int alc883_parse_auto_config(struct hda_codec *codec)
9264{
9265 struct alc_spec *spec = codec->spec;
9266 int err = alc880_parse_auto_config(codec);
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009267 struct auto_pin_cfg *cfg = &spec->autocfg;
9268 int i;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009269
9270 if (err < 0)
9271 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02009272 else if (!err)
9273 return 0; /* no config found */
9274
9275 err = alc_auto_add_mic_boost(codec);
9276 if (err < 0)
9277 return err;
9278
9279 /* hack - override the init verbs */
9280 spec->init_verbs[0] = alc883_auto_init_verbs;
Takashi Iwai776e1842007-08-29 15:07:11 +02009281
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009282 /* setup input_mux for ALC889 */
9283 if (codec->vendor_id == 0x10ec0889) {
9284 /* digital-mic input pin is excluded in alc880_auto_create..()
9285 * because it's under 0x18
9286 */
9287 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
9288 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
9289 struct hda_input_mux *imux = &spec->private_imux[0];
9290 for (i = 1; i < 3; i++)
9291 memcpy(&spec->private_imux[i],
9292 &spec->private_imux[0],
9293 sizeof(spec->private_imux[0]));
9294 imux->items[imux->num_items].label = "Int DMic";
9295 imux->items[imux->num_items].index = 0x0b;
9296 imux->num_items++;
9297 spec->num_mux_defs = 3;
9298 spec->input_mux = spec->private_imux;
9299 }
9300 }
9301
Takashi Iwai776e1842007-08-29 15:07:11 +02009302 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009303}
9304
9305/* additional initialization for auto-configuration model */
9306static void alc883_auto_init(struct hda_codec *codec)
9307{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009308 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009309 alc883_auto_init_multi_out(codec);
9310 alc883_auto_init_hp_out(codec);
9311 alc883_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02009312 alc883_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009313 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02009314 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009315}
9316
9317static int patch_alc883(struct hda_codec *codec)
9318{
9319 struct alc_spec *spec;
9320 int err, board_config;
9321
9322 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
9323 if (spec == NULL)
9324 return -ENOMEM;
9325
9326 codec->spec = spec;
9327
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02009328 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
9329
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009330 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
9331 alc883_models,
9332 alc883_cfg_tbl);
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009333 if (board_config < 0 || board_config >= ALC883_MODEL_LAST) {
9334 /* Pick up systems that don't supply PCI SSID */
9335 switch (codec->subsystem_id) {
9336 case 0x106b3600: /* Macbook 3.1 */
9337 board_config = ALC889A_MB31;
9338 break;
9339 default:
9340 printk(KERN_INFO
9341 "hda_codec: Unknown model for %s, trying "
9342 "auto-probe from BIOS...\n", codec->chip_name);
9343 board_config = ALC883_AUTO;
9344 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009345 }
9346
9347 if (board_config == ALC883_AUTO) {
9348 /* automatic parse from the BIOS config */
9349 err = alc883_parse_auto_config(codec);
9350 if (err < 0) {
9351 alc_free(codec);
9352 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009353 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009354 printk(KERN_INFO
9355 "hda_codec: Cannot set up configuration "
9356 "from BIOS. Using base mode...\n");
9357 board_config = ALC883_3ST_2ch_DIG;
9358 }
9359 }
9360
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09009361 err = snd_hda_attach_beep_device(codec, 0x1);
9362 if (err < 0) {
9363 alc_free(codec);
9364 return err;
9365 }
9366
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009367 if (board_config != ALC883_AUTO)
9368 setup_preset(spec, &alc883_presets[board_config]);
9369
Kailang Yang2f893282008-05-27 12:14:47 +02009370 switch (codec->vendor_id) {
9371 case 0x10ec0888:
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009372 if (!spec->num_adc_nids) {
9373 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
9374 spec->adc_nids = alc883_adc_nids;
9375 }
9376 if (!spec->capsrc_nids)
9377 spec->capsrc_nids = alc883_capsrc_nids;
9378 spec->capture_style = CAPT_MIX; /* matrix-style capture */
Takashi Iwai4a79ba32009-04-22 16:31:35 +02009379 spec->init_amp = ALC_INIT_DEFAULT; /* always initialize */
Kailang Yang2f893282008-05-27 12:14:47 +02009380 break;
9381 case 0x10ec0889:
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009382 if (!spec->num_adc_nids) {
9383 spec->num_adc_nids = ARRAY_SIZE(alc889_adc_nids);
9384 spec->adc_nids = alc889_adc_nids;
9385 }
9386 if (!spec->capsrc_nids)
9387 spec->capsrc_nids = alc889_capsrc_nids;
9388 spec->capture_style = CAPT_1MUX_MIX; /* 1mux/Nmix-style
9389 capture */
Kailang Yang2f893282008-05-27 12:14:47 +02009390 break;
9391 default:
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009392 if (!spec->num_adc_nids) {
9393 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
9394 spec->adc_nids = alc883_adc_nids;
9395 }
9396 if (!spec->capsrc_nids)
9397 spec->capsrc_nids = alc883_capsrc_nids;
9398 spec->capture_style = CAPT_MIX; /* matrix-style capture */
Kailang Yang2f893282008-05-27 12:14:47 +02009399 break;
9400 }
9401
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009402 spec->stream_analog_playback = &alc883_pcm_analog_playback;
9403 spec->stream_analog_capture = &alc883_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01009404 spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009405
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009406 spec->stream_digital_playback = &alc883_pcm_digital_playback;
9407 spec->stream_digital_capture = &alc883_pcm_digital_capture;
9408
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009409 if (!spec->cap_mixer)
9410 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01009411 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009412
Takashi Iwai2134ea42008-01-10 16:53:55 +01009413 spec->vmaster_nid = 0x0c;
9414
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009415 codec->patch_ops = alc_patch_ops;
9416 if (board_config == ALC883_AUTO)
9417 spec->init_hook = alc883_auto_init;
Kailang Yangf9423e72008-05-27 12:32:25 +02009418
Takashi Iwaicb53c622007-08-10 17:21:45 +02009419#ifdef CONFIG_SND_HDA_POWER_SAVE
9420 if (!spec->loopback.amplist)
9421 spec->loopback.amplist = alc883_loopbacks;
9422#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01009423 codec->proc_widget_hook = print_realtek_coef;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009424
9425 return 0;
9426}
9427
9428/*
Kailang Yangdf694da2005-12-05 19:42:22 +01009429 * ALC262 support
9430 */
9431
9432#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
9433#define ALC262_DIGIN_NID ALC880_DIGIN_NID
9434
9435#define alc262_dac_nids alc260_dac_nids
9436#define alc262_adc_nids alc882_adc_nids
9437#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +01009438#define alc262_capsrc_nids alc882_capsrc_nids
9439#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +01009440
9441#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01009442#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01009443
Kailang Yang4e555fe2008-08-26 13:05:55 +02009444static hda_nid_t alc262_dmic_adc_nids[1] = {
9445 /* ADC0 */
9446 0x09
9447};
9448
9449static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
9450
Kailang Yangdf694da2005-12-05 19:42:22 +01009451static struct snd_kcontrol_new alc262_base_mixer[] = {
9452 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9453 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9454 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9455 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9456 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9457 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9458 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9459 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009460 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009461 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9462 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009463 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009464 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
9465 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9466 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
9467 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009468 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01009469};
9470
Takashi Iwaice875f02008-01-28 18:17:43 +01009471/* update HP, line and mono-out pins according to the master switch */
9472static void alc262_hp_master_update(struct hda_codec *codec)
9473{
9474 struct alc_spec *spec = codec->spec;
9475 int val = spec->master_sw;
9476
9477 /* HP & line-out */
9478 snd_hda_codec_write_cache(codec, 0x1b, 0,
9479 AC_VERB_SET_PIN_WIDGET_CONTROL,
9480 val ? PIN_HP : 0);
9481 snd_hda_codec_write_cache(codec, 0x15, 0,
9482 AC_VERB_SET_PIN_WIDGET_CONTROL,
9483 val ? PIN_HP : 0);
9484 /* mono (speaker) depending on the HP jack sense */
9485 val = val && !spec->jack_present;
9486 snd_hda_codec_write_cache(codec, 0x16, 0,
9487 AC_VERB_SET_PIN_WIDGET_CONTROL,
9488 val ? PIN_OUT : 0);
9489}
9490
9491static void alc262_hp_bpc_automute(struct hda_codec *codec)
9492{
9493 struct alc_spec *spec = codec->spec;
9494 unsigned int presence;
9495 presence = snd_hda_codec_read(codec, 0x1b, 0,
9496 AC_VERB_GET_PIN_SENSE, 0);
9497 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9498 alc262_hp_master_update(codec);
9499}
9500
9501static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
9502{
9503 if ((res >> 26) != ALC880_HP_EVENT)
9504 return;
9505 alc262_hp_bpc_automute(codec);
9506}
9507
9508static void alc262_hp_wildwest_automute(struct hda_codec *codec)
9509{
9510 struct alc_spec *spec = codec->spec;
9511 unsigned int presence;
9512 presence = snd_hda_codec_read(codec, 0x15, 0,
9513 AC_VERB_GET_PIN_SENSE, 0);
9514 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9515 alc262_hp_master_update(codec);
9516}
9517
9518static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
9519 unsigned int res)
9520{
9521 if ((res >> 26) != ALC880_HP_EVENT)
9522 return;
9523 alc262_hp_wildwest_automute(codec);
9524}
9525
Takashi Iwaib72519b2009-05-08 14:31:55 +02009526#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +01009527
9528static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
9529 struct snd_ctl_elem_value *ucontrol)
9530{
9531 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9532 struct alc_spec *spec = codec->spec;
9533 int val = !!*ucontrol->value.integer.value;
9534
9535 if (val == spec->master_sw)
9536 return 0;
9537 spec->master_sw = val;
9538 alc262_hp_master_update(codec);
9539 return 1;
9540}
9541
Takashi Iwaib72519b2009-05-08 14:31:55 +02009542#define ALC262_HP_MASTER_SWITCH \
9543 { \
9544 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
9545 .name = "Master Playback Switch", \
9546 .info = snd_ctl_boolean_mono_info, \
9547 .get = alc262_hp_master_sw_get, \
9548 .put = alc262_hp_master_sw_put, \
9549 }
9550
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009551static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +02009552 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009553 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9554 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9555 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009556 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9557 HDA_OUTPUT),
9558 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9559 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009560 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9561 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009562 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009563 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9564 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009565 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009566 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9567 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9568 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9569 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009570 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
9571 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
9572 { } /* end */
9573};
9574
Kailang Yangcd7509a2007-01-26 18:33:17 +01009575static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +02009576 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +01009577 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9578 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9579 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9580 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009581 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9582 HDA_OUTPUT),
9583 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9584 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009585 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
9586 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009587 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009588 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9589 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9590 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9591 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009592 { } /* end */
9593};
9594
9595static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
9596 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9597 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009598 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009599 { } /* end */
9600};
9601
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009602/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009603static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009604{
9605 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009606
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009607 spec->autocfg.hp_pins[0] = 0x15;
9608 spec->autocfg.speaker_pins[0] = 0x0c; /* HACK: not actually a pin */
9609 alc_automute_amp(codec);
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009610}
9611
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009612static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +01009613 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9614 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009615 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9616 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9617 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9618 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9619 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9620 { } /* end */
9621};
9622
9623static struct hda_verb alc262_hp_t5735_verbs[] = {
9624 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9625 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9626
9627 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9628 { }
9629};
9630
Kailang Yang8c427222008-01-10 13:03:59 +01009631static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +01009632 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9633 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01009634 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
9635 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +01009636 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9637 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9638 { } /* end */
9639};
9640
9641static struct hda_verb alc262_hp_rp5700_verbs[] = {
9642 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9643 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9644 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9645 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9646 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9647 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9648 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9649 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9650 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9651 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9652 {}
9653};
9654
9655static struct hda_input_mux alc262_hp_rp5700_capture_source = {
9656 .num_items = 1,
9657 .items = {
9658 { "Line", 0x1 },
9659 },
9660};
9661
Takashi Iwai42171c12009-05-08 14:11:43 +02009662/* bind hp and internal speaker mute (with plug check) as master switch */
9663static void alc262_hippo_master_update(struct hda_codec *codec)
9664{
9665 struct alc_spec *spec = codec->spec;
9666 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
9667 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
9668 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
9669 unsigned int mute;
9670
9671 /* HP */
9672 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
9673 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
9674 HDA_AMP_MUTE, mute);
9675 /* mute internal speaker per jack sense */
9676 if (spec->jack_present)
9677 mute = HDA_AMP_MUTE;
9678 if (line_nid)
9679 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
9680 HDA_AMP_MUTE, mute);
9681 if (speaker_nid && speaker_nid != line_nid)
9682 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
9683 HDA_AMP_MUTE, mute);
9684}
9685
9686#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
9687
9688static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
9689 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +02009690{
9691 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +02009692 struct alc_spec *spec = codec->spec;
9693 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +02009694
Takashi Iwai42171c12009-05-08 14:11:43 +02009695 if (val == spec->master_sw)
9696 return 0;
9697 spec->master_sw = val;
9698 alc262_hippo_master_update(codec);
9699 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +02009700}
Takashi Iwai5b319542007-07-26 11:49:22 +02009701
Takashi Iwai42171c12009-05-08 14:11:43 +02009702#define ALC262_HIPPO_MASTER_SWITCH \
9703 { \
9704 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
9705 .name = "Master Playback Switch", \
9706 .info = snd_ctl_boolean_mono_info, \
9707 .get = alc262_hippo_master_sw_get, \
9708 .put = alc262_hippo_master_sw_put, \
9709 }
9710
9711static struct snd_kcontrol_new alc262_hippo_mixer[] = {
9712 ALC262_HIPPO_MASTER_SWITCH,
9713 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9714 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9715 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9716 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9717 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9718 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9719 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9720 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9721 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9722 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9723 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9724 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9725 { } /* end */
9726};
9727
9728static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
9729 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9730 ALC262_HIPPO_MASTER_SWITCH,
9731 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9732 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9733 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9734 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9735 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9736 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9737 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9738 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9739 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9740 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9741 { } /* end */
9742};
9743
9744/* mute/unmute internal speaker according to the hp jack and mute state */
9745static void alc262_hippo_automute(struct hda_codec *codec)
9746{
9747 struct alc_spec *spec = codec->spec;
9748 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
9749 unsigned int present;
9750
9751 /* need to execute and sync at first */
9752 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
9753 present = snd_hda_codec_read(codec, hp_nid, 0,
9754 AC_VERB_GET_PIN_SENSE, 0);
9755 spec->jack_present = (present & 0x80000000) != 0;
9756 alc262_hippo_master_update(codec);
9757}
9758
9759static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
9760{
9761 if ((res >> 26) != ALC880_HP_EVENT)
9762 return;
9763 alc262_hippo_automute(codec);
9764}
9765
9766static void alc262_hippo_init_hook(struct hda_codec *codec)
9767{
9768 struct alc_spec *spec = codec->spec;
9769
9770 spec->autocfg.hp_pins[0] = 0x15;
9771 spec->autocfg.speaker_pins[0] = 0x14;
9772 alc262_hippo_automute(codec);
9773}
9774
9775static void alc262_hippo1_init_hook(struct hda_codec *codec)
9776{
9777 struct alc_spec *spec = codec->spec;
9778
9779 spec->autocfg.hp_pins[0] = 0x1b;
9780 spec->autocfg.speaker_pins[0] = 0x14;
9781 alc262_hippo_automute(codec);
9782}
9783
9784
Kailang Yang272a5272007-05-14 11:00:38 +02009785static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +02009786 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +02009787 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +02009788 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9789 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9790 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9791 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9792 { } /* end */
9793};
9794
Kailang Yang83c34212007-07-05 11:43:05 +02009795static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +02009796 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9797 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +02009798 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9799 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9800 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9801 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9802 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9803 { } /* end */
9804};
Kailang Yang272a5272007-05-14 11:00:38 +02009805
Tony Vroonba340e82009-02-02 19:01:30 +00009806static struct snd_kcontrol_new alc262_tyan_mixer[] = {
9807 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9808 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
9809 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
9810 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
9811 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9812 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9813 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9814 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9815 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9816 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9817 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9818 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9819 { } /* end */
9820};
9821
9822static struct hda_verb alc262_tyan_verbs[] = {
9823 /* Headphone automute */
9824 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9825 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9826 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9827
9828 /* P11 AUX_IN, white 4-pin connector */
9829 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9830 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
9831 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
9832 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
9833
9834 {}
9835};
9836
9837/* unsolicited event for HP jack sensing */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009838static void alc262_tyan_init_hook(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +00009839{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009840 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +00009841
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009842 spec->autocfg.hp_pins[0] = 0x1b;
9843 spec->autocfg.speaker_pins[0] = 0x15;
9844 alc_automute_amp(codec);
Tony Vroonba340e82009-02-02 19:01:30 +00009845}
9846
Tony Vroonba340e82009-02-02 19:01:30 +00009847
Kailang Yangdf694da2005-12-05 19:42:22 +01009848#define alc262_capture_mixer alc882_capture_mixer
9849#define alc262_capture_alt_mixer alc882_capture_alt_mixer
9850
9851/*
9852 * generic initialization of ADC, input mixers and output mixers
9853 */
9854static struct hda_verb alc262_init_verbs[] = {
9855 /*
9856 * Unmute ADC0-2 and set the default input to mic-in
9857 */
9858 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9859 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9860 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9861 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9862 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9863 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9864
Takashi Iwaicb53c622007-08-10 17:21:45 +02009865 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01009866 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009867 * Note: PASD motherboards uses the Line In 2 as the input for
9868 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01009869 */
9870 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009871 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9872 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9873 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9874 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9875 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009876
9877 /*
9878 * Set up output mixers (0x0c - 0x0e)
9879 */
9880 /* set vol=0 to output mixers */
9881 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9882 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9883 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9884 /* set up input amps for analog loopback */
9885 /* Amp Indices: DAC = 0, mixer = 1 */
9886 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9887 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9888 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9889 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9890 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9891 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9892
9893 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9894 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9895 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9896 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9897 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9898 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9899
9900 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9901 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9902 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9903 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9904 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +02009905
Kailang Yangdf694da2005-12-05 19:42:22 +01009906 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9907 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +02009908
Kailang Yangdf694da2005-12-05 19:42:22 +01009909 /* FIXME: use matrix-type input source selection */
9910 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9911 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9912 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9913 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9914 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9915 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9916 /* Input mixer2 */
9917 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9918 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9919 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9920 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9921 /* Input mixer3 */
9922 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9923 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9924 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009925 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +01009926
9927 { }
9928};
9929
Kailang Yang4e555fe2008-08-26 13:05:55 +02009930static struct hda_verb alc262_eapd_verbs[] = {
9931 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
9932 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
9933 { }
9934};
9935
Kailang Yangccc656c2006-10-17 12:32:26 +02009936static struct hda_verb alc262_hippo_unsol_verbs[] = {
9937 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9938 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9939 {}
9940};
9941
9942static struct hda_verb alc262_hippo1_unsol_verbs[] = {
9943 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9944 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9945 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9946
9947 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9948 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9949 {}
9950};
9951
Kailang Yang272a5272007-05-14 11:00:38 +02009952static struct hda_verb alc262_sony_unsol_verbs[] = {
9953 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9954 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9955 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
9956
9957 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9958 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +09009959 {}
Kailang Yang272a5272007-05-14 11:00:38 +02009960};
9961
Kailang Yang4e555fe2008-08-26 13:05:55 +02009962static struct hda_input_mux alc262_dmic_capture_source = {
9963 .num_items = 2,
9964 .items = {
9965 { "Int DMic", 0x9 },
9966 { "Mic", 0x0 },
9967 },
9968};
9969
9970static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
9971 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9972 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9973 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9974 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9975 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +02009976 { } /* end */
9977};
9978
9979static struct hda_verb alc262_toshiba_s06_verbs[] = {
9980 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9981 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9982 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9983 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9984 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
9985 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9986 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
9987 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9988 {}
9989};
9990
9991static void alc262_dmic_automute(struct hda_codec *codec)
9992{
9993 unsigned int present;
9994
9995 present = snd_hda_codec_read(codec, 0x18, 0,
9996 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9997 snd_hda_codec_write(codec, 0x22, 0,
9998 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x09);
9999}
10000
Kailang Yang4e555fe2008-08-26 13:05:55 +020010001
10002/* unsolicited event for HP jack sensing */
10003static void alc262_toshiba_s06_unsol_event(struct hda_codec *codec,
10004 unsigned int res)
10005{
Kailang Yang4e555fe2008-08-26 13:05:55 +020010006 if ((res >> 26) == ALC880_MIC_EVENT)
10007 alc262_dmic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010008 else
10009 alc_sku_unsol_event(codec, res);
Kailang Yang4e555fe2008-08-26 13:05:55 +020010010}
10011
10012static void alc262_toshiba_s06_init_hook(struct hda_codec *codec)
10013{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010014 struct alc_spec *spec = codec->spec;
10015
10016 spec->autocfg.hp_pins[0] = 0x15;
10017 spec->autocfg.speaker_pins[0] = 0x14;
10018 alc_automute_pin(codec);
Kailang Yang4e555fe2008-08-26 13:05:55 +020010019 alc262_dmic_automute(codec);
10020}
10021
Takashi Iwai834be882006-03-01 14:16:17 +010010022/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010023 * nec model
10024 * 0x15 = headphone
10025 * 0x16 = internal speaker
10026 * 0x18 = external mic
10027 */
10028
10029static struct snd_kcontrol_new alc262_nec_mixer[] = {
10030 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
10031 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
10032
10033 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10034 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10035 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10036
10037 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10038 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10039 { } /* end */
10040};
10041
10042static struct hda_verb alc262_nec_verbs[] = {
10043 /* Unmute Speaker */
10044 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10045
10046 /* Headphone */
10047 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10048 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10049
10050 /* External mic to headphone */
10051 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10052 /* External mic to speaker */
10053 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10054 {}
10055};
10056
10057/*
Takashi Iwai834be882006-03-01 14:16:17 +010010058 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010010059 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
10060 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010010061 */
10062
10063#define ALC_HP_EVENT 0x37
10064
10065static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
10066 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10067 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010010068 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10069 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010010070 {}
10071};
10072
Jiang zhe0e31daf2008-03-20 12:12:39 +010010073static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
10074 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10075 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10076 {}
10077};
10078
Takashi Iwai834be882006-03-01 14:16:17 +010010079static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010080 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010010081 .items = {
10082 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010083 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010010084 { "CD", 0x4 },
10085 },
10086};
10087
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010088static struct hda_input_mux alc262_HP_capture_source = {
10089 .num_items = 5,
10090 .items = {
10091 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020010092 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010093 { "Line", 0x2 },
10094 { "CD", 0x4 },
10095 { "AUX IN", 0x6 },
10096 },
10097};
10098
zhejiangaccbe492007-08-31 12:36:05 +020010099static struct hda_input_mux alc262_HP_D7000_capture_source = {
10100 .num_items = 4,
10101 .items = {
10102 { "Mic", 0x0 },
10103 { "Front Mic", 0x2 },
10104 { "Line", 0x1 },
10105 { "CD", 0x4 },
10106 },
10107};
10108
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010109/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010010110static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
10111{
10112 struct alc_spec *spec = codec->spec;
10113 unsigned int mute;
10114
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010115 if (force || !spec->sense_updated) {
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010116 unsigned int present;
Takashi Iwai834be882006-03-01 14:16:17 +010010117 /* need to execute and sync at first */
10118 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010119 /* check laptop HP jack */
10120 present = snd_hda_codec_read(codec, 0x14, 0,
10121 AC_VERB_GET_PIN_SENSE, 0);
10122 /* need to execute and sync at first */
10123 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10124 /* check docking HP jack */
10125 present |= snd_hda_codec_read(codec, 0x1b, 0,
10126 AC_VERB_GET_PIN_SENSE, 0);
10127 if (present & AC_PINSENSE_PRESENCE)
10128 spec->jack_present = 1;
10129 else
10130 spec->jack_present = 0;
Takashi Iwai834be882006-03-01 14:16:17 +010010131 spec->sense_updated = 1;
10132 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010133 /* unmute internal speaker only if both HPs are unplugged and
10134 * master switch is on
10135 */
10136 if (spec->jack_present)
10137 mute = HDA_AMP_MUTE;
10138 else
Takashi Iwai834be882006-03-01 14:16:17 +010010139 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010140 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10141 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010010142}
10143
10144/* unsolicited event for HP jack sensing */
10145static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
10146 unsigned int res)
10147{
10148 if ((res >> 26) != ALC_HP_EVENT)
10149 return;
10150 alc262_fujitsu_automute(codec, 1);
10151}
10152
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010153static void alc262_fujitsu_init_hook(struct hda_codec *codec)
10154{
10155 alc262_fujitsu_automute(codec, 1);
10156}
10157
Takashi Iwai834be882006-03-01 14:16:17 +010010158/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020010159static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
10160 .ops = &snd_hda_bind_vol,
10161 .values = {
10162 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
10163 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
10164 0
10165 },
10166};
Takashi Iwai834be882006-03-01 14:16:17 +010010167
Jiang zhe0e31daf2008-03-20 12:12:39 +010010168/* mute/unmute internal speaker according to the hp jack and mute state */
10169static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
10170{
10171 struct alc_spec *spec = codec->spec;
10172 unsigned int mute;
10173
10174 if (force || !spec->sense_updated) {
10175 unsigned int present_int_hp;
10176 /* need to execute and sync at first */
10177 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10178 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
10179 AC_VERB_GET_PIN_SENSE, 0);
10180 spec->jack_present = (present_int_hp & 0x80000000) != 0;
10181 spec->sense_updated = 1;
10182 }
10183 if (spec->jack_present) {
10184 /* mute internal speaker */
10185 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10186 HDA_AMP_MUTE, HDA_AMP_MUTE);
10187 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10188 HDA_AMP_MUTE, HDA_AMP_MUTE);
10189 } else {
10190 /* unmute internal speaker if necessary */
10191 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
10192 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10193 HDA_AMP_MUTE, mute);
10194 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10195 HDA_AMP_MUTE, mute);
10196 }
10197}
10198
10199/* unsolicited event for HP jack sensing */
10200static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
10201 unsigned int res)
10202{
10203 if ((res >> 26) != ALC_HP_EVENT)
10204 return;
10205 alc262_lenovo_3000_automute(codec, 1);
10206}
10207
Takashi Iwai834be882006-03-01 14:16:17 +010010208/* bind hp and internal speaker mute (with plug check) */
10209static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
10210 struct snd_ctl_elem_value *ucontrol)
10211{
10212 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10213 long *valp = ucontrol->value.integer.value;
10214 int change;
10215
Tony Vroon5d9fab22008-03-14 17:09:18 +010010216 change = snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10217 HDA_AMP_MUTE,
10218 valp ? 0 : HDA_AMP_MUTE);
10219 change |= snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
10220 HDA_AMP_MUTE,
10221 valp ? 0 : HDA_AMP_MUTE);
10222
Takashi Iwai82beb8f2007-08-10 17:09:26 +020010223 if (change)
10224 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010010225 return change;
10226}
10227
10228static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020010229 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010010230 {
10231 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10232 .name = "Master Playback Switch",
10233 .info = snd_hda_mixer_amp_switch_info,
10234 .get = snd_hda_mixer_amp_switch_get,
10235 .put = alc262_fujitsu_master_sw_put,
10236 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10237 },
10238 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10239 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10240 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10241 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10242 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010243 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10244 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10245 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010010246 { } /* end */
10247};
10248
Jiang zhe0e31daf2008-03-20 12:12:39 +010010249/* bind hp and internal speaker mute (with plug check) */
10250static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
10251 struct snd_ctl_elem_value *ucontrol)
10252{
10253 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10254 long *valp = ucontrol->value.integer.value;
10255 int change;
10256
10257 change = snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
10258 HDA_AMP_MUTE,
10259 valp ? 0 : HDA_AMP_MUTE);
10260
10261 if (change)
10262 alc262_lenovo_3000_automute(codec, 0);
10263 return change;
10264}
10265
10266static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
10267 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10268 {
10269 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10270 .name = "Master Playback Switch",
10271 .info = snd_hda_mixer_amp_switch_info,
10272 .get = snd_hda_mixer_amp_switch_get,
10273 .put = alc262_lenovo_3000_master_sw_put,
10274 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
10275 },
10276 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10277 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10278 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10279 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10280 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10281 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10282 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10283 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10284 { } /* end */
10285};
10286
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010287static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
10288 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020010289 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010290 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10291 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10292 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10293 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10294 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10295 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10296 { } /* end */
10297};
10298
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010299/* additional init verbs for Benq laptops */
10300static struct hda_verb alc262_EAPD_verbs[] = {
10301 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10302 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
10303 {}
10304};
10305
Kailang Yang83c34212007-07-05 11:43:05 +020010306static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
10307 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10308 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10309
10310 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10311 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
10312 {}
10313};
10314
Tobin Davisf651b502007-10-26 12:40:47 +020010315/* Samsung Q1 Ultra Vista model setup */
10316static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010317 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10318 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010319 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10320 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10321 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010322 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010323 { } /* end */
10324};
10325
10326static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010327 /* output mixer */
10328 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10329 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10330 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10331 /* speaker */
10332 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10333 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10334 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10335 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10336 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020010337 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010338 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10339 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10340 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10341 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10342 /* internal mic */
10343 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10344 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10345 /* ADC, choose mic */
10346 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10347 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10348 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10349 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10350 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10351 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10352 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10353 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10354 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
10355 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020010356 {}
10357};
10358
Tobin Davisf651b502007-10-26 12:40:47 +020010359/* mute/unmute internal speaker according to the hp jack and mute state */
10360static void alc262_ultra_automute(struct hda_codec *codec)
10361{
10362 struct alc_spec *spec = codec->spec;
10363 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020010364
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010365 mute = 0;
10366 /* auto-mute only when HP is used as HP */
10367 if (!spec->cur_mux[0]) {
10368 unsigned int present;
10369 /* need to execute and sync at first */
10370 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
10371 present = snd_hda_codec_read(codec, 0x15, 0,
10372 AC_VERB_GET_PIN_SENSE, 0);
10373 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
10374 if (spec->jack_present)
10375 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020010376 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010377 /* mute/unmute internal speaker */
10378 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10379 HDA_AMP_MUTE, mute);
10380 /* mute/unmute HP */
10381 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10382 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020010383}
10384
10385/* unsolicited event for HP jack sensing */
10386static void alc262_ultra_unsol_event(struct hda_codec *codec,
10387 unsigned int res)
10388{
10389 if ((res >> 26) != ALC880_HP_EVENT)
10390 return;
10391 alc262_ultra_automute(codec);
10392}
10393
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010394static struct hda_input_mux alc262_ultra_capture_source = {
10395 .num_items = 2,
10396 .items = {
10397 { "Mic", 0x1 },
10398 { "Headphone", 0x7 },
10399 },
10400};
10401
10402static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
10403 struct snd_ctl_elem_value *ucontrol)
10404{
10405 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10406 struct alc_spec *spec = codec->spec;
10407 int ret;
10408
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010409 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010410 if (!ret)
10411 return 0;
10412 /* reprogram the HP pin as mic or HP according to the input source */
10413 snd_hda_codec_write_cache(codec, 0x15, 0,
10414 AC_VERB_SET_PIN_WIDGET_CONTROL,
10415 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
10416 alc262_ultra_automute(codec); /* mute/unmute HP */
10417 return ret;
10418}
10419
10420static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
10421 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10422 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10423 {
10424 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10425 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010426 .info = alc_mux_enum_info,
10427 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010428 .put = alc262_ultra_mux_enum_put,
10429 },
10430 { } /* end */
10431};
10432
Kailang Yangdf694da2005-12-05 19:42:22 +010010433/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010434static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
10435 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010010436{
10437 hda_nid_t nid;
10438 int err;
10439
10440 spec->multiout.num_dacs = 1; /* only use one dac */
10441 spec->multiout.dac_nids = spec->private_dac_nids;
10442 spec->multiout.dac_nids[0] = 2;
10443
10444 nid = cfg->line_out_pins[0];
10445 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010446 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10447 "Front Playback Volume",
10448 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
10449 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010450 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010451 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10452 "Front Playback Switch",
10453 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
10454 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010455 return err;
10456 }
10457
Takashi Iwai82bc9552006-03-21 11:24:42 +010010458 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010459 if (nid) {
10460 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010461 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10462 "Speaker Playback Volume",
10463 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10464 HDA_OUTPUT));
10465 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010466 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010467 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10468 "Speaker Playback Switch",
10469 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10470 HDA_OUTPUT));
10471 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010472 return err;
10473 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010474 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10475 "Speaker Playback Switch",
10476 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10477 HDA_OUTPUT));
10478 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010479 return err;
10480 }
10481 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +020010482 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010483 if (nid) {
10484 /* spec->multiout.hp_nid = 2; */
10485 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010486 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10487 "Headphone Playback Volume",
10488 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10489 HDA_OUTPUT));
10490 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010491 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010492 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10493 "Headphone Playback Switch",
10494 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10495 HDA_OUTPUT));
10496 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010497 return err;
10498 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010499 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10500 "Headphone Playback Switch",
10501 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10502 HDA_OUTPUT));
10503 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010504 return err;
10505 }
10506 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010507 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010010508}
10509
10510/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010511#define alc262_auto_create_analog_input_ctls \
10512 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010010513
10514/*
10515 * generic initialization of ADC, input mixers and output mixers
10516 */
10517static struct hda_verb alc262_volume_init_verbs[] = {
10518 /*
10519 * Unmute ADC0-2 and set the default input to mic-in
10520 */
10521 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10522 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10523 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10524 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10525 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10526 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10527
Takashi Iwaicb53c622007-08-10 17:21:45 +020010528 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010529 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010530 * Note: PASD motherboards uses the Line In 2 as the input for
10531 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010532 */
10533 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010534 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10535 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10536 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10537 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10538 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010539
10540 /*
10541 * Set up output mixers (0x0c - 0x0f)
10542 */
10543 /* set vol=0 to output mixers */
10544 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10545 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10546 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020010547
Kailang Yangdf694da2005-12-05 19:42:22 +010010548 /* set up input amps for analog loopback */
10549 /* Amp Indices: DAC = 0, mixer = 1 */
10550 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10551 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10552 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10553 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10554 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10555 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10556
10557 /* FIXME: use matrix-type input source selection */
10558 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10559 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10560 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10561 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10562 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10563 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10564 /* Input mixer2 */
10565 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10566 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10567 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10568 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10569 /* Input mixer3 */
10570 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10571 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10572 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10573 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10574
10575 { }
10576};
10577
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010578static struct hda_verb alc262_HP_BPC_init_verbs[] = {
10579 /*
10580 * Unmute ADC0-2 and set the default input to mic-in
10581 */
10582 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10583 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10584 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10585 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10586 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10587 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10588
Takashi Iwaicb53c622007-08-10 17:21:45 +020010589 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010590 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010591 * Note: PASD motherboards uses the Line In 2 as the input for
10592 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010593 */
10594 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010595 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10596 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10597 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10598 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10599 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10600 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10601 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020010602
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010603 /*
10604 * Set up output mixers (0x0c - 0x0e)
10605 */
10606 /* set vol=0 to output mixers */
10607 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10608 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10609 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10610
10611 /* set up input amps for analog loopback */
10612 /* Amp Indices: DAC = 0, mixer = 1 */
10613 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10614 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10615 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10616 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10617 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10618 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10619
Takashi Iwaice875f02008-01-28 18:17:43 +010010620 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010621 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10622 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10623
10624 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10625 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10626
10627 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10628 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10629
10630 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10631 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10632 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10633 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10634 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10635
10636 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10637 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10638 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10639 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10640 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10641 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10642
10643
10644 /* FIXME: use matrix-type input source selection */
10645 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10646 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10647 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10648 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10649 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10650 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10651 /* Input mixer2 */
10652 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10653 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10654 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10655 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10656 /* Input mixer3 */
10657 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10658 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10659 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10660 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10661
Takashi Iwaice875f02008-01-28 18:17:43 +010010662 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10663
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010664 { }
10665};
10666
Kailang Yangcd7509a2007-01-26 18:33:17 +010010667static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
10668 /*
10669 * Unmute ADC0-2 and set the default input to mic-in
10670 */
10671 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10672 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10673 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10674 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10675 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10676 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10677
Takashi Iwaicb53c622007-08-10 17:21:45 +020010678 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010010679 * mixer widget
10680 * Note: PASD motherboards uses the Line In 2 as the input for front
10681 * panel mic (mic 2)
10682 */
10683 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010684 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10685 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10686 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10687 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10688 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10689 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10690 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10691 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010010692 /*
10693 * Set up output mixers (0x0c - 0x0e)
10694 */
10695 /* set vol=0 to output mixers */
10696 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10697 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10698 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10699
10700 /* set up input amps for analog loopback */
10701 /* Amp Indices: DAC = 0, mixer = 1 */
10702 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10703 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10704 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10705 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10706 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10707 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10708
10709
10710 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
10711 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
10712 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
10713 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
10714 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10715 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
10716 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
10717
10718 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10719 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10720
10721 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10722 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
10723
10724 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
10725 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10726 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10727 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10728 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10729 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10730
10731 /* FIXME: use matrix-type input source selection */
10732 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10733 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10734 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
10735 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
10736 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
10737 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
10738 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
10739 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10740 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
10741 /* Input mixer2 */
10742 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10743 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10744 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10745 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10746 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10747 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10748 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10749 /* Input mixer3 */
10750 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10751 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10752 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10753 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10754 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10755 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10756 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10757
Takashi Iwaice875f02008-01-28 18:17:43 +010010758 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10759
Kailang Yangcd7509a2007-01-26 18:33:17 +010010760 { }
10761};
10762
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010763static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
10764
10765 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
10766 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10767 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
10768
10769 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
10770 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10771 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10772 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10773
10774 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
10775 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10776 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10777 {}
10778};
10779
10780
Takashi Iwaicb53c622007-08-10 17:21:45 +020010781#ifdef CONFIG_SND_HDA_POWER_SAVE
10782#define alc262_loopbacks alc880_loopbacks
10783#endif
10784
Kailang Yangdf694da2005-12-05 19:42:22 +010010785/* pcm configuration: identiacal with ALC880 */
10786#define alc262_pcm_analog_playback alc880_pcm_analog_playback
10787#define alc262_pcm_analog_capture alc880_pcm_analog_capture
10788#define alc262_pcm_digital_playback alc880_pcm_digital_playback
10789#define alc262_pcm_digital_capture alc880_pcm_digital_capture
10790
10791/*
10792 * BIOS auto configuration
10793 */
10794static int alc262_parse_auto_config(struct hda_codec *codec)
10795{
10796 struct alc_spec *spec = codec->spec;
10797 int err;
10798 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
10799
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010800 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10801 alc262_ignore);
10802 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010803 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010804 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010010805 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010806 spec->multiout.max_channels = 2;
10807 spec->no_analog = 1;
10808 goto dig_only;
10809 }
Kailang Yangdf694da2005-12-05 19:42:22 +010010810 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010811 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010812 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
10813 if (err < 0)
10814 return err;
10815 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
10816 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010817 return err;
10818
10819 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10820
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010821 dig_only:
Takashi Iwai0852d7a2009-02-11 11:35:15 +010010822 if (spec->autocfg.dig_outs) {
Kailang Yangdf694da2005-12-05 19:42:22 +010010823 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
Takashi Iwai0852d7a2009-02-11 11:35:15 +010010824 spec->dig_out_type = spec->autocfg.dig_out_type[0];
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010825 }
Kailang Yangdf694da2005-12-05 19:42:22 +010010826 if (spec->autocfg.dig_in_pin)
10827 spec->dig_in_nid = ALC262_DIGIN_NID;
10828
Takashi Iwai603c4012008-07-30 15:01:44 +020010829 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010010830 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010010831
Takashi Iwaid88897e2008-10-31 15:01:37 +010010832 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020010833 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020010834 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010835
Takashi Iwai776e1842007-08-29 15:07:11 +020010836 err = alc_auto_add_mic_boost(codec);
10837 if (err < 0)
10838 return err;
10839
Takashi Iwai4a79ba32009-04-22 16:31:35 +020010840 alc_ssid_check(codec, 0x15, 0x14, 0x1b);
10841
Kailang Yangdf694da2005-12-05 19:42:22 +010010842 return 1;
10843}
10844
10845#define alc262_auto_init_multi_out alc882_auto_init_multi_out
10846#define alc262_auto_init_hp_out alc882_auto_init_hp_out
10847#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020010848#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010010849
10850
10851/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010852static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010010853{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010854 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010010855 alc262_auto_init_multi_out(codec);
10856 alc262_auto_init_hp_out(codec);
10857 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020010858 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010859 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020010860 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010010861}
10862
10863/*
10864 * configuration and preset
10865 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010866static const char *alc262_models[ALC262_MODEL_LAST] = {
10867 [ALC262_BASIC] = "basic",
10868 [ALC262_HIPPO] = "hippo",
10869 [ALC262_HIPPO_1] = "hippo_1",
10870 [ALC262_FUJITSU] = "fujitsu",
10871 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010010872 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010010873 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010010874 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010875 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020010876 [ALC262_BENQ_T31] = "benq-t31",
10877 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020010878 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010879 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020010880 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010010881 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010882 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000010883 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010884 [ALC262_AUTO] = "auto",
10885};
10886
10887static struct snd_pci_quirk alc262_cfg_tbl[] = {
10888 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010889 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010010890 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
10891 ALC262_HP_BPC),
10892 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
10893 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010010894 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
10895 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010896 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010897 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010898 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010899 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010900 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010901 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010902 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010903 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010904 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
10905 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
10906 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010907 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
10908 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010010909 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010910 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010911 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010912 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010010913 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwaif872a912009-02-26 00:57:01 +010010914 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
10915 ALC262_SONY_ASSAMD),
Akio Idehara36ca6e12008-06-09 22:57:40 +090010916 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010917 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020010918 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010919 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010010920 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000010921 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010010922 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
10923 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110010924 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010010925 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010926 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020010927 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010928 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010010929 {}
10930};
10931
10932static struct alc_config_preset alc262_presets[] = {
10933 [ALC262_BASIC] = {
10934 .mixers = { alc262_base_mixer },
10935 .init_verbs = { alc262_init_verbs },
10936 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10937 .dac_nids = alc262_dac_nids,
10938 .hp_nid = 0x03,
10939 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10940 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010010941 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010010942 },
Kailang Yangccc656c2006-10-17 12:32:26 +020010943 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020010944 .mixers = { alc262_hippo_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +020010945 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
10946 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10947 .dac_nids = alc262_dac_nids,
10948 .hp_nid = 0x03,
10949 .dig_out_nid = ALC262_DIGOUT_NID,
10950 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10951 .channel_mode = alc262_modes,
10952 .input_mux = &alc262_capture_source,
10953 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020010954 .init_hook = alc262_hippo_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +020010955 },
10956 [ALC262_HIPPO_1] = {
10957 .mixers = { alc262_hippo1_mixer },
10958 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
10959 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10960 .dac_nids = alc262_dac_nids,
10961 .hp_nid = 0x02,
10962 .dig_out_nid = ALC262_DIGOUT_NID,
10963 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10964 .channel_mode = alc262_modes,
10965 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020010966 .unsol_event = alc262_hippo_unsol_event,
10967 .init_hook = alc262_hippo1_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +020010968 },
Takashi Iwai834be882006-03-01 14:16:17 +010010969 [ALC262_FUJITSU] = {
10970 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010971 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
10972 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010010973 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10974 .dac_nids = alc262_dac_nids,
10975 .hp_nid = 0x03,
10976 .dig_out_nid = ALC262_DIGOUT_NID,
10977 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10978 .channel_mode = alc262_modes,
10979 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010980 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010981 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010010982 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010983 [ALC262_HP_BPC] = {
10984 .mixers = { alc262_HP_BPC_mixer },
10985 .init_verbs = { alc262_HP_BPC_init_verbs },
10986 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10987 .dac_nids = alc262_dac_nids,
10988 .hp_nid = 0x03,
10989 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10990 .channel_mode = alc262_modes,
10991 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010992 .unsol_event = alc262_hp_bpc_unsol_event,
10993 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010994 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010010995 [ALC262_HP_BPC_D7000_WF] = {
10996 .mixers = { alc262_HP_BPC_WildWest_mixer },
10997 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
10998 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10999 .dac_nids = alc262_dac_nids,
11000 .hp_nid = 0x03,
11001 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11002 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011003 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011004 .unsol_event = alc262_hp_wildwest_unsol_event,
11005 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011006 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011007 [ALC262_HP_BPC_D7000_WL] = {
11008 .mixers = { alc262_HP_BPC_WildWest_mixer,
11009 alc262_HP_BPC_WildWest_option_mixer },
11010 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11011 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11012 .dac_nids = alc262_dac_nids,
11013 .hp_nid = 0x03,
11014 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11015 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011016 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011017 .unsol_event = alc262_hp_wildwest_unsol_event,
11018 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011019 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011020 [ALC262_HP_TC_T5735] = {
11021 .mixers = { alc262_hp_t5735_mixer },
11022 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
11023 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11024 .dac_nids = alc262_dac_nids,
11025 .hp_nid = 0x03,
11026 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11027 .channel_mode = alc262_modes,
11028 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011029 .unsol_event = alc_automute_amp_unsol_event,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011030 .init_hook = alc262_hp_t5735_init_hook,
Kailang Yang8c427222008-01-10 13:03:59 +010011031 },
11032 [ALC262_HP_RP5700] = {
11033 .mixers = { alc262_hp_rp5700_mixer },
11034 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
11035 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11036 .dac_nids = alc262_dac_nids,
11037 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11038 .channel_mode = alc262_modes,
11039 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011040 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011041 [ALC262_BENQ_ED8] = {
11042 .mixers = { alc262_base_mixer },
11043 .init_verbs = { alc262_init_verbs, alc262_EAPD_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 Iwaif12ab1e2007-04-12 15:51:47 +020011050 },
Kailang Yang272a5272007-05-14 11:00:38 +020011051 [ALC262_SONY_ASSAMD] = {
11052 .mixers = { alc262_sony_mixer },
11053 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
11054 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11055 .dac_nids = alc262_dac_nids,
11056 .hp_nid = 0x02,
11057 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11058 .channel_mode = alc262_modes,
11059 .input_mux = &alc262_capture_source,
11060 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011061 .init_hook = alc262_hippo_init_hook,
Kailang Yang83c34212007-07-05 11:43:05 +020011062 },
11063 [ALC262_BENQ_T31] = {
11064 .mixers = { alc262_benq_t31_mixer },
11065 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
11066 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11067 .dac_nids = alc262_dac_nids,
11068 .hp_nid = 0x03,
11069 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11070 .channel_mode = alc262_modes,
11071 .input_mux = &alc262_capture_source,
11072 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011073 .init_hook = alc262_hippo_init_hook,
Kailang Yangea1fb292008-08-26 12:58:38 +020011074 },
Tobin Davisf651b502007-10-26 12:40:47 +020011075 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011076 .mixers = { alc262_ultra_mixer },
11077 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011078 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020011079 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11080 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020011081 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11082 .channel_mode = alc262_modes,
11083 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011084 .adc_nids = alc262_adc_nids, /* ADC0 */
11085 .capsrc_nids = alc262_capsrc_nids,
11086 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020011087 .unsol_event = alc262_ultra_unsol_event,
11088 .init_hook = alc262_ultra_automute,
11089 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010011090 [ALC262_LENOVO_3000] = {
11091 .mixers = { alc262_lenovo_3000_mixer },
11092 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11093 alc262_lenovo_3000_unsol_verbs },
11094 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11095 .dac_nids = alc262_dac_nids,
11096 .hp_nid = 0x03,
11097 .dig_out_nid = ALC262_DIGOUT_NID,
11098 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11099 .channel_mode = alc262_modes,
11100 .input_mux = &alc262_fujitsu_capture_source,
11101 .unsol_event = alc262_lenovo_3000_unsol_event,
11102 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011103 [ALC262_NEC] = {
11104 .mixers = { alc262_nec_mixer },
11105 .init_verbs = { alc262_nec_verbs },
11106 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11107 .dac_nids = alc262_dac_nids,
11108 .hp_nid = 0x03,
11109 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11110 .channel_mode = alc262_modes,
11111 .input_mux = &alc262_capture_source,
11112 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020011113 [ALC262_TOSHIBA_S06] = {
11114 .mixers = { alc262_toshiba_s06_mixer },
11115 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
11116 alc262_eapd_verbs },
11117 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11118 .capsrc_nids = alc262_dmic_capsrc_nids,
11119 .dac_nids = alc262_dac_nids,
11120 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
11121 .dig_out_nid = ALC262_DIGOUT_NID,
11122 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11123 .channel_mode = alc262_modes,
11124 .input_mux = &alc262_dmic_capture_source,
11125 .unsol_event = alc262_toshiba_s06_unsol_event,
11126 .init_hook = alc262_toshiba_s06_init_hook,
11127 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011128 [ALC262_TOSHIBA_RX1] = {
11129 .mixers = { alc262_toshiba_rx1_mixer },
11130 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
11131 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11132 .dac_nids = alc262_dac_nids,
11133 .hp_nid = 0x03,
11134 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11135 .channel_mode = alc262_modes,
11136 .input_mux = &alc262_capture_source,
11137 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011138 .init_hook = alc262_hippo_init_hook,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011139 },
Tony Vroonba340e82009-02-02 19:01:30 +000011140 [ALC262_TYAN] = {
11141 .mixers = { alc262_tyan_mixer },
11142 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
11143 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11144 .dac_nids = alc262_dac_nids,
11145 .hp_nid = 0x02,
11146 .dig_out_nid = ALC262_DIGOUT_NID,
11147 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11148 .channel_mode = alc262_modes,
11149 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011150 .unsol_event = alc_automute_amp_unsol_event,
11151 .init_hook = alc262_tyan_init_hook,
Tony Vroonba340e82009-02-02 19:01:30 +000011152 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011153};
11154
11155static int patch_alc262(struct hda_codec *codec)
11156{
11157 struct alc_spec *spec;
11158 int board_config;
11159 int err;
11160
Robert P. J. Daydc041e02006-12-19 14:44:15 +010011161 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010011162 if (spec == NULL)
11163 return -ENOMEM;
11164
11165 codec->spec = spec;
11166#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011167 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
11168 * under-run
11169 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011170 {
11171 int tmp;
11172 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11173 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
11174 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11175 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
11176 }
11177#endif
11178
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020011179 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
11180
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011181 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
11182 alc262_models,
11183 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010011184
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011185 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020011186 printk(KERN_INFO "hda_codec: Unknown model for %s, "
11187 "trying auto-probe from BIOS...\n", codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010011188 board_config = ALC262_AUTO;
11189 }
11190
11191 if (board_config == ALC262_AUTO) {
11192 /* automatic parse from the BIOS config */
11193 err = alc262_parse_auto_config(codec);
11194 if (err < 0) {
11195 alc_free(codec);
11196 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011197 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011198 printk(KERN_INFO
11199 "hda_codec: Cannot set up configuration "
11200 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011201 board_config = ALC262_BASIC;
11202 }
11203 }
11204
Takashi Iwai07eba612009-02-19 08:06:35 +010011205 if (!spec->no_analog) {
11206 err = snd_hda_attach_beep_device(codec, 0x1);
11207 if (err < 0) {
11208 alc_free(codec);
11209 return err;
11210 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090011211 }
11212
Kailang Yangdf694da2005-12-05 19:42:22 +010011213 if (board_config != ALC262_AUTO)
11214 setup_preset(spec, &alc262_presets[board_config]);
11215
Kailang Yangdf694da2005-12-05 19:42:22 +010011216 spec->stream_analog_playback = &alc262_pcm_analog_playback;
11217 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020011218
Kailang Yangdf694da2005-12-05 19:42:22 +010011219 spec->stream_digital_playback = &alc262_pcm_digital_playback;
11220 spec->stream_digital_capture = &alc262_pcm_digital_capture;
11221
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011222 spec->capture_style = CAPT_MIX;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011223 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011224 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +010011225 unsigned int wcap = get_wcaps(codec, 0x07);
11226
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011227 /* get type */
11228 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +010011229 if (wcap != AC_WID_AUD_IN) {
11230 spec->adc_nids = alc262_adc_nids_alt;
11231 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwai88c71a92008-02-14 17:27:17 +010011232 spec->capsrc_nids = alc262_capsrc_nids_alt;
Kailang Yangdf694da2005-12-05 19:42:22 +010011233 } else {
11234 spec->adc_nids = alc262_adc_nids;
11235 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
Takashi Iwai88c71a92008-02-14 17:27:17 +010011236 spec->capsrc_nids = alc262_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010011237 }
11238 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011239 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011240 set_capture_mixer(spec);
Takashi Iwai07eba612009-02-19 08:06:35 +010011241 if (!spec->no_analog)
11242 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010011243
Takashi Iwai2134ea42008-01-10 16:53:55 +010011244 spec->vmaster_nid = 0x0c;
11245
Kailang Yangdf694da2005-12-05 19:42:22 +010011246 codec->patch_ops = alc_patch_ops;
11247 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011248 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011249#ifdef CONFIG_SND_HDA_POWER_SAVE
11250 if (!spec->loopback.amplist)
11251 spec->loopback.amplist = alc262_loopbacks;
11252#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010011253 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020011254
Kailang Yangdf694da2005-12-05 19:42:22 +010011255 return 0;
11256}
11257
Kailang Yangdf694da2005-12-05 19:42:22 +010011258/*
Kailang Yanga361d842007-06-05 12:30:55 +020011259 * ALC268 channel source setting (2 channel)
11260 */
11261#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
11262#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020011263
Kailang Yanga361d842007-06-05 12:30:55 +020011264static hda_nid_t alc268_dac_nids[2] = {
11265 /* front, hp */
11266 0x02, 0x03
11267};
11268
11269static hda_nid_t alc268_adc_nids[2] = {
11270 /* ADC0-1 */
11271 0x08, 0x07
11272};
11273
11274static hda_nid_t alc268_adc_nids_alt[1] = {
11275 /* ADC0 */
11276 0x08
11277};
11278
Takashi Iwaie1406342008-02-11 18:32:32 +010011279static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
11280
Kailang Yanga361d842007-06-05 12:30:55 +020011281static struct snd_kcontrol_new alc268_base_mixer[] = {
11282 /* output mixer control */
11283 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11284 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11285 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11286 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011287 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11288 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11289 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020011290 { }
11291};
11292
Takashi Iwai42171c12009-05-08 14:11:43 +020011293static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
11294 /* output mixer control */
11295 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11296 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11297 ALC262_HIPPO_MASTER_SWITCH,
11298 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11299 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11300 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11301 { }
11302};
11303
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011304/* bind Beep switches of both NID 0x0f and 0x10 */
11305static struct hda_bind_ctls alc268_bind_beep_sw = {
11306 .ops = &snd_hda_bind_sw,
11307 .values = {
11308 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
11309 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
11310 0
11311 },
11312};
11313
11314static struct snd_kcontrol_new alc268_beep_mixer[] = {
11315 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
11316 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
11317 { }
11318};
11319
Kailang Yangd1a991a2007-08-15 16:21:59 +020011320static struct hda_verb alc268_eapd_verbs[] = {
11321 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11322 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11323 { }
11324};
11325
Takashi Iwaid2738092007-08-16 14:59:45 +020011326/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020011327static struct hda_verb alc268_toshiba_verbs[] = {
11328 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11329 { } /* end */
11330};
11331
Kailang Yang8ef355d2008-08-26 13:10:22 +020011332static struct hda_input_mux alc268_acer_lc_capture_source = {
11333 .num_items = 2,
11334 .items = {
11335 { "i-Mic", 0x6 },
11336 { "E-Mic", 0x0 },
11337 },
11338};
11339
Takashi Iwaid2738092007-08-16 14:59:45 +020011340/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020011341/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020011342static struct hda_bind_ctls alc268_acer_bind_master_vol = {
11343 .ops = &snd_hda_bind_vol,
11344 .values = {
11345 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
11346 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
11347 0
11348 },
11349};
11350
Takashi Iwai889c4392007-08-23 18:56:52 +020011351/* mute/unmute internal speaker according to the hp jack and mute state */
11352static void alc268_acer_automute(struct hda_codec *codec, int force)
11353{
11354 struct alc_spec *spec = codec->spec;
11355 unsigned int mute;
11356
11357 if (force || !spec->sense_updated) {
11358 unsigned int present;
11359 present = snd_hda_codec_read(codec, 0x14, 0,
11360 AC_VERB_GET_PIN_SENSE, 0);
11361 spec->jack_present = (present & 0x80000000) != 0;
11362 spec->sense_updated = 1;
11363 }
11364 if (spec->jack_present)
11365 mute = HDA_AMP_MUTE; /* mute internal speaker */
11366 else /* unmute internal speaker if necessary */
11367 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
11368 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11369 HDA_AMP_MUTE, mute);
11370}
11371
11372
11373/* bind hp and internal speaker mute (with plug check) */
11374static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
11375 struct snd_ctl_elem_value *ucontrol)
11376{
11377 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11378 long *valp = ucontrol->value.integer.value;
11379 int change;
11380
11381 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
11382 HDA_AMP_MUTE,
11383 valp[0] ? 0 : HDA_AMP_MUTE);
11384 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
11385 HDA_AMP_MUTE,
11386 valp[1] ? 0 : HDA_AMP_MUTE);
11387 if (change)
11388 alc268_acer_automute(codec, 0);
11389 return change;
11390}
Takashi Iwaid2738092007-08-16 14:59:45 +020011391
Kailang Yang8ef355d2008-08-26 13:10:22 +020011392static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
11393 /* output mixer control */
11394 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11395 {
11396 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11397 .name = "Master Playback Switch",
11398 .info = snd_hda_mixer_amp_switch_info,
11399 .get = snd_hda_mixer_amp_switch_get,
11400 .put = alc268_acer_master_sw_put,
11401 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11402 },
11403 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
11404 { }
11405};
11406
Takashi Iwaid2738092007-08-16 14:59:45 +020011407static struct snd_kcontrol_new alc268_acer_mixer[] = {
11408 /* output mixer control */
11409 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11410 {
11411 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11412 .name = "Master Playback Switch",
11413 .info = snd_hda_mixer_amp_switch_info,
11414 .get = snd_hda_mixer_amp_switch_get,
11415 .put = alc268_acer_master_sw_put,
11416 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11417 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011418 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11419 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11420 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020011421 { }
11422};
11423
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011424static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
11425 /* output mixer control */
11426 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11427 {
11428 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11429 .name = "Master Playback Switch",
11430 .info = snd_hda_mixer_amp_switch_info,
11431 .get = snd_hda_mixer_amp_switch_get,
11432 .put = alc268_acer_master_sw_put,
11433 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11434 },
11435 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11436 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11437 { }
11438};
11439
Kailang Yang8ef355d2008-08-26 13:10:22 +020011440static struct hda_verb alc268_acer_aspire_one_verbs[] = {
11441 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11442 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11443 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11444 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11445 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
11446 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
11447 { }
11448};
11449
Takashi Iwaid2738092007-08-16 14:59:45 +020011450static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011451 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
11452 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020011453 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11454 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011455 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11456 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020011457 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11458 { }
11459};
11460
11461/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020011462#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
11463#define alc268_toshiba_init_hook alc262_hippo_init_hook
Takashi Iwaid2738092007-08-16 14:59:45 +020011464
11465static void alc268_acer_unsol_event(struct hda_codec *codec,
11466 unsigned int res)
11467{
Takashi Iwai889c4392007-08-23 18:56:52 +020011468 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020011469 return;
11470 alc268_acer_automute(codec, 1);
11471}
11472
Takashi Iwai889c4392007-08-23 18:56:52 +020011473static void alc268_acer_init_hook(struct hda_codec *codec)
11474{
11475 alc268_acer_automute(codec, 1);
11476}
11477
Kailang Yang8ef355d2008-08-26 13:10:22 +020011478/* toggle speaker-output according to the hp-jack state */
11479static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
11480{
11481 unsigned int present;
11482 unsigned char bits;
11483
11484 present = snd_hda_codec_read(codec, 0x15, 0,
11485 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11486 bits = present ? AMP_IN_MUTE(0) : 0;
11487 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
11488 AMP_IN_MUTE(0), bits);
11489 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
11490 AMP_IN_MUTE(0), bits);
11491}
11492
11493
11494static void alc268_acer_mic_automute(struct hda_codec *codec)
11495{
11496 unsigned int present;
11497
11498 present = snd_hda_codec_read(codec, 0x18, 0,
11499 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11500 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_CONNECT_SEL,
11501 present ? 0x0 : 0x6);
11502}
11503
11504static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
11505 unsigned int res)
11506{
11507 if ((res >> 26) == ALC880_HP_EVENT)
11508 alc268_aspire_one_speaker_automute(codec);
11509 if ((res >> 26) == ALC880_MIC_EVENT)
11510 alc268_acer_mic_automute(codec);
11511}
11512
11513static void alc268_acer_lc_init_hook(struct hda_codec *codec)
11514{
11515 alc268_aspire_one_speaker_automute(codec);
11516 alc268_acer_mic_automute(codec);
11517}
11518
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011519static struct snd_kcontrol_new alc268_dell_mixer[] = {
11520 /* output mixer control */
11521 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11522 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11523 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11524 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11525 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11526 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11527 { }
11528};
11529
11530static struct hda_verb alc268_dell_verbs[] = {
11531 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11532 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11533 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11534 { }
11535};
11536
11537/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011538static void alc268_dell_init_hook(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011539{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011540 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011541
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011542 spec->autocfg.hp_pins[0] = 0x15;
11543 spec->autocfg.speaker_pins[0] = 0x14;
11544 alc_automute_pin(codec);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011545}
11546
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011547static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
11548 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11549 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11550 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11551 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11552 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11553 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
11554 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
11555 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11556 { }
11557};
11558
11559static struct hda_verb alc267_quanta_il1_verbs[] = {
11560 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11561 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
11562 { }
11563};
11564
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011565static void alc267_quanta_il1_mic_automute(struct hda_codec *codec)
11566{
11567 unsigned int present;
11568
11569 present = snd_hda_codec_read(codec, 0x18, 0,
11570 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11571 snd_hda_codec_write(codec, 0x23, 0,
11572 AC_VERB_SET_CONNECT_SEL,
11573 present ? 0x00 : 0x01);
11574}
11575
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011576static void alc267_quanta_il1_init_hook(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011577{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011578 struct alc_spec *spec = codec->spec;
11579
11580 spec->autocfg.hp_pins[0] = 0x15;
11581 spec->autocfg.speaker_pins[0] = 0x14;
11582 alc_automute_pin(codec);
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011583 alc267_quanta_il1_mic_automute(codec);
11584}
11585
11586static void alc267_quanta_il1_unsol_event(struct hda_codec *codec,
11587 unsigned int res)
11588{
11589 switch (res >> 26) {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011590 case ALC880_MIC_EVENT:
11591 alc267_quanta_il1_mic_automute(codec);
11592 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011593 default:
11594 alc_sku_unsol_event(codec, res);
11595 break;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011596 }
11597}
11598
Kailang Yanga361d842007-06-05 12:30:55 +020011599/*
11600 * generic initialization of ADC, input mixers and output mixers
11601 */
11602static struct hda_verb alc268_base_init_verbs[] = {
11603 /* Unmute DAC0-1 and set vol = 0 */
11604 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011605 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011606
11607 /*
11608 * Set up output mixers (0x0c - 0x0e)
11609 */
11610 /* set vol=0 to output mixers */
11611 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020011612 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
11613
11614 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11615 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11616
11617 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11618 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11619 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11620 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11621 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11622 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11623 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11624 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11625
11626 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11627 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11628 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11629 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011630 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011631
11632 /* set PCBEEP vol = 0, mute connections */
11633 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11634 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11635 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020011636
Jiang Zhea9b3aa82007-12-20 13:13:13 +010011637 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020011638
Jiang Zhea9b3aa82007-12-20 13:13:13 +010011639 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
11640 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11641 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
11642 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011643
Kailang Yanga361d842007-06-05 12:30:55 +020011644 { }
11645};
11646
11647/*
11648 * generic initialization of ADC, input mixers and output mixers
11649 */
11650static struct hda_verb alc268_volume_init_verbs[] = {
11651 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010011652 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11653 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011654
11655 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11656 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11657 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11658 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11659 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11660
Kailang Yanga361d842007-06-05 12:30:55 +020011661 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020011662 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11663 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11664
11665 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011666 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011667
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011668 /* set PCBEEP vol = 0, mute connections */
11669 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11670 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11671 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020011672
11673 { }
11674};
11675
Kailang Yanga361d842007-06-05 12:30:55 +020011676static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
11677 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11678 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11679 {
11680 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11681 /* The multiple "Capture Source" controls confuse alsamixer
11682 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020011683 */
11684 /* .name = "Capture Source", */
11685 .name = "Input Source",
11686 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011687 .info = alc_mux_enum_info,
11688 .get = alc_mux_enum_get,
11689 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020011690 },
11691 { } /* end */
11692};
11693
11694static struct snd_kcontrol_new alc268_capture_mixer[] = {
11695 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11696 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11697 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
11698 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
11699 {
11700 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11701 /* The multiple "Capture Source" controls confuse alsamixer
11702 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020011703 */
11704 /* .name = "Capture Source", */
11705 .name = "Input Source",
11706 .count = 2,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011707 .info = alc_mux_enum_info,
11708 .get = alc_mux_enum_get,
11709 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020011710 },
11711 { } /* end */
11712};
11713
11714static struct hda_input_mux alc268_capture_source = {
11715 .num_items = 4,
11716 .items = {
11717 { "Mic", 0x0 },
11718 { "Front Mic", 0x1 },
11719 { "Line", 0x2 },
11720 { "CD", 0x3 },
11721 },
11722};
11723
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011724static struct hda_input_mux alc268_acer_capture_source = {
11725 .num_items = 3,
11726 .items = {
11727 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011728 { "Internal Mic", 0x1 },
11729 { "Line", 0x2 },
11730 },
11731};
11732
11733static struct hda_input_mux alc268_acer_dmic_capture_source = {
11734 .num_items = 3,
11735 .items = {
11736 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011737 { "Internal Mic", 0x6 },
11738 { "Line", 0x2 },
11739 },
11740};
11741
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011742#ifdef CONFIG_SND_DEBUG
11743static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011744 /* Volume widgets */
11745 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11746 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11747 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
11748 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
11749 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
11750 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
11751 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
11752 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
11753 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
11754 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
11755 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
11756 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
11757 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010011758 /* The below appears problematic on some hardwares */
11759 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011760 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11761 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
11762 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
11763 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
11764
11765 /* Modes for retasking pin widgets */
11766 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
11767 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
11768 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
11769 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
11770
11771 /* Controls for GPIO pins, assuming they are configured as outputs */
11772 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
11773 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
11774 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
11775 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
11776
11777 /* Switches to allow the digital SPDIF output pin to be enabled.
11778 * The ALC268 does not have an SPDIF input.
11779 */
11780 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
11781
11782 /* A switch allowing EAPD to be enabled. Some laptops seem to use
11783 * this output to turn on an external amplifier.
11784 */
11785 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
11786 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
11787
11788 { } /* end */
11789};
11790#endif
11791
Kailang Yanga361d842007-06-05 12:30:55 +020011792/* create input playback/capture controls for the given pin */
11793static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
11794 const char *ctlname, int idx)
11795{
11796 char name[32];
11797 int err;
11798
11799 sprintf(name, "%s Playback Volume", ctlname);
11800 if (nid == 0x14) {
11801 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11802 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
11803 HDA_OUTPUT));
11804 if (err < 0)
11805 return err;
11806 } else if (nid == 0x15) {
11807 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11808 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
11809 HDA_OUTPUT));
11810 if (err < 0)
11811 return err;
11812 } else
11813 return -1;
11814 sprintf(name, "%s Playback Switch", ctlname);
11815 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
11816 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
11817 if (err < 0)
11818 return err;
11819 return 0;
11820}
11821
11822/* add playback controls from the parsed DAC table */
11823static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
11824 const struct auto_pin_cfg *cfg)
11825{
11826 hda_nid_t nid;
11827 int err;
11828
11829 spec->multiout.num_dacs = 2; /* only use one dac */
11830 spec->multiout.dac_nids = spec->private_dac_nids;
11831 spec->multiout.dac_nids[0] = 2;
11832 spec->multiout.dac_nids[1] = 3;
11833
11834 nid = cfg->line_out_pins[0];
11835 if (nid)
Kailang Yangea1fb292008-08-26 12:58:38 +020011836 alc268_new_analog_output(spec, nid, "Front", 0);
Kailang Yanga361d842007-06-05 12:30:55 +020011837
11838 nid = cfg->speaker_pins[0];
11839 if (nid == 0x1d) {
11840 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11841 "Speaker Playback Volume",
11842 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
11843 if (err < 0)
11844 return err;
11845 }
11846 nid = cfg->hp_pins[0];
11847 if (nid)
11848 alc268_new_analog_output(spec, nid, "Headphone", 0);
11849
11850 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
11851 if (nid == 0x16) {
11852 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11853 "Mono Playback Switch",
11854 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
11855 if (err < 0)
11856 return err;
11857 }
Kailang Yangea1fb292008-08-26 12:58:38 +020011858 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020011859}
11860
11861/* create playback/capture controls for input pins */
11862static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
11863 const struct auto_pin_cfg *cfg)
11864{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011865 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020011866 int i, idx1;
11867
11868 for (i = 0; i < AUTO_PIN_LAST; i++) {
11869 switch(cfg->input_pins[i]) {
11870 case 0x18:
11871 idx1 = 0; /* Mic 1 */
11872 break;
11873 case 0x19:
11874 idx1 = 1; /* Mic 2 */
11875 break;
11876 case 0x1a:
11877 idx1 = 2; /* Line In */
11878 break;
Kailang Yangea1fb292008-08-26 12:58:38 +020011879 case 0x1c:
Kailang Yanga361d842007-06-05 12:30:55 +020011880 idx1 = 3; /* CD */
11881 break;
Takashi Iwai7194cae2008-03-06 16:58:17 +010011882 case 0x12:
11883 case 0x13:
11884 idx1 = 6; /* digital mics */
11885 break;
Kailang Yanga361d842007-06-05 12:30:55 +020011886 default:
11887 continue;
11888 }
11889 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
11890 imux->items[imux->num_items].index = idx1;
Kailang Yangea1fb292008-08-26 12:58:38 +020011891 imux->num_items++;
Kailang Yanga361d842007-06-05 12:30:55 +020011892 }
11893 return 0;
11894}
11895
11896static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
11897{
11898 struct alc_spec *spec = codec->spec;
11899 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
11900 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
11901 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
11902 unsigned int dac_vol1, dac_vol2;
11903
11904 if (speaker_nid) {
11905 snd_hda_codec_write(codec, speaker_nid, 0,
11906 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
11907 snd_hda_codec_write(codec, 0x0f, 0,
11908 AC_VERB_SET_AMP_GAIN_MUTE,
11909 AMP_IN_UNMUTE(1));
11910 snd_hda_codec_write(codec, 0x10, 0,
11911 AC_VERB_SET_AMP_GAIN_MUTE,
11912 AMP_IN_UNMUTE(1));
11913 } else {
11914 snd_hda_codec_write(codec, 0x0f, 0,
11915 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
11916 snd_hda_codec_write(codec, 0x10, 0,
11917 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
11918 }
11919
11920 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020011921 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020011922 dac_vol2 = AMP_OUT_ZERO;
11923 else if (line_nid == 0x15)
11924 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020011925 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020011926 dac_vol2 = AMP_OUT_ZERO;
11927 else if (hp_nid == 0x15)
11928 dac_vol1 = AMP_OUT_ZERO;
11929 if (line_nid != 0x16 || hp_nid != 0x16 ||
11930 spec->autocfg.line_out_pins[1] != 0x16 ||
11931 spec->autocfg.line_out_pins[2] != 0x16)
11932 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
11933
11934 snd_hda_codec_write(codec, 0x02, 0,
11935 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
11936 snd_hda_codec_write(codec, 0x03, 0,
11937 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
11938}
11939
11940/* pcm configuration: identiacal with ALC880 */
11941#define alc268_pcm_analog_playback alc880_pcm_analog_playback
11942#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010011943#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020011944#define alc268_pcm_digital_playback alc880_pcm_digital_playback
11945
11946/*
11947 * BIOS auto configuration
11948 */
11949static int alc268_parse_auto_config(struct hda_codec *codec)
11950{
11951 struct alc_spec *spec = codec->spec;
11952 int err;
11953 static hda_nid_t alc268_ignore[] = { 0 };
11954
11955 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11956 alc268_ignore);
11957 if (err < 0)
11958 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010011959 if (!spec->autocfg.line_outs) {
11960 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
11961 spec->multiout.max_channels = 2;
11962 spec->no_analog = 1;
11963 goto dig_only;
11964 }
Kailang Yanga361d842007-06-05 12:30:55 +020011965 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010011966 }
Kailang Yanga361d842007-06-05 12:30:55 +020011967 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
11968 if (err < 0)
11969 return err;
11970 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
11971 if (err < 0)
11972 return err;
11973
11974 spec->multiout.max_channels = 2;
11975
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010011976 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020011977 /* digital only support output */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010011978 if (spec->autocfg.dig_outs) {
Kailang Yanga361d842007-06-05 12:30:55 +020011979 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010011980 spec->dig_out_type = spec->autocfg.dig_out_type[0];
11981 }
Takashi Iwai603c4012008-07-30 15:01:44 +020011982 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011983 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020011984
Takashi Iwai892981f2009-03-02 08:04:35 +010011985 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011986 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011987
Takashi Iwaid88897e2008-10-31 15:01:37 +010011988 add_verb(spec, alc268_volume_init_verbs);
Kailang Yanga361d842007-06-05 12:30:55 +020011989 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011990 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020011991
Takashi Iwai776e1842007-08-29 15:07:11 +020011992 err = alc_auto_add_mic_boost(codec);
11993 if (err < 0)
11994 return err;
11995
Kailang Yanga361d842007-06-05 12:30:55 +020011996 return 1;
11997}
11998
11999#define alc268_auto_init_multi_out alc882_auto_init_multi_out
12000#define alc268_auto_init_hp_out alc882_auto_init_hp_out
12001#define alc268_auto_init_analog_input alc882_auto_init_analog_input
12002
12003/* init callback for auto-configuration model -- overriding the default init */
12004static void alc268_auto_init(struct hda_codec *codec)
12005{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012006 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020012007 alc268_auto_init_multi_out(codec);
12008 alc268_auto_init_hp_out(codec);
12009 alc268_auto_init_mono_speaker_out(codec);
12010 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012011 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012012 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020012013}
12014
12015/*
12016 * configuration and preset
12017 */
12018static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012019 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020012020 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012021 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020012022 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012023 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020012024 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012025 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012026 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012027#ifdef CONFIG_SND_DEBUG
12028 [ALC268_TEST] = "test",
12029#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012030 [ALC268_AUTO] = "auto",
12031};
12032
12033static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020012034 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012035 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010012036 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012037 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010012038 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020012039 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
12040 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012041 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Takashi Iwai57d13922009-01-08 15:52:09 +010012042 SND_PCI_QUIRK(0x1028, 0x02b0, "Dell Inspiron Mini9", ALC268_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012043 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
Kailang Yanga361d842007-06-05 12:30:55 +020012044 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Kailang Yangd1a991a2007-08-15 16:21:59 +020012045 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
Takashi Iwai8e7f00f2007-09-07 10:58:58 +020012046 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
Travis Place2346d0c2008-09-01 08:24:00 +020012047 SND_PCI_QUIRK(0x1179, 0xff64, "TOSHIBA L305", ALC268_TOSHIBA),
Tony Vroon378bd6a2008-06-04 12:08:30 +020012048 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020012049 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012050 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012051 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Kailang Yanga361d842007-06-05 12:30:55 +020012052 {}
12053};
12054
12055static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012056 [ALC267_QUANTA_IL1] = {
Takashi Iwai22971e32009-02-10 11:56:44 +010012057 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012058 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12059 alc267_quanta_il1_verbs },
12060 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12061 .dac_nids = alc268_dac_nids,
12062 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12063 .adc_nids = alc268_adc_nids_alt,
12064 .hp_nid = 0x03,
12065 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12066 .channel_mode = alc268_modes,
12067 .input_mux = &alc268_capture_source,
12068 .unsol_event = alc267_quanta_il1_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012069 .init_hook = alc267_quanta_il1_init_hook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012070 },
Kailang Yanga361d842007-06-05 12:30:55 +020012071 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012072 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12073 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020012074 .init_verbs = { alc268_base_init_verbs },
12075 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12076 .dac_nids = alc268_dac_nids,
12077 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12078 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012079 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020012080 .hp_nid = 0x03,
12081 .dig_out_nid = ALC268_DIGOUT_NID,
12082 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12083 .channel_mode = alc268_modes,
12084 .input_mux = &alc268_capture_source,
12085 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012086 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012087 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012088 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012089 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12090 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012091 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12092 .dac_nids = alc268_dac_nids,
12093 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12094 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012095 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012096 .hp_nid = 0x03,
12097 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12098 .channel_mode = alc268_modes,
12099 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012100 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020012101 .init_hook = alc268_toshiba_init_hook,
Takashi Iwaid2738092007-08-16 14:59:45 +020012102 },
12103 [ALC268_ACER] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012104 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
12105 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012106 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12107 alc268_acer_verbs },
12108 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12109 .dac_nids = alc268_dac_nids,
12110 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12111 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012112 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020012113 .hp_nid = 0x02,
12114 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12115 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012116 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012117 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020012118 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012119 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012120 [ALC268_ACER_DMIC] = {
12121 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
12122 alc268_beep_mixer },
12123 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12124 alc268_acer_verbs },
12125 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12126 .dac_nids = alc268_dac_nids,
12127 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12128 .adc_nids = alc268_adc_nids_alt,
12129 .capsrc_nids = alc268_capsrc_nids,
12130 .hp_nid = 0x02,
12131 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12132 .channel_mode = alc268_modes,
12133 .input_mux = &alc268_acer_dmic_capture_source,
12134 .unsol_event = alc268_acer_unsol_event,
12135 .init_hook = alc268_acer_init_hook,
12136 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012137 [ALC268_ACER_ASPIRE_ONE] = {
12138 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010012139 alc268_beep_mixer,
12140 alc268_capture_alt_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012141 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12142 alc268_acer_aspire_one_verbs },
12143 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12144 .dac_nids = alc268_dac_nids,
12145 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12146 .adc_nids = alc268_adc_nids_alt,
12147 .capsrc_nids = alc268_capsrc_nids,
12148 .hp_nid = 0x03,
12149 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12150 .channel_mode = alc268_modes,
12151 .input_mux = &alc268_acer_lc_capture_source,
12152 .unsol_event = alc268_acer_lc_unsol_event,
12153 .init_hook = alc268_acer_lc_init_hook,
12154 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012155 [ALC268_DELL] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012156 .mixers = { alc268_dell_mixer, alc268_beep_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012157 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12158 alc268_dell_verbs },
12159 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12160 .dac_nids = alc268_dac_nids,
12161 .hp_nid = 0x02,
12162 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12163 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012164 .unsol_event = alc_sku_unsol_event,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012165 .init_hook = alc268_dell_init_hook,
12166 .input_mux = &alc268_capture_source,
12167 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012168 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012169 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12170 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012171 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12172 alc268_toshiba_verbs },
12173 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12174 .dac_nids = alc268_dac_nids,
12175 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12176 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012177 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012178 .hp_nid = 0x03,
12179 .dig_out_nid = ALC268_DIGOUT_NID,
12180 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12181 .channel_mode = alc268_modes,
12182 .input_mux = &alc268_capture_source,
12183 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020012184 .init_hook = alc268_toshiba_init_hook
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012185 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012186#ifdef CONFIG_SND_DEBUG
12187 [ALC268_TEST] = {
12188 .mixers = { alc268_test_mixer, alc268_capture_mixer },
12189 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12190 alc268_volume_init_verbs },
12191 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12192 .dac_nids = alc268_dac_nids,
12193 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12194 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012195 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012196 .hp_nid = 0x03,
12197 .dig_out_nid = ALC268_DIGOUT_NID,
12198 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12199 .channel_mode = alc268_modes,
12200 .input_mux = &alc268_capture_source,
12201 },
12202#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012203};
12204
12205static int patch_alc268(struct hda_codec *codec)
12206{
12207 struct alc_spec *spec;
12208 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010012209 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020012210
12211 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
12212 if (spec == NULL)
12213 return -ENOMEM;
12214
12215 codec->spec = spec;
12216
12217 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
12218 alc268_models,
12219 alc268_cfg_tbl);
12220
12221 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020012222 printk(KERN_INFO "hda_codec: Unknown model for %s, "
12223 "trying auto-probe from BIOS...\n", codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020012224 board_config = ALC268_AUTO;
12225 }
12226
12227 if (board_config == ALC268_AUTO) {
12228 /* automatic parse from the BIOS config */
12229 err = alc268_parse_auto_config(codec);
12230 if (err < 0) {
12231 alc_free(codec);
12232 return err;
12233 } else if (!err) {
12234 printk(KERN_INFO
12235 "hda_codec: Cannot set up configuration "
12236 "from BIOS. Using base mode...\n");
12237 board_config = ALC268_3ST;
12238 }
12239 }
12240
12241 if (board_config != ALC268_AUTO)
12242 setup_preset(spec, &alc268_presets[board_config]);
12243
Kailang Yanga361d842007-06-05 12:30:55 +020012244 spec->stream_analog_playback = &alc268_pcm_analog_playback;
12245 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010012246 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020012247
Kailang Yanga361d842007-06-05 12:30:55 +020012248 spec->stream_digital_playback = &alc268_pcm_digital_playback;
12249
Takashi Iwai22971e32009-02-10 11:56:44 +010012250 has_beep = 0;
12251 for (i = 0; i < spec->num_mixers; i++) {
12252 if (spec->mixers[i] == alc268_beep_mixer) {
12253 has_beep = 1;
12254 break;
12255 }
12256 }
12257
12258 if (has_beep) {
12259 err = snd_hda_attach_beep_device(codec, 0x1);
12260 if (err < 0) {
12261 alc_free(codec);
12262 return err;
12263 }
12264 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
12265 /* override the amp caps for beep generator */
12266 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012267 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
12268 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
12269 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
12270 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010012271 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012272
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012273 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012274 /* check whether NID 0x07 is valid */
12275 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010012276 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020012277
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012278 /* get type */
12279 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwai67ebcb02008-02-19 15:03:57 +010012280 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012281 spec->adc_nids = alc268_adc_nids_alt;
12282 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012283 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012284 } else {
12285 spec->adc_nids = alc268_adc_nids;
12286 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012287 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020012288 }
Takashi Iwaie1406342008-02-11 18:32:32 +010012289 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai85860c02008-02-19 15:00:15 +010012290 /* set default input source */
12291 for (i = 0; i < spec->num_adc_nids; i++)
12292 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
12293 0, AC_VERB_SET_CONNECT_SEL,
12294 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020012295 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010012296
12297 spec->vmaster_nid = 0x02;
12298
Kailang Yanga361d842007-06-05 12:30:55 +020012299 codec->patch_ops = alc_patch_ops;
12300 if (board_config == ALC268_AUTO)
12301 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020012302
Takashi Iwaidaead532008-11-28 12:55:36 +010012303 codec->proc_widget_hook = print_realtek_coef;
12304
Kailang Yanga361d842007-06-05 12:30:55 +020012305 return 0;
12306}
12307
12308/*
Kailang Yangf6a92242007-12-13 16:52:54 +010012309 * ALC269 channel source setting (2 channel)
12310 */
12311#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
12312
12313#define alc269_dac_nids alc260_dac_nids
12314
12315static hda_nid_t alc269_adc_nids[1] = {
12316 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020012317 0x08,
12318};
12319
Takashi Iwaie01bf502008-08-21 16:25:07 +020012320static hda_nid_t alc269_capsrc_nids[1] = {
12321 0x23,
12322};
12323
12324/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
12325 * not a mux!
12326 */
12327
Kailang Yangf53281e2008-07-18 12:36:43 +020012328static struct hda_input_mux alc269_eeepc_dmic_capture_source = {
12329 .num_items = 2,
12330 .items = {
12331 { "i-Mic", 0x5 },
12332 { "e-Mic", 0x0 },
12333 },
12334};
12335
12336static struct hda_input_mux alc269_eeepc_amic_capture_source = {
12337 .num_items = 2,
12338 .items = {
12339 { "i-Mic", 0x1 },
12340 { "e-Mic", 0x0 },
12341 },
Kailang Yangf6a92242007-12-13 16:52:54 +010012342};
12343
12344#define alc269_modes alc260_modes
12345#define alc269_capture_source alc880_lg_lw_capture_source
12346
12347static struct snd_kcontrol_new alc269_base_mixer[] = {
12348 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12349 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12350 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12351 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12352 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12353 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12354 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12355 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12356 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12357 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12358 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12359 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
12360 { } /* end */
12361};
12362
Kailang Yang60db6b52008-08-26 13:13:00 +020012363static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
12364 /* output mixer control */
12365 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12366 {
12367 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12368 .name = "Master Playback Switch",
12369 .info = snd_hda_mixer_amp_switch_info,
12370 .get = snd_hda_mixer_amp_switch_get,
12371 .put = alc268_acer_master_sw_put,
12372 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12373 },
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("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12378 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12379 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020012380 { }
12381};
12382
Tony Vroon64154832008-11-06 15:08:49 +000012383static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
12384 /* output mixer control */
12385 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12386 {
12387 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12388 .name = "Master Playback Switch",
12389 .info = snd_hda_mixer_amp_switch_info,
12390 .get = snd_hda_mixer_amp_switch_get,
12391 .put = alc268_acer_master_sw_put,
12392 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12393 },
12394 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12395 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12396 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12397 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12398 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12399 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12400 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
12401 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
12402 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000012403 { }
12404};
12405
Kailang Yangf53281e2008-07-18 12:36:43 +020012406/* bind volumes of both NID 0x0c and 0x0d */
12407static struct hda_bind_ctls alc269_epc_bind_vol = {
12408 .ops = &snd_hda_bind_vol,
12409 .values = {
12410 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
12411 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
12412 0
12413 },
12414};
12415
12416static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
12417 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12418 HDA_BIND_VOL("LineOut Playback Volume", &alc269_epc_bind_vol),
12419 HDA_CODEC_MUTE("LineOut Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12420 { } /* end */
12421};
12422
Kailang Yangf6a92242007-12-13 16:52:54 +010012423/* capture mixer elements */
Kailang Yangf53281e2008-07-18 12:36:43 +020012424static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
12425 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12426 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012427 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12428 { } /* end */
12429};
12430
12431/* FSC amilo */
12432static struct snd_kcontrol_new alc269_fujitsu_mixer[] = {
12433 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12434 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12435 HDA_BIND_VOL("PCM Playback Volume", &alc269_epc_bind_vol),
Kailang Yangf53281e2008-07-18 12:36:43 +020012436 { } /* end */
12437};
12438
Kailang Yang60db6b52008-08-26 13:13:00 +020012439static struct hda_verb alc269_quanta_fl1_verbs[] = {
12440 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12441 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12442 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12443 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12444 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12445 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12446 { }
12447};
12448
Tony Vroon64154832008-11-06 15:08:49 +000012449static struct hda_verb alc269_lifebook_verbs[] = {
12450 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12451 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
12452 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12453 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12454 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12455 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12456 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12457 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12458 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12459 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12460 { }
12461};
12462
Kailang Yang60db6b52008-08-26 13:13:00 +020012463/* toggle speaker-output according to the hp-jack state */
12464static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
12465{
12466 unsigned int present;
12467 unsigned char bits;
12468
12469 present = snd_hda_codec_read(codec, 0x15, 0,
12470 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12471 bits = present ? AMP_IN_MUTE(0) : 0;
12472 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12473 AMP_IN_MUTE(0), bits);
12474 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12475 AMP_IN_MUTE(0), bits);
12476
12477 snd_hda_codec_write(codec, 0x20, 0,
12478 AC_VERB_SET_COEF_INDEX, 0x0c);
12479 snd_hda_codec_write(codec, 0x20, 0,
12480 AC_VERB_SET_PROC_COEF, 0x680);
12481
12482 snd_hda_codec_write(codec, 0x20, 0,
12483 AC_VERB_SET_COEF_INDEX, 0x0c);
12484 snd_hda_codec_write(codec, 0x20, 0,
12485 AC_VERB_SET_PROC_COEF, 0x480);
12486}
12487
Tony Vroon64154832008-11-06 15:08:49 +000012488/* toggle speaker-output according to the hp-jacks state */
12489static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
12490{
12491 unsigned int present;
12492 unsigned char bits;
12493
12494 /* Check laptop headphone socket */
12495 present = snd_hda_codec_read(codec, 0x15, 0,
12496 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12497
12498 /* Check port replicator headphone socket */
12499 present |= snd_hda_codec_read(codec, 0x1a, 0,
12500 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12501
12502 bits = present ? AMP_IN_MUTE(0) : 0;
12503 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12504 AMP_IN_MUTE(0), bits);
12505 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12506 AMP_IN_MUTE(0), bits);
12507
12508 snd_hda_codec_write(codec, 0x20, 0,
12509 AC_VERB_SET_COEF_INDEX, 0x0c);
12510 snd_hda_codec_write(codec, 0x20, 0,
12511 AC_VERB_SET_PROC_COEF, 0x680);
12512
12513 snd_hda_codec_write(codec, 0x20, 0,
12514 AC_VERB_SET_COEF_INDEX, 0x0c);
12515 snd_hda_codec_write(codec, 0x20, 0,
12516 AC_VERB_SET_PROC_COEF, 0x480);
12517}
12518
Kailang Yang60db6b52008-08-26 13:13:00 +020012519static void alc269_quanta_fl1_mic_automute(struct hda_codec *codec)
12520{
12521 unsigned int present;
12522
12523 present = snd_hda_codec_read(codec, 0x18, 0,
12524 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12525 snd_hda_codec_write(codec, 0x23, 0,
12526 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x1);
12527}
12528
Tony Vroon64154832008-11-06 15:08:49 +000012529static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
12530{
12531 unsigned int present_laptop;
12532 unsigned int present_dock;
12533
12534 present_laptop = snd_hda_codec_read(codec, 0x18, 0,
12535 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12536
12537 present_dock = snd_hda_codec_read(codec, 0x1b, 0,
12538 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12539
12540 /* Laptop mic port overrides dock mic port, design decision */
12541 if (present_dock)
12542 snd_hda_codec_write(codec, 0x23, 0,
12543 AC_VERB_SET_CONNECT_SEL, 0x3);
12544 if (present_laptop)
12545 snd_hda_codec_write(codec, 0x23, 0,
12546 AC_VERB_SET_CONNECT_SEL, 0x0);
12547 if (!present_dock && !present_laptop)
12548 snd_hda_codec_write(codec, 0x23, 0,
12549 AC_VERB_SET_CONNECT_SEL, 0x1);
12550}
12551
Kailang Yang60db6b52008-08-26 13:13:00 +020012552static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
12553 unsigned int res)
12554{
12555 if ((res >> 26) == ALC880_HP_EVENT)
12556 alc269_quanta_fl1_speaker_automute(codec);
12557 if ((res >> 26) == ALC880_MIC_EVENT)
12558 alc269_quanta_fl1_mic_automute(codec);
12559}
12560
Tony Vroon64154832008-11-06 15:08:49 +000012561static void alc269_lifebook_unsol_event(struct hda_codec *codec,
12562 unsigned int res)
12563{
12564 if ((res >> 26) == ALC880_HP_EVENT)
12565 alc269_lifebook_speaker_automute(codec);
12566 if ((res >> 26) == ALC880_MIC_EVENT)
12567 alc269_lifebook_mic_autoswitch(codec);
12568}
12569
Kailang Yang60db6b52008-08-26 13:13:00 +020012570static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
12571{
12572 alc269_quanta_fl1_speaker_automute(codec);
12573 alc269_quanta_fl1_mic_automute(codec);
12574}
12575
Tony Vroon64154832008-11-06 15:08:49 +000012576static void alc269_lifebook_init_hook(struct hda_codec *codec)
12577{
12578 alc269_lifebook_speaker_automute(codec);
12579 alc269_lifebook_mic_autoswitch(codec);
12580}
12581
Kailang Yang60db6b52008-08-26 13:13:00 +020012582static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
12583 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12584 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
12585 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12586 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
12587 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12588 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12589 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12590 {}
12591};
12592
12593static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
12594 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12595 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
12596 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12597 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
12598 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12599 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12600 {}
12601};
12602
12603/* toggle speaker-output according to the hp-jack state */
12604static void alc269_speaker_automute(struct hda_codec *codec)
12605{
12606 unsigned int present;
12607 unsigned char bits;
12608
12609 present = snd_hda_codec_read(codec, 0x15, 0,
12610 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12611 bits = present ? AMP_IN_MUTE(0) : 0;
12612 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12613 AMP_IN_MUTE(0), bits);
12614 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12615 AMP_IN_MUTE(0), bits);
12616}
12617
12618static void alc269_eeepc_dmic_automute(struct hda_codec *codec)
12619{
12620 unsigned int present;
12621
12622 present = snd_hda_codec_read(codec, 0x18, 0,
12623 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12624 snd_hda_codec_write(codec, 0x23, 0,
12625 AC_VERB_SET_CONNECT_SEL, (present ? 0 : 5));
12626}
12627
12628static void alc269_eeepc_amic_automute(struct hda_codec *codec)
12629{
12630 unsigned int present;
12631
12632 present = snd_hda_codec_read(codec, 0x18, 0,
12633 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12634 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12635 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
12636 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12637 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
12638}
12639
12640/* unsolicited event for HP jack sensing */
12641static void alc269_eeepc_dmic_unsol_event(struct hda_codec *codec,
12642 unsigned int res)
12643{
12644 if ((res >> 26) == ALC880_HP_EVENT)
12645 alc269_speaker_automute(codec);
12646
12647 if ((res >> 26) == ALC880_MIC_EVENT)
12648 alc269_eeepc_dmic_automute(codec);
12649}
12650
12651static void alc269_eeepc_dmic_inithook(struct hda_codec *codec)
12652{
12653 alc269_speaker_automute(codec);
12654 alc269_eeepc_dmic_automute(codec);
12655}
12656
12657/* unsolicited event for HP jack sensing */
12658static void alc269_eeepc_amic_unsol_event(struct hda_codec *codec,
12659 unsigned int res)
12660{
12661 if ((res >> 26) == ALC880_HP_EVENT)
12662 alc269_speaker_automute(codec);
12663
12664 if ((res >> 26) == ALC880_MIC_EVENT)
12665 alc269_eeepc_amic_automute(codec);
12666}
12667
12668static void alc269_eeepc_amic_inithook(struct hda_codec *codec)
12669{
12670 alc269_speaker_automute(codec);
12671 alc269_eeepc_amic_automute(codec);
12672}
12673
Kailang Yangf6a92242007-12-13 16:52:54 +010012674/*
12675 * generic initialization of ADC, input mixers and output mixers
12676 */
12677static struct hda_verb alc269_init_verbs[] = {
12678 /*
12679 * Unmute ADC0 and set the default input to mic-in
12680 */
Kailang Yang60db6b52008-08-26 13:13:00 +020012681 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010012682
12683 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
12684 * analog-loopback mixer widget
12685 * Note: PASD motherboards uses the Line In 2 as the input for
12686 * front panel mic (mic 2)
12687 */
12688 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
12689 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12690 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12691 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12692 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12693 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12694
12695 /*
12696 * Set up output mixers (0x0c - 0x0e)
12697 */
12698 /* set vol=0 to output mixers */
12699 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12700 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12701
12702 /* set up input amps for analog loopback */
12703 /* Amp Indices: DAC = 0, mixer = 1 */
12704 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12705 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12706 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12707 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12708 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12709 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12710
12711 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12712 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12713 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12714 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12715 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12716 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12717 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12718
12719 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12720 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12721 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12722 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12723 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12724 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12725 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12726
12727 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
12728 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12729
12730 /* FIXME: use matrix-type input source selection */
12731 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
12732 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang60db6b52008-08-26 13:13:00 +020012733 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12734 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangf6a92242007-12-13 16:52:54 +010012735 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12736 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12737
12738 /* set EAPD */
12739 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12740 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12741 { }
12742};
12743
12744/* add playback controls from the parsed DAC table */
12745static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
12746 const struct auto_pin_cfg *cfg)
12747{
12748 hda_nid_t nid;
12749 int err;
12750
12751 spec->multiout.num_dacs = 1; /* only use one dac */
12752 spec->multiout.dac_nids = spec->private_dac_nids;
12753 spec->multiout.dac_nids[0] = 2;
12754
12755 nid = cfg->line_out_pins[0];
12756 if (nid) {
12757 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12758 "Front Playback Volume",
12759 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
12760 if (err < 0)
12761 return err;
12762 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12763 "Front Playback Switch",
12764 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
12765 if (err < 0)
12766 return err;
12767 }
12768
12769 nid = cfg->speaker_pins[0];
12770 if (nid) {
12771 if (!cfg->line_out_pins[0]) {
12772 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12773 "Speaker Playback Volume",
12774 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12775 HDA_OUTPUT));
12776 if (err < 0)
12777 return err;
12778 }
12779 if (nid == 0x16) {
12780 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12781 "Speaker Playback Switch",
12782 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12783 HDA_OUTPUT));
12784 if (err < 0)
12785 return err;
12786 } else {
12787 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12788 "Speaker Playback Switch",
12789 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12790 HDA_OUTPUT));
12791 if (err < 0)
12792 return err;
12793 }
12794 }
12795 nid = cfg->hp_pins[0];
12796 if (nid) {
12797 /* spec->multiout.hp_nid = 2; */
12798 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
12799 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12800 "Headphone Playback Volume",
12801 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12802 HDA_OUTPUT));
12803 if (err < 0)
12804 return err;
12805 }
12806 if (nid == 0x16) {
12807 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12808 "Headphone Playback Switch",
12809 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12810 HDA_OUTPUT));
12811 if (err < 0)
12812 return err;
12813 } else {
12814 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12815 "Headphone Playback Switch",
12816 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12817 HDA_OUTPUT));
12818 if (err < 0)
12819 return err;
12820 }
12821 }
12822 return 0;
12823}
12824
Takashi Iwaiee956e02008-10-31 17:16:31 +010012825static int alc269_auto_create_analog_input_ctls(struct alc_spec *spec,
12826 const struct auto_pin_cfg *cfg)
12827{
12828 int err;
12829
12830 err = alc880_auto_create_analog_input_ctls(spec, cfg);
12831 if (err < 0)
12832 return err;
12833 /* digital-mic input pin is excluded in alc880_auto_create..()
12834 * because it's under 0x18
12835 */
12836 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
12837 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012838 struct hda_input_mux *imux = &spec->private_imux[0];
Takashi Iwaiee956e02008-10-31 17:16:31 +010012839 imux->items[imux->num_items].label = "Int Mic";
12840 imux->items[imux->num_items].index = 0x05;
12841 imux->num_items++;
12842 }
12843 return 0;
12844}
Kailang Yangf6a92242007-12-13 16:52:54 +010012845
12846#ifdef CONFIG_SND_HDA_POWER_SAVE
12847#define alc269_loopbacks alc880_loopbacks
12848#endif
12849
12850/* pcm configuration: identiacal with ALC880 */
12851#define alc269_pcm_analog_playback alc880_pcm_analog_playback
12852#define alc269_pcm_analog_capture alc880_pcm_analog_capture
12853#define alc269_pcm_digital_playback alc880_pcm_digital_playback
12854#define alc269_pcm_digital_capture alc880_pcm_digital_capture
12855
Takashi Iwaif03d3112009-03-05 14:18:16 +010012856static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
12857 .substreams = 1,
12858 .channels_min = 2,
12859 .channels_max = 8,
12860 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
12861 /* NID is set in alc_build_pcms */
12862 .ops = {
12863 .open = alc880_playback_pcm_open,
12864 .prepare = alc880_playback_pcm_prepare,
12865 .cleanup = alc880_playback_pcm_cleanup
12866 },
12867};
12868
12869static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
12870 .substreams = 1,
12871 .channels_min = 2,
12872 .channels_max = 2,
12873 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
12874 /* NID is set in alc_build_pcms */
12875};
12876
Kailang Yangf6a92242007-12-13 16:52:54 +010012877/*
12878 * BIOS auto configuration
12879 */
12880static int alc269_parse_auto_config(struct hda_codec *codec)
12881{
12882 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010012883 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010012884 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
12885
12886 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12887 alc269_ignore);
12888 if (err < 0)
12889 return err;
12890
12891 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
12892 if (err < 0)
12893 return err;
12894 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
12895 if (err < 0)
12896 return err;
12897
12898 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12899
Takashi Iwai0852d7a2009-02-11 11:35:15 +010012900 if (spec->autocfg.dig_outs)
Kailang Yangf6a92242007-12-13 16:52:54 +010012901 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
12902
Takashi Iwai603c4012008-07-30 15:01:44 +020012903 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012904 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010012905
Takashi Iwaid88897e2008-10-31 15:01:37 +010012906 add_verb(spec, alc269_init_verbs);
Kailang Yangf6a92242007-12-13 16:52:54 +010012907 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012908 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie01bf502008-08-21 16:25:07 +020012909 /* set default input source */
12910 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
12911 0, AC_VERB_SET_CONNECT_SEL,
12912 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010012913
12914 err = alc_auto_add_mic_boost(codec);
12915 if (err < 0)
12916 return err;
12917
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012918 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012919 set_capture_mixer(spec);
Kailang Yangf53281e2008-07-18 12:36:43 +020012920
Kailang Yangf6a92242007-12-13 16:52:54 +010012921 return 1;
12922}
12923
12924#define alc269_auto_init_multi_out alc882_auto_init_multi_out
12925#define alc269_auto_init_hp_out alc882_auto_init_hp_out
12926#define alc269_auto_init_analog_input alc882_auto_init_analog_input
12927
12928
12929/* init callback for auto-configuration model -- overriding the default init */
12930static void alc269_auto_init(struct hda_codec *codec)
12931{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012932 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010012933 alc269_auto_init_multi_out(codec);
12934 alc269_auto_init_hp_out(codec);
12935 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012936 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012937 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010012938}
12939
12940/*
12941 * configuration and preset
12942 */
12943static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020012944 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020012945 [ALC269_QUANTA_FL1] = "quanta",
12946 [ALC269_ASUS_EEEPC_P703] = "eeepc-p703",
Takashi Iwai26f5df22008-11-03 17:39:46 +010012947 [ALC269_ASUS_EEEPC_P901] = "eeepc-p901",
Tony Vroon64154832008-11-06 15:08:49 +000012948 [ALC269_FUJITSU] = "fujitsu",
12949 [ALC269_LIFEBOOK] = "lifebook"
Kailang Yangf6a92242007-12-13 16:52:54 +010012950};
12951
12952static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020012953 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020012954 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
12955 ALC269_ASUS_EEEPC_P703),
Kailang Yang622e84c2009-04-21 07:39:04 +020012956 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_ASUS_EEEPC_P703),
12957 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_ASUS_EEEPC_P703),
12958 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_ASUS_EEEPC_P703),
12959 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_ASUS_EEEPC_P703),
12960 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_ASUS_EEEPC_P703),
12961 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_ASUS_EEEPC_P703),
Kailang Yangf53281e2008-07-18 12:36:43 +020012962 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
12963 ALC269_ASUS_EEEPC_P901),
Kailang Yang60db6b52008-08-26 13:13:00 +020012964 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
12965 ALC269_ASUS_EEEPC_P901),
Kailang Yang622e84c2009-04-21 07:39:04 +020012966 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_ASUS_EEEPC_P901),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012967 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
Tony Vroon64154832008-11-06 15:08:49 +000012968 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yangf6a92242007-12-13 16:52:54 +010012969 {}
12970};
12971
12972static struct alc_config_preset alc269_presets[] = {
12973 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012974 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010012975 .init_verbs = { alc269_init_verbs },
12976 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12977 .dac_nids = alc269_dac_nids,
12978 .hp_nid = 0x03,
12979 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12980 .channel_mode = alc269_modes,
12981 .input_mux = &alc269_capture_source,
12982 },
Kailang Yang60db6b52008-08-26 13:13:00 +020012983 [ALC269_QUANTA_FL1] = {
12984 .mixers = { alc269_quanta_fl1_mixer },
12985 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
12986 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12987 .dac_nids = alc269_dac_nids,
12988 .hp_nid = 0x03,
12989 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12990 .channel_mode = alc269_modes,
12991 .input_mux = &alc269_capture_source,
12992 .unsol_event = alc269_quanta_fl1_unsol_event,
12993 .init_hook = alc269_quanta_fl1_init_hook,
12994 },
Kailang Yangf53281e2008-07-18 12:36:43 +020012995 [ALC269_ASUS_EEEPC_P703] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012996 .mixers = { alc269_eeepc_mixer },
12997 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020012998 .init_verbs = { alc269_init_verbs,
12999 alc269_eeepc_amic_init_verbs },
13000 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13001 .dac_nids = alc269_dac_nids,
13002 .hp_nid = 0x03,
13003 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13004 .channel_mode = alc269_modes,
13005 .input_mux = &alc269_eeepc_amic_capture_source,
13006 .unsol_event = alc269_eeepc_amic_unsol_event,
13007 .init_hook = alc269_eeepc_amic_inithook,
13008 },
13009 [ALC269_ASUS_EEEPC_P901] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013010 .mixers = { alc269_eeepc_mixer },
13011 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013012 .init_verbs = { alc269_init_verbs,
13013 alc269_eeepc_dmic_init_verbs },
13014 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13015 .dac_nids = alc269_dac_nids,
13016 .hp_nid = 0x03,
13017 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13018 .channel_mode = alc269_modes,
13019 .input_mux = &alc269_eeepc_dmic_capture_source,
13020 .unsol_event = alc269_eeepc_dmic_unsol_event,
13021 .init_hook = alc269_eeepc_dmic_inithook,
13022 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013023 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013024 .mixers = { alc269_fujitsu_mixer },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013025 .cap_mixer = alc269_epc_capture_mixer,
13026 .init_verbs = { alc269_init_verbs,
13027 alc269_eeepc_dmic_init_verbs },
13028 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13029 .dac_nids = alc269_dac_nids,
13030 .hp_nid = 0x03,
13031 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13032 .channel_mode = alc269_modes,
13033 .input_mux = &alc269_eeepc_dmic_capture_source,
13034 .unsol_event = alc269_eeepc_dmic_unsol_event,
13035 .init_hook = alc269_eeepc_dmic_inithook,
13036 },
Tony Vroon64154832008-11-06 15:08:49 +000013037 [ALC269_LIFEBOOK] = {
13038 .mixers = { alc269_lifebook_mixer },
13039 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
13040 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13041 .dac_nids = alc269_dac_nids,
13042 .hp_nid = 0x03,
13043 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13044 .channel_mode = alc269_modes,
13045 .input_mux = &alc269_capture_source,
13046 .unsol_event = alc269_lifebook_unsol_event,
13047 .init_hook = alc269_lifebook_init_hook,
13048 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013049};
13050
13051static int patch_alc269(struct hda_codec *codec)
13052{
13053 struct alc_spec *spec;
13054 int board_config;
13055 int err;
13056
13057 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13058 if (spec == NULL)
13059 return -ENOMEM;
13060
13061 codec->spec = spec;
13062
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020013063 alc_fix_pll_init(codec, 0x20, 0x04, 15);
13064
Kailang Yangf6a92242007-12-13 16:52:54 +010013065 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
13066 alc269_models,
13067 alc269_cfg_tbl);
13068
13069 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020013070 printk(KERN_INFO "hda_codec: Unknown model for %s, "
13071 "trying auto-probe from BIOS...\n", codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010013072 board_config = ALC269_AUTO;
13073 }
13074
13075 if (board_config == ALC269_AUTO) {
13076 /* automatic parse from the BIOS config */
13077 err = alc269_parse_auto_config(codec);
13078 if (err < 0) {
13079 alc_free(codec);
13080 return err;
13081 } else if (!err) {
13082 printk(KERN_INFO
13083 "hda_codec: Cannot set up configuration "
13084 "from BIOS. Using base mode...\n");
13085 board_config = ALC269_BASIC;
13086 }
13087 }
13088
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090013089 err = snd_hda_attach_beep_device(codec, 0x1);
13090 if (err < 0) {
13091 alc_free(codec);
13092 return err;
13093 }
13094
Kailang Yangf6a92242007-12-13 16:52:54 +010013095 if (board_config != ALC269_AUTO)
13096 setup_preset(spec, &alc269_presets[board_config]);
13097
Takashi Iwaif03d3112009-03-05 14:18:16 +010013098 if (codec->subsystem_id == 0x17aa3bf8) {
13099 /* Due to a hardware problem on Lenovo Ideadpad, we need to
13100 * fix the sample rate of analog I/O to 44.1kHz
13101 */
13102 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
13103 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
13104 } else {
13105 spec->stream_analog_playback = &alc269_pcm_analog_playback;
13106 spec->stream_analog_capture = &alc269_pcm_analog_capture;
13107 }
Kailang Yangf6a92242007-12-13 16:52:54 +010013108 spec->stream_digital_playback = &alc269_pcm_digital_playback;
13109 spec->stream_digital_capture = &alc269_pcm_digital_capture;
13110
13111 spec->adc_nids = alc269_adc_nids;
13112 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
Takashi Iwaie01bf502008-08-21 16:25:07 +020013113 spec->capsrc_nids = alc269_capsrc_nids;
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013114 if (!spec->cap_mixer)
13115 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013116 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010013117
13118 codec->patch_ops = alc_patch_ops;
13119 if (board_config == ALC269_AUTO)
13120 spec->init_hook = alc269_auto_init;
13121#ifdef CONFIG_SND_HDA_POWER_SAVE
13122 if (!spec->loopback.amplist)
13123 spec->loopback.amplist = alc269_loopbacks;
13124#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010013125 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010013126
13127 return 0;
13128}
13129
13130/*
Kailang Yangdf694da2005-12-05 19:42:22 +010013131 * ALC861 channel source setting (2/6 channel selection for 3-stack)
13132 */
13133
13134/*
13135 * set the path ways for 2 channel output
13136 * need to set the codec line out and mic 1 pin widgets to inputs
13137 */
13138static struct hda_verb alc861_threestack_ch2_init[] = {
13139 /* set pin widget 1Ah (line in) for input */
13140 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013141 /* set pin widget 18h (mic1/2) for input, for mic also enable
13142 * the vref
13143 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013144 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13145
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013146 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13147#if 0
13148 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13149 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13150#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013151 { } /* end */
13152};
13153/*
13154 * 6ch mode
13155 * need to set the codec line out and mic 1 pin widgets to outputs
13156 */
13157static struct hda_verb alc861_threestack_ch6_init[] = {
13158 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13159 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13160 /* set pin widget 18h (mic1) for output (CLFE)*/
13161 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13162
13163 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013164 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013165
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013166 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13167#if 0
13168 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13169 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13170#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013171 { } /* end */
13172};
13173
13174static struct hda_channel_mode alc861_threestack_modes[2] = {
13175 { 2, alc861_threestack_ch2_init },
13176 { 6, alc861_threestack_ch6_init },
13177};
Takashi Iwai22309c32006-08-09 16:57:28 +020013178/* Set mic1 as input and unmute the mixer */
13179static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
13180 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13181 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13182 { } /* end */
13183};
13184/* Set mic1 as output and mute mixer */
13185static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
13186 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13187 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13188 { } /* end */
13189};
13190
13191static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
13192 { 2, alc861_uniwill_m31_ch2_init },
13193 { 4, alc861_uniwill_m31_ch4_init },
13194};
Kailang Yangdf694da2005-12-05 19:42:22 +010013195
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013196/* Set mic1 and line-in as input and unmute the mixer */
13197static struct hda_verb alc861_asus_ch2_init[] = {
13198 /* set pin widget 1Ah (line in) for input */
13199 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013200 /* set pin widget 18h (mic1/2) for input, for mic also enable
13201 * the vref
13202 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013203 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13204
13205 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13206#if 0
13207 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13208 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13209#endif
13210 { } /* end */
13211};
13212/* Set mic1 nad line-in as output and mute mixer */
13213static struct hda_verb alc861_asus_ch6_init[] = {
13214 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13215 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13216 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13217 /* set pin widget 18h (mic1) for output (CLFE)*/
13218 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13219 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13220 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
13221 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
13222
13223 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13224#if 0
13225 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13226 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13227#endif
13228 { } /* end */
13229};
13230
13231static struct hda_channel_mode alc861_asus_modes[2] = {
13232 { 2, alc861_asus_ch2_init },
13233 { 6, alc861_asus_ch6_init },
13234};
13235
Kailang Yangdf694da2005-12-05 19:42:22 +010013236/* patch-ALC861 */
13237
13238static struct snd_kcontrol_new alc861_base_mixer[] = {
13239 /* output mixer control */
13240 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13241 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13242 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13243 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13244 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13245
13246 /*Input mixer control */
13247 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13248 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13249 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13250 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13251 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13252 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13253 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13254 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13255 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13256 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013257
Kailang Yangdf694da2005-12-05 19:42:22 +010013258 { } /* end */
13259};
13260
13261static struct snd_kcontrol_new alc861_3ST_mixer[] = {
13262 /* output mixer control */
13263 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13264 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13265 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13266 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13267 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13268
13269 /* Input mixer control */
13270 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13271 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13272 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13273 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13274 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13275 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13276 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13277 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13278 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13279 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013280
Kailang Yangdf694da2005-12-05 19:42:22 +010013281 {
13282 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13283 .name = "Channel Mode",
13284 .info = alc_ch_mode_info,
13285 .get = alc_ch_mode_get,
13286 .put = alc_ch_mode_put,
13287 .private_value = ARRAY_SIZE(alc861_threestack_modes),
13288 },
13289 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013290};
13291
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013292static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013293 /* output mixer control */
13294 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13295 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13296 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020013297
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013298 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013299};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013300
Takashi Iwai22309c32006-08-09 16:57:28 +020013301static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
13302 /* output mixer control */
13303 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13304 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13305 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13306 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13307 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13308
13309 /* Input mixer control */
13310 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13311 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13312 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13313 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13314 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13315 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13316 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13317 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13318 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13319 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013320
Takashi Iwai22309c32006-08-09 16:57:28 +020013321 {
13322 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13323 .name = "Channel Mode",
13324 .info = alc_ch_mode_info,
13325 .get = alc_ch_mode_get,
13326 .put = alc_ch_mode_put,
13327 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
13328 },
13329 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013330};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013331
13332static struct snd_kcontrol_new alc861_asus_mixer[] = {
13333 /* output mixer control */
13334 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13335 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13336 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13337 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13338 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13339
13340 /* Input mixer control */
13341 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13342 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13343 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13344 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13345 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13346 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13347 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13348 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13349 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013350 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
13351
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013352 {
13353 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13354 .name = "Channel Mode",
13355 .info = alc_ch_mode_info,
13356 .get = alc_ch_mode_get,
13357 .put = alc_ch_mode_put,
13358 .private_value = ARRAY_SIZE(alc861_asus_modes),
13359 },
13360 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013361};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013362
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013363/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013364static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013365 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13366 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013367 { }
13368};
13369
Kailang Yangdf694da2005-12-05 19:42:22 +010013370/*
13371 * generic initialization of ADC, input mixers and output mixers
13372 */
13373static struct hda_verb alc861_base_init_verbs[] = {
13374 /*
13375 * Unmute ADC0 and set the default input to mic-in
13376 */
13377 /* port-A for surround (rear panel) */
13378 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13379 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
13380 /* port-B for mic-in (rear panel) with vref */
13381 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13382 /* port-C for line-in (rear panel) */
13383 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13384 /* port-D for Front */
13385 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13386 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13387 /* port-E for HP out (front panel) */
13388 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13389 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013390 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013391 /* port-F for mic-in (front panel) with vref */
13392 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13393 /* port-G for CLFE (rear panel) */
13394 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13395 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13396 /* port-H for side (rear panel) */
13397 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13398 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
13399 /* CD-in */
13400 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13401 /* route front mic to ADC1*/
13402 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13403 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013404
Kailang Yangdf694da2005-12-05 19:42:22 +010013405 /* Unmute DAC0~3 & spdif out*/
13406 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13407 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13408 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13409 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13410 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013411
Kailang Yangdf694da2005-12-05 19:42:22 +010013412 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13413 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13414 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13415 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13416 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013417
Kailang Yangdf694da2005-12-05 19:42:22 +010013418 /* Unmute Stereo Mixer 15 */
13419 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13420 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13421 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013422 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013423
13424 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13425 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13426 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13427 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13428 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13429 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13430 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13431 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013432 /* hp used DAC 3 (Front) */
13433 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013434 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13435
13436 { }
13437};
13438
13439static struct hda_verb alc861_threestack_init_verbs[] = {
13440 /*
13441 * Unmute ADC0 and set the default input to mic-in
13442 */
13443 /* port-A for surround (rear panel) */
13444 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13445 /* port-B for mic-in (rear panel) with vref */
13446 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13447 /* port-C for line-in (rear panel) */
13448 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13449 /* port-D for Front */
13450 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13451 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13452 /* port-E for HP out (front panel) */
13453 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13454 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013455 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013456 /* port-F for mic-in (front panel) with vref */
13457 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13458 /* port-G for CLFE (rear panel) */
13459 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13460 /* port-H for side (rear panel) */
13461 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13462 /* CD-in */
13463 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13464 /* route front mic to ADC1*/
13465 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13466 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13467 /* Unmute DAC0~3 & spdif out*/
13468 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13469 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13470 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13471 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13472 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013473
Kailang Yangdf694da2005-12-05 19:42:22 +010013474 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13475 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13476 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13477 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13478 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013479
Kailang Yangdf694da2005-12-05 19:42:22 +010013480 /* Unmute Stereo Mixer 15 */
13481 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13482 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13483 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013484 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013485
13486 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13487 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13488 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13489 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13490 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13491 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13492 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13493 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013494 /* hp used DAC 3 (Front) */
13495 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013496 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13497 { }
13498};
Takashi Iwai22309c32006-08-09 16:57:28 +020013499
13500static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
13501 /*
13502 * Unmute ADC0 and set the default input to mic-in
13503 */
13504 /* port-A for surround (rear panel) */
13505 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13506 /* port-B for mic-in (rear panel) with vref */
13507 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13508 /* port-C for line-in (rear panel) */
13509 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13510 /* port-D for Front */
13511 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13512 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13513 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013514 /* this has to be set to VREF80 */
13515 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013516 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013517 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013518 /* port-F for mic-in (front panel) with vref */
13519 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13520 /* port-G for CLFE (rear panel) */
13521 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13522 /* port-H for side (rear panel) */
13523 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13524 /* CD-in */
13525 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13526 /* route front mic to ADC1*/
13527 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13528 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13529 /* Unmute DAC0~3 & spdif out*/
13530 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13531 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13532 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13533 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13534 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013535
Takashi Iwai22309c32006-08-09 16:57:28 +020013536 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13537 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13538 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13539 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13540 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013541
Takashi Iwai22309c32006-08-09 16:57:28 +020013542 /* Unmute Stereo Mixer 15 */
13543 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13544 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13545 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013546 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020013547
13548 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13549 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13550 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13551 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13552 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13553 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13554 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13555 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013556 /* hp used DAC 3 (Front) */
13557 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020013558 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13559 { }
13560};
13561
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013562static struct hda_verb alc861_asus_init_verbs[] = {
13563 /*
13564 * Unmute ADC0 and set the default input to mic-in
13565 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013566 /* port-A for surround (rear panel)
13567 * according to codec#0 this is the HP jack
13568 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013569 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
13570 /* route front PCM to HP */
13571 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
13572 /* port-B for mic-in (rear panel) with vref */
13573 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13574 /* port-C for line-in (rear panel) */
13575 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13576 /* port-D for Front */
13577 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13578 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13579 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013580 /* this has to be set to VREF80 */
13581 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013582 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013583 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013584 /* port-F for mic-in (front panel) with vref */
13585 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13586 /* port-G for CLFE (rear panel) */
13587 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13588 /* port-H for side (rear panel) */
13589 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13590 /* CD-in */
13591 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13592 /* route front mic to ADC1*/
13593 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13594 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13595 /* Unmute DAC0~3 & spdif out*/
13596 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13597 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13598 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13599 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13600 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13601 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13602 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13603 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13604 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13605 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013606
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013607 /* Unmute Stereo Mixer 15 */
13608 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13609 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13610 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013611 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013612
13613 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13614 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13615 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13616 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13617 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13618 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13619 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13620 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013621 /* hp used DAC 3 (Front) */
13622 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013623 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13624 { }
13625};
13626
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013627/* additional init verbs for ASUS laptops */
13628static struct hda_verb alc861_asus_laptop_init_verbs[] = {
13629 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
13630 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
13631 { }
13632};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013633
Kailang Yangdf694da2005-12-05 19:42:22 +010013634/*
13635 * generic initialization of ADC, input mixers and output mixers
13636 */
13637static struct hda_verb alc861_auto_init_verbs[] = {
13638 /*
13639 * Unmute ADC0 and set the default input to mic-in
13640 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013641 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010013642 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013643
Kailang Yangdf694da2005-12-05 19:42:22 +010013644 /* Unmute DAC0~3 & spdif out*/
13645 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13646 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13647 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13648 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13649 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013650
Kailang Yangdf694da2005-12-05 19:42:22 +010013651 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13652 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13653 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13654 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13655 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013656
Kailang Yangdf694da2005-12-05 19:42:22 +010013657 /* Unmute Stereo Mixer 15 */
13658 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13659 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13660 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13661 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
13662
13663 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13664 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13665 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13666 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13667 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13668 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13669 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13670 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13671
13672 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13673 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013674 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13675 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013676 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13677 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013678 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13679 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013680
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013681 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013682
13683 { }
13684};
13685
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013686static struct hda_verb alc861_toshiba_init_verbs[] = {
13687 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013688
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013689 { }
13690};
13691
13692/* toggle speaker-output according to the hp-jack state */
13693static void alc861_toshiba_automute(struct hda_codec *codec)
13694{
13695 unsigned int present;
13696
13697 present = snd_hda_codec_read(codec, 0x0f, 0,
13698 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013699 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
13700 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
13701 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
13702 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013703}
13704
13705static void alc861_toshiba_unsol_event(struct hda_codec *codec,
13706 unsigned int res)
13707{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013708 if ((res >> 26) == ALC880_HP_EVENT)
13709 alc861_toshiba_automute(codec);
13710}
13711
Kailang Yangdf694da2005-12-05 19:42:22 +010013712/* pcm configuration: identiacal with ALC880 */
13713#define alc861_pcm_analog_playback alc880_pcm_analog_playback
13714#define alc861_pcm_analog_capture alc880_pcm_analog_capture
13715#define alc861_pcm_digital_playback alc880_pcm_digital_playback
13716#define alc861_pcm_digital_capture alc880_pcm_digital_capture
13717
13718
13719#define ALC861_DIGOUT_NID 0x07
13720
13721static struct hda_channel_mode alc861_8ch_modes[1] = {
13722 { 8, NULL }
13723};
13724
13725static hda_nid_t alc861_dac_nids[4] = {
13726 /* front, surround, clfe, side */
13727 0x03, 0x06, 0x05, 0x04
13728};
13729
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013730static hda_nid_t alc660_dac_nids[3] = {
13731 /* front, clfe, surround */
13732 0x03, 0x05, 0x06
13733};
13734
Kailang Yangdf694da2005-12-05 19:42:22 +010013735static hda_nid_t alc861_adc_nids[1] = {
13736 /* ADC0-2 */
13737 0x08,
13738};
13739
13740static struct hda_input_mux alc861_capture_source = {
13741 .num_items = 5,
13742 .items = {
13743 { "Mic", 0x0 },
13744 { "Front Mic", 0x3 },
13745 { "Line", 0x1 },
13746 { "CD", 0x4 },
13747 { "Mixer", 0x5 },
13748 },
13749};
13750
13751/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013752static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
13753 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010013754{
13755 int i;
13756 hda_nid_t nid;
13757
13758 spec->multiout.dac_nids = spec->private_dac_nids;
13759 for (i = 0; i < cfg->line_outs; i++) {
13760 nid = cfg->line_out_pins[i];
13761 if (nid) {
13762 if (i >= ARRAY_SIZE(alc861_dac_nids))
13763 continue;
13764 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
13765 }
13766 }
13767 spec->multiout.num_dacs = cfg->line_outs;
13768 return 0;
13769}
13770
13771/* add playback controls from the parsed DAC table */
13772static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
13773 const struct auto_pin_cfg *cfg)
13774{
13775 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013776 static const char *chname[4] = {
13777 "Front", "Surround", NULL /*CLFE*/, "Side"
13778 };
Kailang Yangdf694da2005-12-05 19:42:22 +010013779 hda_nid_t nid;
13780 int i, idx, err;
13781
13782 for (i = 0; i < cfg->line_outs; i++) {
13783 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013784 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010013785 continue;
13786 if (nid == 0x05) {
13787 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013788 err = add_control(spec, ALC_CTL_BIND_MUTE,
13789 "Center Playback Switch",
13790 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
13791 HDA_OUTPUT));
13792 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013793 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013794 err = add_control(spec, ALC_CTL_BIND_MUTE,
13795 "LFE Playback Switch",
13796 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13797 HDA_OUTPUT));
13798 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013799 return err;
13800 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013801 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
13802 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +010013803 if (nid == alc861_dac_nids[idx])
13804 break;
13805 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013806 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
13807 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13808 HDA_OUTPUT));
13809 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013810 return err;
13811 }
13812 }
13813 return 0;
13814}
13815
13816static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
13817{
13818 int err;
13819 hda_nid_t nid;
13820
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013821 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010013822 return 0;
13823
13824 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
13825 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013826 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13827 "Headphone Playback Switch",
13828 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
13829 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013830 return err;
13831 spec->multiout.hp_nid = nid;
13832 }
13833 return 0;
13834}
13835
13836/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013837static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
13838 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010013839{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013840 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010013841 int i, err, idx, idx1;
13842
13843 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013844 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010013845 case 0x0c:
13846 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013847 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013848 break;
13849 case 0x0f:
13850 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013851 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013852 break;
13853 case 0x0d:
13854 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013855 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013856 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013857 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010013858 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013859 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013860 break;
13861 case 0x11:
13862 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013863 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010013864 break;
13865 default:
13866 continue;
13867 }
13868
Takashi Iwai4a471b72005-12-07 13:56:29 +010013869 err = new_analog_input(spec, cfg->input_pins[i],
13870 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010013871 if (err < 0)
13872 return err;
13873
Takashi Iwai4a471b72005-12-07 13:56:29 +010013874 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010013875 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013876 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010013877 }
13878 return 0;
13879}
13880
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013881static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
13882 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +010013883 int pin_type, int dac_idx)
13884{
Jacek Luczak564c5be2008-05-03 18:41:23 +020013885 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
13886 pin_type);
13887 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13888 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +010013889}
13890
13891static void alc861_auto_init_multi_out(struct hda_codec *codec)
13892{
13893 struct alc_spec *spec = codec->spec;
13894 int i;
13895
13896 for (i = 0; i < spec->autocfg.line_outs; i++) {
13897 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013898 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010013899 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013900 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013901 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010013902 }
13903}
13904
13905static void alc861_auto_init_hp_out(struct hda_codec *codec)
13906{
13907 struct alc_spec *spec = codec->spec;
13908 hda_nid_t pin;
13909
Takashi Iwaieb06ed82006-09-20 17:10:27 +020013910 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010013911 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013912 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
13913 spec->multiout.dac_nids[0]);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013914 pin = spec->autocfg.speaker_pins[0];
13915 if (pin)
13916 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010013917}
13918
13919static void alc861_auto_init_analog_input(struct hda_codec *codec)
13920{
13921 struct alc_spec *spec = codec->spec;
13922 int i;
13923
13924 for (i = 0; i < AUTO_PIN_LAST; i++) {
13925 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai23f0c042009-02-26 13:03:58 +010013926 if (nid >= 0x0c && nid <= 0x11)
13927 alc_set_input_pin(codec, nid, i);
Kailang Yangdf694da2005-12-05 19:42:22 +010013928 }
13929}
13930
13931/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013932/* return 1 if successful, 0 if the proper config is not found,
13933 * or a negative error code
13934 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013935static int alc861_parse_auto_config(struct hda_codec *codec)
13936{
13937 struct alc_spec *spec = codec->spec;
13938 int err;
13939 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
13940
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013941 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13942 alc861_ignore);
13943 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013944 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013945 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010013946 return 0; /* can't find valid BIOS pin config */
13947
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013948 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
13949 if (err < 0)
13950 return err;
13951 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
13952 if (err < 0)
13953 return err;
13954 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
13955 if (err < 0)
13956 return err;
13957 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
13958 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013959 return err;
13960
13961 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13962
Takashi Iwai0852d7a2009-02-11 11:35:15 +010013963 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010013964 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
13965
Takashi Iwai603c4012008-07-30 15:01:44 +020013966 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013967 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010013968
Takashi Iwaid88897e2008-10-31 15:01:37 +010013969 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010013970
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020013971 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013972 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010013973
13974 spec->adc_nids = alc861_adc_nids;
13975 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013976 set_capture_mixer(spec);
Kailang Yangdf694da2005-12-05 19:42:22 +010013977
Takashi Iwai4a79ba32009-04-22 16:31:35 +020013978 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b);
13979
Kailang Yangdf694da2005-12-05 19:42:22 +010013980 return 1;
13981}
13982
Takashi Iwaiae6b8132006-03-03 16:47:17 +010013983/* additional initialization for auto-configuration model */
13984static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010013985{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013986 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010013987 alc861_auto_init_multi_out(codec);
13988 alc861_auto_init_hp_out(codec);
13989 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013990 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013991 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010013992}
13993
Takashi Iwaicb53c622007-08-10 17:21:45 +020013994#ifdef CONFIG_SND_HDA_POWER_SAVE
13995static struct hda_amp_list alc861_loopbacks[] = {
13996 { 0x15, HDA_INPUT, 0 },
13997 { 0x15, HDA_INPUT, 1 },
13998 { 0x15, HDA_INPUT, 2 },
13999 { 0x15, HDA_INPUT, 3 },
14000 { } /* end */
14001};
14002#endif
14003
Kailang Yangdf694da2005-12-05 19:42:22 +010014004
14005/*
14006 * configuration and preset
14007 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014008static const char *alc861_models[ALC861_MODEL_LAST] = {
14009 [ALC861_3ST] = "3stack",
14010 [ALC660_3ST] = "3stack-660",
14011 [ALC861_3ST_DIG] = "3stack-dig",
14012 [ALC861_6ST_DIG] = "6stack-dig",
14013 [ALC861_UNIWILL_M31] = "uniwill-m31",
14014 [ALC861_TOSHIBA] = "toshiba",
14015 [ALC861_ASUS] = "asus",
14016 [ALC861_ASUS_LAPTOP] = "asus-laptop",
14017 [ALC861_AUTO] = "auto",
14018};
14019
14020static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010014021 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014022 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14023 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14024 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014025 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020014026 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010014027 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020014028 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
14029 * Any other models that need this preset?
14030 */
14031 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020014032 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
14033 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014034 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
14035 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
14036 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
14037 /* FIXME: the below seems conflict */
14038 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
14039 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
14040 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010014041 {}
14042};
14043
14044static struct alc_config_preset alc861_presets[] = {
14045 [ALC861_3ST] = {
14046 .mixers = { alc861_3ST_mixer },
14047 .init_verbs = { alc861_threestack_init_verbs },
14048 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14049 .dac_nids = alc861_dac_nids,
14050 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14051 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014052 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014053 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14054 .adc_nids = alc861_adc_nids,
14055 .input_mux = &alc861_capture_source,
14056 },
14057 [ALC861_3ST_DIG] = {
14058 .mixers = { alc861_base_mixer },
14059 .init_verbs = { alc861_threestack_init_verbs },
14060 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14061 .dac_nids = alc861_dac_nids,
14062 .dig_out_nid = ALC861_DIGOUT_NID,
14063 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14064 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014065 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014066 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14067 .adc_nids = alc861_adc_nids,
14068 .input_mux = &alc861_capture_source,
14069 },
14070 [ALC861_6ST_DIG] = {
14071 .mixers = { alc861_base_mixer },
14072 .init_verbs = { alc861_base_init_verbs },
14073 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14074 .dac_nids = alc861_dac_nids,
14075 .dig_out_nid = ALC861_DIGOUT_NID,
14076 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
14077 .channel_mode = alc861_8ch_modes,
14078 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14079 .adc_nids = alc861_adc_nids,
14080 .input_mux = &alc861_capture_source,
14081 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014082 [ALC660_3ST] = {
14083 .mixers = { alc861_3ST_mixer },
14084 .init_verbs = { alc861_threestack_init_verbs },
14085 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
14086 .dac_nids = alc660_dac_nids,
14087 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14088 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014089 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014090 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14091 .adc_nids = alc861_adc_nids,
14092 .input_mux = &alc861_capture_source,
14093 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014094 [ALC861_UNIWILL_M31] = {
14095 .mixers = { alc861_uniwill_m31_mixer },
14096 .init_verbs = { alc861_uniwill_m31_init_verbs },
14097 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14098 .dac_nids = alc861_dac_nids,
14099 .dig_out_nid = ALC861_DIGOUT_NID,
14100 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
14101 .channel_mode = alc861_uniwill_m31_modes,
14102 .need_dac_fix = 1,
14103 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14104 .adc_nids = alc861_adc_nids,
14105 .input_mux = &alc861_capture_source,
14106 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014107 [ALC861_TOSHIBA] = {
14108 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014109 .init_verbs = { alc861_base_init_verbs,
14110 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014111 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14112 .dac_nids = alc861_dac_nids,
14113 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14114 .channel_mode = alc883_3ST_2ch_modes,
14115 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14116 .adc_nids = alc861_adc_nids,
14117 .input_mux = &alc861_capture_source,
14118 .unsol_event = alc861_toshiba_unsol_event,
14119 .init_hook = alc861_toshiba_automute,
14120 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014121 [ALC861_ASUS] = {
14122 .mixers = { alc861_asus_mixer },
14123 .init_verbs = { alc861_asus_init_verbs },
14124 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14125 .dac_nids = alc861_dac_nids,
14126 .dig_out_nid = ALC861_DIGOUT_NID,
14127 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
14128 .channel_mode = alc861_asus_modes,
14129 .need_dac_fix = 1,
14130 .hp_nid = 0x06,
14131 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14132 .adc_nids = alc861_adc_nids,
14133 .input_mux = &alc861_capture_source,
14134 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014135 [ALC861_ASUS_LAPTOP] = {
14136 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
14137 .init_verbs = { alc861_asus_init_verbs,
14138 alc861_asus_laptop_init_verbs },
14139 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14140 .dac_nids = alc861_dac_nids,
14141 .dig_out_nid = ALC861_DIGOUT_NID,
14142 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14143 .channel_mode = alc883_3ST_2ch_modes,
14144 .need_dac_fix = 1,
14145 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14146 .adc_nids = alc861_adc_nids,
14147 .input_mux = &alc861_capture_source,
14148 },
14149};
Kailang Yangdf694da2005-12-05 19:42:22 +010014150
14151
14152static int patch_alc861(struct hda_codec *codec)
14153{
14154 struct alc_spec *spec;
14155 int board_config;
14156 int err;
14157
Robert P. J. Daydc041e02006-12-19 14:44:15 +010014158 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010014159 if (spec == NULL)
14160 return -ENOMEM;
14161
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014162 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014163
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014164 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
14165 alc861_models,
14166 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014167
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014168 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020014169 printk(KERN_INFO "hda_codec: Unknown model for %s, "
14170 "trying auto-probe from BIOS...\n", codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010014171 board_config = ALC861_AUTO;
14172 }
14173
14174 if (board_config == ALC861_AUTO) {
14175 /* automatic parse from the BIOS config */
14176 err = alc861_parse_auto_config(codec);
14177 if (err < 0) {
14178 alc_free(codec);
14179 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014180 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014181 printk(KERN_INFO
14182 "hda_codec: Cannot set up configuration "
14183 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010014184 board_config = ALC861_3ST_DIG;
14185 }
14186 }
14187
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014188 err = snd_hda_attach_beep_device(codec, 0x23);
14189 if (err < 0) {
14190 alc_free(codec);
14191 return err;
14192 }
14193
Kailang Yangdf694da2005-12-05 19:42:22 +010014194 if (board_config != ALC861_AUTO)
14195 setup_preset(spec, &alc861_presets[board_config]);
14196
Kailang Yangdf694da2005-12-05 19:42:22 +010014197 spec->stream_analog_playback = &alc861_pcm_analog_playback;
14198 spec->stream_analog_capture = &alc861_pcm_analog_capture;
14199
Kailang Yangdf694da2005-12-05 19:42:22 +010014200 spec->stream_digital_playback = &alc861_pcm_digital_playback;
14201 spec->stream_digital_capture = &alc861_pcm_digital_capture;
14202
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014203 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
14204
Takashi Iwai2134ea42008-01-10 16:53:55 +010014205 spec->vmaster_nid = 0x03;
14206
Kailang Yangdf694da2005-12-05 19:42:22 +010014207 codec->patch_ops = alc_patch_ops;
14208 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014209 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014210#ifdef CONFIG_SND_HDA_POWER_SAVE
14211 if (!spec->loopback.amplist)
14212 spec->loopback.amplist = alc861_loopbacks;
14213#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010014214 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020014215
Kailang Yangdf694da2005-12-05 19:42:22 +010014216 return 0;
14217}
14218
14219/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014220 * ALC861-VD support
14221 *
14222 * Based on ALC882
14223 *
14224 * In addition, an independent DAC
14225 */
14226#define ALC861VD_DIGOUT_NID 0x06
14227
14228static hda_nid_t alc861vd_dac_nids[4] = {
14229 /* front, surr, clfe, side surr */
14230 0x02, 0x03, 0x04, 0x05
14231};
14232
14233/* dac_nids for ALC660vd are in a different order - according to
14234 * Realtek's driver.
14235 * This should probably tesult in a different mixer for 6stack models
14236 * of ALC660vd codecs, but for now there is only 3stack mixer
14237 * - and it is the same as in 861vd.
14238 * adc_nids in ALC660vd are (is) the same as in 861vd
14239 */
14240static hda_nid_t alc660vd_dac_nids[3] = {
14241 /* front, rear, clfe, rear_surr */
14242 0x02, 0x04, 0x03
14243};
14244
14245static hda_nid_t alc861vd_adc_nids[1] = {
14246 /* ADC0 */
14247 0x09,
14248};
14249
Takashi Iwaie1406342008-02-11 18:32:32 +010014250static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
14251
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014252/* input MUX */
14253/* FIXME: should be a matrix-type input source selection */
14254static struct hda_input_mux alc861vd_capture_source = {
14255 .num_items = 4,
14256 .items = {
14257 { "Mic", 0x0 },
14258 { "Front Mic", 0x1 },
14259 { "Line", 0x2 },
14260 { "CD", 0x4 },
14261 },
14262};
14263
Kailang Yang272a5272007-05-14 11:00:38 +020014264static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010014265 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020014266 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010014267 { "Ext Mic", 0x0 },
14268 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020014269 },
14270};
14271
Kailang Yangd1a991a2007-08-15 16:21:59 +020014272static struct hda_input_mux alc861vd_hp_capture_source = {
14273 .num_items = 2,
14274 .items = {
14275 { "Front Mic", 0x0 },
14276 { "ATAPI Mic", 0x1 },
14277 },
14278};
14279
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014280/*
14281 * 2ch mode
14282 */
14283static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
14284 { 2, NULL }
14285};
14286
14287/*
14288 * 6ch mode
14289 */
14290static struct hda_verb alc861vd_6stack_ch6_init[] = {
14291 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14292 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14293 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14294 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14295 { } /* end */
14296};
14297
14298/*
14299 * 8ch mode
14300 */
14301static struct hda_verb alc861vd_6stack_ch8_init[] = {
14302 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14303 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14304 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14305 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14306 { } /* end */
14307};
14308
14309static struct hda_channel_mode alc861vd_6stack_modes[2] = {
14310 { 6, alc861vd_6stack_ch6_init },
14311 { 8, alc861vd_6stack_ch8_init },
14312};
14313
14314static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
14315 {
14316 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14317 .name = "Channel Mode",
14318 .info = alc_ch_mode_info,
14319 .get = alc_ch_mode_get,
14320 .put = alc_ch_mode_put,
14321 },
14322 { } /* end */
14323};
14324
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014325/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
14326 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
14327 */
14328static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
14329 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14330 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14331
14332 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14333 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
14334
14335 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
14336 HDA_OUTPUT),
14337 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
14338 HDA_OUTPUT),
14339 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
14340 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
14341
14342 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
14343 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
14344
14345 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14346
14347 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14348 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14349 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14350
14351 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14352 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14353 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14354
14355 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14356 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14357
14358 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14359 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14360
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014361 { } /* end */
14362};
14363
14364static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
14365 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14366 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14367
14368 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14369
14370 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14371 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14372 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14373
14374 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14375 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14376 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14377
14378 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14379 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14380
14381 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14382 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14383
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014384 { } /* end */
14385};
14386
Kailang Yangbdd148a2007-05-08 15:19:08 +020014387static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
14388 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14389 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
14390 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14391
14392 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14393
14394 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14395 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14396 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14397
14398 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14399 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14400 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14401
14402 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14403 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14404
14405 { } /* end */
14406};
14407
Tobin Davisb419f342008-03-07 11:57:51 +010014408/* Pin assignment: Speaker=0x14, HP = 0x15,
14409 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020014410 */
14411static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010014412 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14413 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014414 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14415 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010014416 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
14417 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14418 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14419 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
14420 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14421 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014422 { } /* end */
14423};
14424
Kailang Yangd1a991a2007-08-15 16:21:59 +020014425/* Pin assignment: Speaker=0x14, Line-out = 0x15,
14426 * Front Mic=0x18, ATAPI Mic = 0x19,
14427 */
14428static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
14429 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14430 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14431 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14432 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
14433 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14434 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14435 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14436 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020014437
Kailang Yangd1a991a2007-08-15 16:21:59 +020014438 { } /* end */
14439};
14440
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014441/*
14442 * generic initialization of ADC, input mixers and output mixers
14443 */
14444static struct hda_verb alc861vd_volume_init_verbs[] = {
14445 /*
14446 * Unmute ADC0 and set the default input to mic-in
14447 */
14448 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14449 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14450
14451 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
14452 * the analog-loopback mixer widget
14453 */
14454 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020014455 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14456 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14457 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14458 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14459 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014460
14461 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020014462 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14463 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14464 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014465 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014466
14467 /*
14468 * Set up output mixers (0x02 - 0x05)
14469 */
14470 /* set vol=0 to output mixers */
14471 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14472 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14473 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14474 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14475
14476 /* set up input amps for analog loopback */
14477 /* Amp Indices: DAC = 0, mixer = 1 */
14478 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14479 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14480 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14481 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14482 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14483 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14484 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14485 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14486
14487 { }
14488};
14489
14490/*
14491 * 3-stack pin configuration:
14492 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
14493 */
14494static struct hda_verb alc861vd_3stack_init_verbs[] = {
14495 /*
14496 * Set pin mode and muting
14497 */
14498 /* set front pin widgets 0x14 for output */
14499 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14500 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14501 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14502
14503 /* Mic (rear) pin: input vref at 80% */
14504 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14505 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14506 /* Front Mic pin: input vref at 80% */
14507 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14508 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14509 /* Line In pin: input */
14510 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14511 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14512 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14513 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14514 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14515 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14516 /* CD pin widget for input */
14517 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14518
14519 { }
14520};
14521
14522/*
14523 * 6-stack pin configuration:
14524 */
14525static struct hda_verb alc861vd_6stack_init_verbs[] = {
14526 /*
14527 * Set pin mode and muting
14528 */
14529 /* set front pin widgets 0x14 for output */
14530 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14531 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14532 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14533
14534 /* Rear Pin: output 1 (0x0d) */
14535 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14536 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14537 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14538 /* CLFE Pin: output 2 (0x0e) */
14539 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14540 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14541 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
14542 /* Side Pin: output 3 (0x0f) */
14543 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14544 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14545 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
14546
14547 /* Mic (rear) pin: input vref at 80% */
14548 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14549 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14550 /* Front Mic pin: input vref at 80% */
14551 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14552 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14553 /* Line In pin: input */
14554 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14555 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14556 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14557 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14558 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14559 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14560 /* CD pin widget for input */
14561 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14562
14563 { }
14564};
14565
Kailang Yangbdd148a2007-05-08 15:19:08 +020014566static struct hda_verb alc861vd_eapd_verbs[] = {
14567 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14568 { }
14569};
14570
Kailang Yangf9423e72008-05-27 12:32:25 +020014571static struct hda_verb alc660vd_eapd_verbs[] = {
14572 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14573 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
14574 { }
14575};
14576
Kailang Yangbdd148a2007-05-08 15:19:08 +020014577static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
14578 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14579 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14580 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
14581 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020014582 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020014583 {}
14584};
14585
Kailang Yangbdd148a2007-05-08 15:19:08 +020014586static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
14587{
14588 unsigned int present;
14589 unsigned char bits;
14590
14591 present = snd_hda_codec_read(codec, 0x18, 0,
14592 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014593 bits = present ? HDA_AMP_MUTE : 0;
14594 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
14595 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014596}
14597
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014598static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020014599{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014600 struct alc_spec *spec = codec->spec;
14601
14602 spec->autocfg.hp_pins[0] = 0x1b;
14603 spec->autocfg.speaker_pins[0] = 0x14;
14604 alc_automute_amp(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014605 alc861vd_lenovo_mic_automute(codec);
14606}
14607
14608static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
14609 unsigned int res)
14610{
14611 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020014612 case ALC880_MIC_EVENT:
14613 alc861vd_lenovo_mic_automute(codec);
14614 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014615 default:
14616 alc_automute_amp_unsol_event(codec, res);
14617 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020014618 }
14619}
14620
Kailang Yang272a5272007-05-14 11:00:38 +020014621static struct hda_verb alc861vd_dallas_verbs[] = {
14622 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14623 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14624 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14625 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14626
14627 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14628 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14629 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14630 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14631 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14632 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14633 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14634 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014635
Kailang Yang272a5272007-05-14 11:00:38 +020014636 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14637 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14638 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14639 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14640 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14641 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14642 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14643 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14644
14645 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14646 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14647 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14648 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14649 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14650 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14651 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14652 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14653
14654 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14655 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14656 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14657 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
14658
14659 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014660 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020014661 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14662
14663 { } /* end */
14664};
14665
14666/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014667static void alc861vd_dallas_init_hook(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020014668{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014669 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020014670
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014671 spec->autocfg.hp_pins[0] = 0x15;
14672 spec->autocfg.speaker_pins[0] = 0x14;
14673 alc_automute_amp(codec);
Kailang Yang272a5272007-05-14 11:00:38 +020014674}
14675
Takashi Iwaicb53c622007-08-10 17:21:45 +020014676#ifdef CONFIG_SND_HDA_POWER_SAVE
14677#define alc861vd_loopbacks alc880_loopbacks
14678#endif
14679
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014680/* pcm configuration: identiacal with ALC880 */
14681#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
14682#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
14683#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
14684#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
14685
14686/*
14687 * configuration and preset
14688 */
14689static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
14690 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020014691 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010014692 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014693 [ALC861VD_3ST] = "3stack",
14694 [ALC861VD_3ST_DIG] = "3stack-digout",
14695 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020014696 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020014697 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020014698 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014699 [ALC861VD_AUTO] = "auto",
14700};
14701
14702static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014703 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
14704 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010014705 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014706 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Takashi Iwai13c94742008-11-05 08:06:08 +010014707 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020014708 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014709 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014710 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020014711 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Kailang Yang272a5272007-05-14 11:00:38 +020014712 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Takashi Iwai542d7c62007-08-16 18:57:30 +020014713 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010014714 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020014715 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010014716 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020014717 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014718 {}
14719};
14720
14721static struct alc_config_preset alc861vd_presets[] = {
14722 [ALC660VD_3ST] = {
14723 .mixers = { alc861vd_3st_mixer },
14724 .init_verbs = { alc861vd_volume_init_verbs,
14725 alc861vd_3stack_init_verbs },
14726 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14727 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014728 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14729 .channel_mode = alc861vd_3stack_2ch_modes,
14730 .input_mux = &alc861vd_capture_source,
14731 },
Mike Crash6963f842007-06-25 12:12:51 +020014732 [ALC660VD_3ST_DIG] = {
14733 .mixers = { alc861vd_3st_mixer },
14734 .init_verbs = { alc861vd_volume_init_verbs,
14735 alc861vd_3stack_init_verbs },
14736 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14737 .dac_nids = alc660vd_dac_nids,
14738 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020014739 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14740 .channel_mode = alc861vd_3stack_2ch_modes,
14741 .input_mux = &alc861vd_capture_source,
14742 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014743 [ALC861VD_3ST] = {
14744 .mixers = { alc861vd_3st_mixer },
14745 .init_verbs = { alc861vd_volume_init_verbs,
14746 alc861vd_3stack_init_verbs },
14747 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14748 .dac_nids = alc861vd_dac_nids,
14749 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14750 .channel_mode = alc861vd_3stack_2ch_modes,
14751 .input_mux = &alc861vd_capture_source,
14752 },
14753 [ALC861VD_3ST_DIG] = {
14754 .mixers = { alc861vd_3st_mixer },
14755 .init_verbs = { alc861vd_volume_init_verbs,
14756 alc861vd_3stack_init_verbs },
14757 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14758 .dac_nids = alc861vd_dac_nids,
14759 .dig_out_nid = ALC861VD_DIGOUT_NID,
14760 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14761 .channel_mode = alc861vd_3stack_2ch_modes,
14762 .input_mux = &alc861vd_capture_source,
14763 },
14764 [ALC861VD_6ST_DIG] = {
14765 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
14766 .init_verbs = { alc861vd_volume_init_verbs,
14767 alc861vd_6stack_init_verbs },
14768 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14769 .dac_nids = alc861vd_dac_nids,
14770 .dig_out_nid = ALC861VD_DIGOUT_NID,
14771 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
14772 .channel_mode = alc861vd_6stack_modes,
14773 .input_mux = &alc861vd_capture_source,
14774 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020014775 [ALC861VD_LENOVO] = {
14776 .mixers = { alc861vd_lenovo_mixer },
14777 .init_verbs = { alc861vd_volume_init_verbs,
14778 alc861vd_3stack_init_verbs,
14779 alc861vd_eapd_verbs,
14780 alc861vd_lenovo_unsol_verbs },
14781 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14782 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020014783 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14784 .channel_mode = alc861vd_3stack_2ch_modes,
14785 .input_mux = &alc861vd_capture_source,
14786 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014787 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020014788 },
Kailang Yang272a5272007-05-14 11:00:38 +020014789 [ALC861VD_DALLAS] = {
14790 .mixers = { alc861vd_dallas_mixer },
14791 .init_verbs = { alc861vd_dallas_verbs },
14792 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14793 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020014794 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14795 .channel_mode = alc861vd_3stack_2ch_modes,
14796 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014797 .unsol_event = alc_automute_amp_unsol_event,
14798 .init_hook = alc861vd_dallas_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014799 },
14800 [ALC861VD_HP] = {
14801 .mixers = { alc861vd_hp_mixer },
14802 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
14803 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14804 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014805 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014806 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14807 .channel_mode = alc861vd_3stack_2ch_modes,
14808 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014809 .unsol_event = alc_automute_amp_unsol_event,
14810 .init_hook = alc861vd_dallas_init_hook,
Kailang Yangea1fb292008-08-26 12:58:38 +020014811 },
Takashi Iwai13c94742008-11-05 08:06:08 +010014812 [ALC660VD_ASUS_V1S] = {
14813 .mixers = { alc861vd_lenovo_mixer },
14814 .init_verbs = { alc861vd_volume_init_verbs,
14815 alc861vd_3stack_init_verbs,
14816 alc861vd_eapd_verbs,
14817 alc861vd_lenovo_unsol_verbs },
14818 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14819 .dac_nids = alc660vd_dac_nids,
14820 .dig_out_nid = ALC861VD_DIGOUT_NID,
14821 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14822 .channel_mode = alc861vd_3stack_2ch_modes,
14823 .input_mux = &alc861vd_capture_source,
14824 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014825 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010014826 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014827};
14828
14829/*
14830 * BIOS auto configuration
14831 */
14832static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
14833 hda_nid_t nid, int pin_type, int dac_idx)
14834{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014835 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014836}
14837
14838static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
14839{
14840 struct alc_spec *spec = codec->spec;
14841 int i;
14842
14843 for (i = 0; i <= HDA_SIDE; i++) {
14844 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014845 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014846 if (nid)
14847 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014848 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014849 }
14850}
14851
14852
14853static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
14854{
14855 struct alc_spec *spec = codec->spec;
14856 hda_nid_t pin;
14857
14858 pin = spec->autocfg.hp_pins[0];
14859 if (pin) /* connect to front and use dac 0 */
14860 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014861 pin = spec->autocfg.speaker_pins[0];
14862 if (pin)
14863 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014864}
14865
14866#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
14867#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
14868
14869static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
14870{
14871 struct alc_spec *spec = codec->spec;
14872 int i;
14873
14874 for (i = 0; i < AUTO_PIN_LAST; i++) {
14875 hda_nid_t nid = spec->autocfg.input_pins[i];
14876 if (alc861vd_is_input_pin(nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010014877 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +010014878 if (nid != ALC861VD_PIN_CD_NID &&
14879 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014880 snd_hda_codec_write(codec, nid, 0,
14881 AC_VERB_SET_AMP_GAIN_MUTE,
14882 AMP_OUT_MUTE);
14883 }
14884 }
14885}
14886
Takashi Iwaif511b012008-08-15 16:46:42 +020014887#define alc861vd_auto_init_input_src alc882_auto_init_input_src
14888
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014889#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
14890#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
14891
14892/* add playback controls from the parsed DAC table */
14893/* Based on ALC880 version. But ALC861VD has separate,
14894 * different NIDs for mute/unmute switch and volume control */
14895static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
14896 const struct auto_pin_cfg *cfg)
14897{
14898 char name[32];
14899 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
14900 hda_nid_t nid_v, nid_s;
14901 int i, err;
14902
14903 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014904 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014905 continue;
14906 nid_v = alc861vd_idx_to_mixer_vol(
14907 alc880_dac_to_idx(
14908 spec->multiout.dac_nids[i]));
14909 nid_s = alc861vd_idx_to_mixer_switch(
14910 alc880_dac_to_idx(
14911 spec->multiout.dac_nids[i]));
14912
14913 if (i == 2) {
14914 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014915 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14916 "Center Playback Volume",
14917 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
14918 HDA_OUTPUT));
14919 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014920 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014921 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14922 "LFE Playback Volume",
14923 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
14924 HDA_OUTPUT));
14925 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014926 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014927 err = add_control(spec, ALC_CTL_BIND_MUTE,
14928 "Center Playback Switch",
14929 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
14930 HDA_INPUT));
14931 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014932 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014933 err = add_control(spec, ALC_CTL_BIND_MUTE,
14934 "LFE Playback Switch",
14935 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
14936 HDA_INPUT));
14937 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014938 return err;
14939 } else {
14940 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014941 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
14942 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
14943 HDA_OUTPUT));
14944 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014945 return err;
14946 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014947 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020014948 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014949 HDA_INPUT));
14950 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014951 return err;
14952 }
14953 }
14954 return 0;
14955}
14956
14957/* add playback controls for speaker and HP outputs */
14958/* Based on ALC880 version. But ALC861VD has separate,
14959 * different NIDs for mute/unmute switch and volume control */
14960static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
14961 hda_nid_t pin, const char *pfx)
14962{
14963 hda_nid_t nid_v, nid_s;
14964 int err;
14965 char name[32];
14966
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014967 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014968 return 0;
14969
14970 if (alc880_is_fixed_pin(pin)) {
14971 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
14972 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014973 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014974 spec->multiout.hp_nid = nid_v;
14975 else
14976 spec->multiout.extra_out_nid[0] = nid_v;
14977 /* control HP volume/switch on the output mixer amp */
14978 nid_v = alc861vd_idx_to_mixer_vol(
14979 alc880_fixed_pin_idx(pin));
14980 nid_s = alc861vd_idx_to_mixer_switch(
14981 alc880_fixed_pin_idx(pin));
14982
14983 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014984 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
14985 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
14986 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014987 return err;
14988 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014989 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
14990 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
14991 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014992 return err;
14993 } else if (alc880_is_multi_pin(pin)) {
14994 /* set manual connection */
14995 /* we have only a switch on HP-out PIN */
14996 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014997 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
14998 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
14999 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015000 return err;
15001 }
15002 return 0;
15003}
15004
15005/* parse the BIOS configuration and set up the alc_spec
15006 * return 1 if successful, 0 if the proper config is not found,
15007 * or a negative error code
15008 * Based on ALC880 version - had to change it to override
15009 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
15010static int alc861vd_parse_auto_config(struct hda_codec *codec)
15011{
15012 struct alc_spec *spec = codec->spec;
15013 int err;
15014 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
15015
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015016 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15017 alc861vd_ignore);
15018 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015019 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015020 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015021 return 0; /* can't find valid BIOS pin config */
15022
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015023 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
15024 if (err < 0)
15025 return err;
15026 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
15027 if (err < 0)
15028 return err;
15029 err = alc861vd_auto_create_extra_out(spec,
15030 spec->autocfg.speaker_pins[0],
15031 "Speaker");
15032 if (err < 0)
15033 return err;
15034 err = alc861vd_auto_create_extra_out(spec,
15035 spec->autocfg.hp_pins[0],
15036 "Headphone");
15037 if (err < 0)
15038 return err;
15039 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
15040 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015041 return err;
15042
15043 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15044
Takashi Iwai0852d7a2009-02-11 11:35:15 +010015045 if (spec->autocfg.dig_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015046 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
15047
Takashi Iwai603c4012008-07-30 15:01:44 +020015048 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010015049 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015050
Takashi Iwaid88897e2008-10-31 15:01:37 +010015051 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015052
15053 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015054 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015055
Takashi Iwai776e1842007-08-29 15:07:11 +020015056 err = alc_auto_add_mic_boost(codec);
15057 if (err < 0)
15058 return err;
15059
Takashi Iwai4a79ba32009-04-22 16:31:35 +020015060 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
15061
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015062 return 1;
15063}
15064
15065/* additional initialization for auto-configuration model */
15066static void alc861vd_auto_init(struct hda_codec *codec)
15067{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015068 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015069 alc861vd_auto_init_multi_out(codec);
15070 alc861vd_auto_init_hp_out(codec);
15071 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020015072 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015073 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020015074 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015075}
15076
15077static int patch_alc861vd(struct hda_codec *codec)
15078{
15079 struct alc_spec *spec;
15080 int err, board_config;
15081
15082 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15083 if (spec == NULL)
15084 return -ENOMEM;
15085
15086 codec->spec = spec;
15087
15088 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
15089 alc861vd_models,
15090 alc861vd_cfg_tbl);
15091
15092 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020015093 printk(KERN_INFO "hda_codec: Unknown model for %s, "
15094 "trying auto-probe from BIOS...\n", codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015095 board_config = ALC861VD_AUTO;
15096 }
15097
15098 if (board_config == ALC861VD_AUTO) {
15099 /* automatic parse from the BIOS config */
15100 err = alc861vd_parse_auto_config(codec);
15101 if (err < 0) {
15102 alc_free(codec);
15103 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015104 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015105 printk(KERN_INFO
15106 "hda_codec: Cannot set up configuration "
15107 "from BIOS. Using base mode...\n");
15108 board_config = ALC861VD_3ST;
15109 }
15110 }
15111
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015112 err = snd_hda_attach_beep_device(codec, 0x23);
15113 if (err < 0) {
15114 alc_free(codec);
15115 return err;
15116 }
15117
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015118 if (board_config != ALC861VD_AUTO)
15119 setup_preset(spec, &alc861vd_presets[board_config]);
15120
Kailang Yang2f893282008-05-27 12:14:47 +020015121 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020015122 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010015123 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020015124 }
15125
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015126 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
15127 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
15128
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015129 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
15130 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
15131
15132 spec->adc_nids = alc861vd_adc_nids;
15133 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +010015134 spec->capsrc_nids = alc861vd_capsrc_nids;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015135 spec->capture_style = CAPT_MIX;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015136
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015137 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015138 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015139
Takashi Iwai2134ea42008-01-10 16:53:55 +010015140 spec->vmaster_nid = 0x02;
15141
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015142 codec->patch_ops = alc_patch_ops;
15143
15144 if (board_config == ALC861VD_AUTO)
15145 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015146#ifdef CONFIG_SND_HDA_POWER_SAVE
15147 if (!spec->loopback.amplist)
15148 spec->loopback.amplist = alc861vd_loopbacks;
15149#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010015150 codec->proc_widget_hook = print_realtek_coef;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015151
15152 return 0;
15153}
15154
15155/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015156 * ALC662 support
15157 *
15158 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
15159 * configuration. Each pin widget can choose any input DACs and a mixer.
15160 * Each ADC is connected from a mixer of all inputs. This makes possible
15161 * 6-channel independent captures.
15162 *
15163 * In addition, an independent DAC for the multi-playback (not used in this
15164 * driver yet).
15165 */
15166#define ALC662_DIGOUT_NID 0x06
15167#define ALC662_DIGIN_NID 0x0a
15168
15169static hda_nid_t alc662_dac_nids[4] = {
15170 /* front, rear, clfe, rear_surr */
15171 0x02, 0x03, 0x04
15172};
15173
Kailang Yang622e84c2009-04-21 07:39:04 +020015174static hda_nid_t alc272_dac_nids[2] = {
15175 0x02, 0x03
15176};
15177
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015178static hda_nid_t alc662_adc_nids[1] = {
15179 /* ADC1-2 */
15180 0x09,
15181};
Takashi Iwaie1406342008-02-11 18:32:32 +010015182
Kailang Yang622e84c2009-04-21 07:39:04 +020015183static hda_nid_t alc272_adc_nids[1] = {
15184 /* ADC1-2 */
15185 0x08,
15186};
15187
Kailang Yang77a261b2008-02-19 11:38:05 +010015188static hda_nid_t alc662_capsrc_nids[1] = { 0x22 };
Kailang Yang622e84c2009-04-21 07:39:04 +020015189static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
15190
Takashi Iwaie1406342008-02-11 18:32:32 +010015191
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015192/* input MUX */
15193/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015194static struct hda_input_mux alc662_capture_source = {
15195 .num_items = 4,
15196 .items = {
15197 { "Mic", 0x0 },
15198 { "Front Mic", 0x1 },
15199 { "Line", 0x2 },
15200 { "CD", 0x4 },
15201 },
15202};
15203
15204static struct hda_input_mux alc662_lenovo_101e_capture_source = {
15205 .num_items = 2,
15206 .items = {
15207 { "Mic", 0x1 },
15208 { "Line", 0x2 },
15209 },
15210};
Kailang Yang291702f2007-10-16 14:28:03 +020015211
15212static struct hda_input_mux alc662_eeepc_capture_source = {
15213 .num_items = 2,
15214 .items = {
15215 { "i-Mic", 0x1 },
15216 { "e-Mic", 0x0 },
15217 },
15218};
15219
Kailang Yang6dda9f42008-05-27 12:05:31 +020015220static struct hda_input_mux alc663_capture_source = {
15221 .num_items = 3,
15222 .items = {
15223 { "Mic", 0x0 },
15224 { "Front Mic", 0x1 },
15225 { "Line", 0x2 },
15226 },
15227};
15228
15229static struct hda_input_mux alc663_m51va_capture_source = {
15230 .num_items = 2,
15231 .items = {
15232 { "Ext-Mic", 0x0 },
15233 { "D-Mic", 0x9 },
15234 },
15235};
15236
Chris Pockelé9541ba12009-05-12 08:08:53 +020015237#if 1 /* set to 0 for testing other input sources below */
15238static struct hda_input_mux alc272_nc10_capture_source = {
15239 .num_items = 2,
15240 .items = {
15241 { "Autoselect Mic", 0x0 },
15242 { "Internal Mic", 0x1 },
15243 },
15244};
15245#else
15246static struct hda_input_mux alc272_nc10_capture_source = {
15247 .num_items = 16,
15248 .items = {
15249 { "Autoselect Mic", 0x0 },
15250 { "Internal Mic", 0x1 },
15251 { "In-0x02", 0x2 },
15252 { "In-0x03", 0x3 },
15253 { "In-0x04", 0x4 },
15254 { "In-0x05", 0x5 },
15255 { "In-0x06", 0x6 },
15256 { "In-0x07", 0x7 },
15257 { "In-0x08", 0x8 },
15258 { "In-0x09", 0x9 },
15259 { "In-0x0a", 0x0a },
15260 { "In-0x0b", 0x0b },
15261 { "In-0x0c", 0x0c },
15262 { "In-0x0d", 0x0d },
15263 { "In-0x0e", 0x0e },
15264 { "In-0x0f", 0x0f },
15265 },
15266};
15267#endif
15268
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015269/*
15270 * 2ch mode
15271 */
15272static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
15273 { 2, NULL }
15274};
15275
15276/*
15277 * 2ch mode
15278 */
15279static struct hda_verb alc662_3ST_ch2_init[] = {
15280 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
15281 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15282 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
15283 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15284 { } /* end */
15285};
15286
15287/*
15288 * 6ch mode
15289 */
15290static struct hda_verb alc662_3ST_ch6_init[] = {
15291 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15292 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15293 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
15294 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15295 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15296 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
15297 { } /* end */
15298};
15299
15300static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
15301 { 2, alc662_3ST_ch2_init },
15302 { 6, alc662_3ST_ch6_init },
15303};
15304
15305/*
15306 * 2ch mode
15307 */
15308static struct hda_verb alc662_sixstack_ch6_init[] = {
15309 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15310 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15311 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15312 { } /* end */
15313};
15314
15315/*
15316 * 6ch mode
15317 */
15318static struct hda_verb alc662_sixstack_ch8_init[] = {
15319 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15320 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15321 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15322 { } /* end */
15323};
15324
15325static struct hda_channel_mode alc662_5stack_modes[2] = {
15326 { 2, alc662_sixstack_ch6_init },
15327 { 6, alc662_sixstack_ch8_init },
15328};
15329
15330/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15331 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15332 */
15333
15334static struct snd_kcontrol_new alc662_base_mixer[] = {
15335 /* output mixer control */
15336 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015337 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015338 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015339 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015340 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15341 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015342 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15343 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015344 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15345
15346 /*Input mixer control */
15347 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
15348 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
15349 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
15350 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
15351 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
15352 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
15353 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
15354 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015355 { } /* end */
15356};
15357
15358static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
15359 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015360 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015361 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15362 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15363 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15364 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15365 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15366 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15367 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15368 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15369 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015370 { } /* end */
15371};
15372
15373static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
15374 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015375 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015376 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015377 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015378 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15379 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015380 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15381 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015382 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15383 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15384 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15385 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15386 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15387 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15388 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15389 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15390 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015391 { } /* end */
15392};
15393
15394static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
15395 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15396 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010015397 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15398 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015399 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15400 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15401 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15402 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15403 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015404 { } /* end */
15405};
15406
Kailang Yang291702f2007-10-16 14:28:03 +020015407static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020015408 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15409 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020015410
15411 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
15412 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15413 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15414
15415 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
15416 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15417 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15418 { } /* end */
15419};
15420
Kailang Yang8c427222008-01-10 13:03:59 +010015421static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020015422 ALC262_HIPPO_MASTER_SWITCH,
15423 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015424 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015425 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15426 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015427 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
15428 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15429 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15430 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15431 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15432 { } /* end */
15433};
15434
Kailang Yangf1d4e282008-08-26 14:03:29 +020015435static struct hda_bind_ctls alc663_asus_bind_master_vol = {
15436 .ops = &snd_hda_bind_vol,
15437 .values = {
15438 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15439 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
15440 0
15441 },
15442};
15443
15444static struct hda_bind_ctls alc663_asus_one_bind_switch = {
15445 .ops = &snd_hda_bind_sw,
15446 .values = {
15447 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15448 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15449 0
15450 },
15451};
15452
Kailang Yang6dda9f42008-05-27 12:05:31 +020015453static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015454 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15455 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
15456 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15457 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15458 { } /* end */
15459};
15460
15461static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
15462 .ops = &snd_hda_bind_sw,
15463 .values = {
15464 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15465 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15466 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15467 0
15468 },
15469};
15470
15471static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
15472 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15473 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
15474 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15475 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15476 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15477 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15478
15479 { } /* end */
15480};
15481
15482static struct hda_bind_ctls alc663_asus_four_bind_switch = {
15483 .ops = &snd_hda_bind_sw,
15484 .values = {
15485 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15486 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15487 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
15488 0
15489 },
15490};
15491
15492static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
15493 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15494 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
15495 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15496 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15497 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15498 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15499 { } /* end */
15500};
15501
15502static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020015503 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15504 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015505 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15506 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15507 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15508 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15509 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15510 { } /* end */
15511};
15512
15513static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
15514 .ops = &snd_hda_bind_vol,
15515 .values = {
15516 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15517 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
15518 0
15519 },
15520};
15521
15522static struct hda_bind_ctls alc663_asus_two_bind_switch = {
15523 .ops = &snd_hda_bind_sw,
15524 .values = {
15525 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15526 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
15527 0
15528 },
15529};
15530
15531static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
15532 HDA_BIND_VOL("Master Playback Volume",
15533 &alc663_asus_two_bind_master_vol),
15534 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15535 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015536 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15537 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15538 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015539 { } /* end */
15540};
15541
15542static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
15543 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15544 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15545 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15546 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15547 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15548 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015549 { } /* end */
15550};
15551
15552static struct snd_kcontrol_new alc663_g71v_mixer[] = {
15553 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15554 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15555 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15556 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15557 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15558
15559 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15560 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15561 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15562 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15563 { } /* end */
15564};
15565
15566static struct snd_kcontrol_new alc663_g50v_mixer[] = {
15567 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15568 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15569 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15570
15571 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15572 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15573 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15574 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15575 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15576 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15577 { } /* end */
15578};
15579
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015580static struct snd_kcontrol_new alc662_chmode_mixer[] = {
15581 {
15582 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15583 .name = "Channel Mode",
15584 .info = alc_ch_mode_info,
15585 .get = alc_ch_mode_get,
15586 .put = alc_ch_mode_put,
15587 },
15588 { } /* end */
15589};
15590
15591static struct hda_verb alc662_init_verbs[] = {
15592 /* ADC: mute amp left and right */
15593 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15594 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15595 /* Front mixer: unmute input/output amp left and right (volume = 0) */
15596
Takashi Iwaicb53c622007-08-10 17:21:45 +020015597 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15598 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15599 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15600 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15601 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015602
Kailang Yangb60dd392007-09-20 12:50:29 +020015603 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15604 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15605 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15606 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15607 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15608 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015609
15610 /* Front Pin: output 0 (0x0c) */
15611 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15612 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15613
15614 /* Rear Pin: output 1 (0x0d) */
15615 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15616 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15617
15618 /* CLFE Pin: output 2 (0x0e) */
15619 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15620 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15621
15622 /* Mic (rear) pin: input vref at 80% */
15623 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15624 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15625 /* Front Mic pin: input vref at 80% */
15626 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15627 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15628 /* Line In pin: input */
15629 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15630 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15631 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15632 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15633 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15634 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15635 /* CD pin widget for input */
15636 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15637
15638 /* FIXME: use matrix-type input source selection */
15639 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15640 /* Input mixer */
15641 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020015642 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015643
15644 /* always trun on EAPD */
15645 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15646 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
15647
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015648 { }
15649};
15650
15651static struct hda_verb alc662_sue_init_verbs[] = {
15652 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15653 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020015654 {}
15655};
15656
15657static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
15658 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15659 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15660 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015661};
15662
Kailang Yang8c427222008-01-10 13:03:59 +010015663/* Set Unsolicited Event*/
15664static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
15665 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15666 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15667 {}
15668};
15669
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015670/*
15671 * generic initialization of ADC, input mixers and output mixers
15672 */
15673static struct hda_verb alc662_auto_init_verbs[] = {
15674 /*
15675 * Unmute ADC and set the default input to mic-in
15676 */
15677 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15678 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15679
15680 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
15681 * mixer widget
15682 * Note: PASD motherboards uses the Line In 2 as the input for front
15683 * panel mic (mic 2)
15684 */
15685 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020015686 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15687 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15688 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15689 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15690 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015691
15692 /*
15693 * Set up output mixers (0x0c - 0x0f)
15694 */
15695 /* set vol=0 to output mixers */
15696 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15697 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15698 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15699
15700 /* set up input amps for analog loopback */
15701 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020015702 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15703 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15704 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15705 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15706 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15707 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015708
15709
15710 /* FIXME: use matrix-type input source selection */
15711 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15712 /* Input mixer */
15713 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020015714 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015715 { }
15716};
15717
Takashi Iwai24fb9172008-09-02 14:48:20 +020015718/* additional verbs for ALC663 */
15719static struct hda_verb alc663_auto_init_verbs[] = {
15720 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15721 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15722 { }
15723};
15724
Kailang Yang6dda9f42008-05-27 12:05:31 +020015725static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015726 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15727 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015728 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15729 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020015730 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15731 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15732 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015733 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15734 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15735 {}
15736};
15737
Kailang Yangf1d4e282008-08-26 14:03:29 +020015738static struct hda_verb alc663_21jd_amic_init_verbs[] = {
15739 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15740 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15741 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15742 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15743 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15744 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15745 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15746 {}
15747};
15748
15749static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
15750 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15751 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15752 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15753 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15754 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15755 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15756 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15757 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15758 {}
15759};
15760
15761static struct hda_verb alc663_15jd_amic_init_verbs[] = {
15762 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15763 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15764 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15765 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15766 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15767 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15768 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15769 {}
15770};
15771
15772static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
15773 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15774 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15775 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15776 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15777 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15778 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15779 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15780 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15781 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15782 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15783 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15784 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15785 {}
15786};
15787
15788static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
15789 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15790 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15791 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15792 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15793 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15794 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15795 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15796 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15797 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15798 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15799 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15800 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15801 {}
15802};
15803
Kailang Yang6dda9f42008-05-27 12:05:31 +020015804static struct hda_verb alc663_g71v_init_verbs[] = {
15805 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15806 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
15807 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
15808
15809 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15810 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15811 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15812
15813 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15814 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
15815 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
15816 {}
15817};
15818
15819static struct hda_verb alc663_g50v_init_verbs[] = {
15820 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15821 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15822 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15823
15824 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15825 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15826 {}
15827};
15828
Kailang Yangf1d4e282008-08-26 14:03:29 +020015829static struct hda_verb alc662_ecs_init_verbs[] = {
15830 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
15831 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15832 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15833 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15834 {}
15835};
15836
Kailang Yang622e84c2009-04-21 07:39:04 +020015837static struct hda_verb alc272_dell_zm1_init_verbs[] = {
15838 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15839 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15840 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15841 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
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, 0x01}, /* Headphone */
15845 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15846 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
15847 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15848 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15849 {}
15850};
15851
15852static struct hda_verb alc272_dell_init_verbs[] = {
15853 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15854 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15855 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15856 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15857 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15858 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15859 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15860 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15861 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
15862 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15863 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15864 {}
15865};
15866
Kailang Yangf1d4e282008-08-26 14:03:29 +020015867static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
15868 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
15869 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
15870 { } /* end */
15871};
15872
Kailang Yang622e84c2009-04-21 07:39:04 +020015873static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
15874 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
15875 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
15876 { } /* end */
15877};
15878
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015879static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
15880{
15881 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015882 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015883
15884 present = snd_hda_codec_read(codec, 0x14, 0,
15885 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020015886 bits = present ? HDA_AMP_MUTE : 0;
15887 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15888 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015889}
15890
15891static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
15892{
15893 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015894 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015895
15896 present = snd_hda_codec_read(codec, 0x1b, 0,
15897 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020015898 bits = present ? HDA_AMP_MUTE : 0;
15899 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15900 HDA_AMP_MUTE, bits);
15901 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
15902 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015903}
15904
15905static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
15906 unsigned int res)
15907{
15908 if ((res >> 26) == ALC880_HP_EVENT)
15909 alc662_lenovo_101e_all_automute(codec);
15910 if ((res >> 26) == ALC880_FRONT_EVENT)
15911 alc662_lenovo_101e_ispeaker_automute(codec);
15912}
15913
Kailang Yang291702f2007-10-16 14:28:03 +020015914static void alc662_eeepc_mic_automute(struct hda_codec *codec)
15915{
15916 unsigned int present;
15917
15918 present = snd_hda_codec_read(codec, 0x18, 0,
15919 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
15920 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15921 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
15922 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15923 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
15924 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15925 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
15926 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15927 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
15928}
15929
15930/* unsolicited event for HP jack sensing */
15931static void alc662_eeepc_unsol_event(struct hda_codec *codec,
15932 unsigned int res)
15933{
Kailang Yang291702f2007-10-16 14:28:03 +020015934 if ((res >> 26) == ALC880_MIC_EVENT)
15935 alc662_eeepc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020015936 else
15937 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020015938}
15939
15940static void alc662_eeepc_inithook(struct hda_codec *codec)
15941{
Takashi Iwai42171c12009-05-08 14:11:43 +020015942 alc262_hippo1_init_hook(codec);
Kailang Yang291702f2007-10-16 14:28:03 +020015943 alc662_eeepc_mic_automute(codec);
15944}
15945
Kailang Yang8c427222008-01-10 13:03:59 +010015946static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
15947{
Takashi Iwai42171c12009-05-08 14:11:43 +020015948 struct alc_spec *spec = codec->spec;
15949
15950 spec->autocfg.hp_pins[0] = 0x14;
15951 spec->autocfg.speaker_pins[0] = 0x1b;
15952 alc262_hippo_master_update(codec);
Kailang Yang8c427222008-01-10 13:03:59 +010015953}
15954
Kailang Yang6dda9f42008-05-27 12:05:31 +020015955static void alc663_m51va_speaker_automute(struct hda_codec *codec)
15956{
15957 unsigned int present;
15958 unsigned char bits;
15959
15960 present = snd_hda_codec_read(codec, 0x21, 0,
Kailang Yangf1d4e282008-08-26 14:03:29 +020015961 AC_VERB_GET_PIN_SENSE, 0)
15962 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020015963 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020015964 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15965 AMP_IN_MUTE(0), bits);
15966 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15967 AMP_IN_MUTE(0), bits);
15968}
15969
15970static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
15971{
15972 unsigned int present;
15973 unsigned char bits;
15974
15975 present = snd_hda_codec_read(codec, 0x21, 0,
15976 AC_VERB_GET_PIN_SENSE, 0)
15977 & AC_PINSENSE_PRESENCE;
15978 bits = present ? HDA_AMP_MUTE : 0;
15979 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15980 AMP_IN_MUTE(0), bits);
15981 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15982 AMP_IN_MUTE(0), bits);
15983 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
15984 AMP_IN_MUTE(0), bits);
15985 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
15986 AMP_IN_MUTE(0), bits);
15987}
15988
15989static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
15990{
15991 unsigned int present;
15992 unsigned char bits;
15993
15994 present = snd_hda_codec_read(codec, 0x15, 0,
15995 AC_VERB_GET_PIN_SENSE, 0)
15996 & AC_PINSENSE_PRESENCE;
15997 bits = present ? HDA_AMP_MUTE : 0;
15998 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15999 AMP_IN_MUTE(0), bits);
16000 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16001 AMP_IN_MUTE(0), bits);
16002 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16003 AMP_IN_MUTE(0), bits);
16004 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16005 AMP_IN_MUTE(0), bits);
16006}
16007
16008static void alc662_f5z_speaker_automute(struct hda_codec *codec)
16009{
16010 unsigned int present;
16011 unsigned char bits;
16012
16013 present = snd_hda_codec_read(codec, 0x1b, 0,
16014 AC_VERB_GET_PIN_SENSE, 0)
16015 & AC_PINSENSE_PRESENCE;
16016 bits = present ? 0 : PIN_OUT;
16017 snd_hda_codec_write(codec, 0x14, 0,
16018 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
16019}
16020
16021static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
16022{
16023 unsigned int present1, present2;
16024
16025 present1 = snd_hda_codec_read(codec, 0x21, 0,
16026 AC_VERB_GET_PIN_SENSE, 0)
16027 & AC_PINSENSE_PRESENCE;
16028 present2 = snd_hda_codec_read(codec, 0x15, 0,
16029 AC_VERB_GET_PIN_SENSE, 0)
16030 & AC_PINSENSE_PRESENCE;
16031
16032 if (present1 || present2) {
16033 snd_hda_codec_write_cache(codec, 0x14, 0,
16034 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16035 } else {
16036 snd_hda_codec_write_cache(codec, 0x14, 0,
16037 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16038 }
16039}
16040
16041static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
16042{
16043 unsigned int present1, present2;
16044
16045 present1 = snd_hda_codec_read(codec, 0x1b, 0,
16046 AC_VERB_GET_PIN_SENSE, 0)
16047 & AC_PINSENSE_PRESENCE;
16048 present2 = snd_hda_codec_read(codec, 0x15, 0,
16049 AC_VERB_GET_PIN_SENSE, 0)
16050 & AC_PINSENSE_PRESENCE;
16051
16052 if (present1 || present2) {
16053 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16054 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16055 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16056 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16057 } else {
16058 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16059 AMP_IN_MUTE(0), 0);
16060 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16061 AMP_IN_MUTE(0), 0);
16062 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020016063}
16064
16065static void alc663_m51va_mic_automute(struct hda_codec *codec)
16066{
16067 unsigned int present;
16068
16069 present = snd_hda_codec_read(codec, 0x18, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020016070 AC_VERB_GET_PIN_SENSE, 0)
16071 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020016072 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016073 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016074 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016075 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016076 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016077 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016078 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016079 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016080}
16081
16082static void alc663_m51va_unsol_event(struct hda_codec *codec,
16083 unsigned int res)
16084{
16085 switch (res >> 26) {
16086 case ALC880_HP_EVENT:
16087 alc663_m51va_speaker_automute(codec);
16088 break;
16089 case ALC880_MIC_EVENT:
16090 alc663_m51va_mic_automute(codec);
16091 break;
16092 }
16093}
16094
16095static void alc663_m51va_inithook(struct hda_codec *codec)
16096{
16097 alc663_m51va_speaker_automute(codec);
16098 alc663_m51va_mic_automute(codec);
16099}
16100
Kailang Yangf1d4e282008-08-26 14:03:29 +020016101/* ***************** Mode1 ******************************/
16102static void alc663_mode1_unsol_event(struct hda_codec *codec,
16103 unsigned int res)
16104{
16105 switch (res >> 26) {
16106 case ALC880_HP_EVENT:
16107 alc663_m51va_speaker_automute(codec);
16108 break;
16109 case ALC880_MIC_EVENT:
16110 alc662_eeepc_mic_automute(codec);
16111 break;
16112 }
16113}
16114
16115static void alc663_mode1_inithook(struct hda_codec *codec)
16116{
16117 alc663_m51va_speaker_automute(codec);
16118 alc662_eeepc_mic_automute(codec);
16119}
16120/* ***************** Mode2 ******************************/
16121static void alc662_mode2_unsol_event(struct hda_codec *codec,
16122 unsigned int res)
16123{
16124 switch (res >> 26) {
16125 case ALC880_HP_EVENT:
16126 alc662_f5z_speaker_automute(codec);
16127 break;
16128 case ALC880_MIC_EVENT:
16129 alc662_eeepc_mic_automute(codec);
16130 break;
16131 }
16132}
16133
16134static void alc662_mode2_inithook(struct hda_codec *codec)
16135{
16136 alc662_f5z_speaker_automute(codec);
16137 alc662_eeepc_mic_automute(codec);
16138}
16139/* ***************** Mode3 ******************************/
16140static void alc663_mode3_unsol_event(struct hda_codec *codec,
16141 unsigned int res)
16142{
16143 switch (res >> 26) {
16144 case ALC880_HP_EVENT:
16145 alc663_two_hp_m1_speaker_automute(codec);
16146 break;
16147 case ALC880_MIC_EVENT:
16148 alc662_eeepc_mic_automute(codec);
16149 break;
16150 }
16151}
16152
16153static void alc663_mode3_inithook(struct hda_codec *codec)
16154{
16155 alc663_two_hp_m1_speaker_automute(codec);
16156 alc662_eeepc_mic_automute(codec);
16157}
16158/* ***************** Mode4 ******************************/
16159static void alc663_mode4_unsol_event(struct hda_codec *codec,
16160 unsigned int res)
16161{
16162 switch (res >> 26) {
16163 case ALC880_HP_EVENT:
16164 alc663_21jd_two_speaker_automute(codec);
16165 break;
16166 case ALC880_MIC_EVENT:
16167 alc662_eeepc_mic_automute(codec);
16168 break;
16169 }
16170}
16171
16172static void alc663_mode4_inithook(struct hda_codec *codec)
16173{
16174 alc663_21jd_two_speaker_automute(codec);
16175 alc662_eeepc_mic_automute(codec);
16176}
16177/* ***************** Mode5 ******************************/
16178static void alc663_mode5_unsol_event(struct hda_codec *codec,
16179 unsigned int res)
16180{
16181 switch (res >> 26) {
16182 case ALC880_HP_EVENT:
16183 alc663_15jd_two_speaker_automute(codec);
16184 break;
16185 case ALC880_MIC_EVENT:
16186 alc662_eeepc_mic_automute(codec);
16187 break;
16188 }
16189}
16190
16191static void alc663_mode5_inithook(struct hda_codec *codec)
16192{
16193 alc663_15jd_two_speaker_automute(codec);
16194 alc662_eeepc_mic_automute(codec);
16195}
16196/* ***************** Mode6 ******************************/
16197static void alc663_mode6_unsol_event(struct hda_codec *codec,
16198 unsigned int res)
16199{
16200 switch (res >> 26) {
16201 case ALC880_HP_EVENT:
16202 alc663_two_hp_m2_speaker_automute(codec);
16203 break;
16204 case ALC880_MIC_EVENT:
16205 alc662_eeepc_mic_automute(codec);
16206 break;
16207 }
16208}
16209
16210static void alc663_mode6_inithook(struct hda_codec *codec)
16211{
16212 alc663_two_hp_m2_speaker_automute(codec);
16213 alc662_eeepc_mic_automute(codec);
16214}
16215
Kailang Yang6dda9f42008-05-27 12:05:31 +020016216static void alc663_g71v_hp_automute(struct hda_codec *codec)
16217{
16218 unsigned int present;
16219 unsigned char bits;
16220
16221 present = snd_hda_codec_read(codec, 0x21, 0,
16222 AC_VERB_GET_PIN_SENSE, 0)
16223 & AC_PINSENSE_PRESENCE;
16224 bits = present ? HDA_AMP_MUTE : 0;
16225 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16226 HDA_AMP_MUTE, bits);
16227 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16228 HDA_AMP_MUTE, bits);
16229}
16230
16231static void alc663_g71v_front_automute(struct hda_codec *codec)
16232{
16233 unsigned int present;
16234 unsigned char bits;
16235
16236 present = snd_hda_codec_read(codec, 0x15, 0,
16237 AC_VERB_GET_PIN_SENSE, 0)
16238 & AC_PINSENSE_PRESENCE;
16239 bits = present ? HDA_AMP_MUTE : 0;
16240 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16241 HDA_AMP_MUTE, bits);
16242}
16243
16244static void alc663_g71v_unsol_event(struct hda_codec *codec,
16245 unsigned int res)
16246{
16247 switch (res >> 26) {
16248 case ALC880_HP_EVENT:
16249 alc663_g71v_hp_automute(codec);
16250 break;
16251 case ALC880_FRONT_EVENT:
16252 alc663_g71v_front_automute(codec);
16253 break;
16254 case ALC880_MIC_EVENT:
16255 alc662_eeepc_mic_automute(codec);
16256 break;
16257 }
16258}
16259
16260static void alc663_g71v_inithook(struct hda_codec *codec)
16261{
16262 alc663_g71v_front_automute(codec);
16263 alc663_g71v_hp_automute(codec);
16264 alc662_eeepc_mic_automute(codec);
16265}
16266
16267static void alc663_g50v_unsol_event(struct hda_codec *codec,
16268 unsigned int res)
16269{
16270 switch (res >> 26) {
16271 case ALC880_HP_EVENT:
16272 alc663_m51va_speaker_automute(codec);
16273 break;
16274 case ALC880_MIC_EVENT:
16275 alc662_eeepc_mic_automute(codec);
16276 break;
16277 }
16278}
16279
16280static void alc663_g50v_inithook(struct hda_codec *codec)
16281{
16282 alc663_m51va_speaker_automute(codec);
16283 alc662_eeepc_mic_automute(codec);
16284}
16285
Kailang Yangf1d4e282008-08-26 14:03:29 +020016286static struct snd_kcontrol_new alc662_ecs_mixer[] = {
16287 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020016288 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016289
16290 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
16291 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
16292 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
16293
16294 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16295 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16296 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16297 { } /* end */
16298};
16299
Chris Pockelé9541ba12009-05-12 08:08:53 +020016300static struct snd_kcontrol_new alc272_nc10_mixer[] = {
16301 /* Master Playback automatically created from Speaker and Headphone */
16302 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16303 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16304 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16305 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16306
16307 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16308 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16309 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
16310
16311 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16312 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16313 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
16314 { } /* end */
16315};
16316
Takashi Iwaicb53c622007-08-10 17:21:45 +020016317#ifdef CONFIG_SND_HDA_POWER_SAVE
16318#define alc662_loopbacks alc880_loopbacks
16319#endif
16320
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016321
16322/* pcm configuration: identiacal with ALC880 */
16323#define alc662_pcm_analog_playback alc880_pcm_analog_playback
16324#define alc662_pcm_analog_capture alc880_pcm_analog_capture
16325#define alc662_pcm_digital_playback alc880_pcm_digital_playback
16326#define alc662_pcm_digital_capture alc880_pcm_digital_capture
16327
16328/*
16329 * configuration and preset
16330 */
16331static const char *alc662_models[ALC662_MODEL_LAST] = {
16332 [ALC662_3ST_2ch_DIG] = "3stack-dig",
16333 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
16334 [ALC662_3ST_6ch] = "3stack-6ch",
16335 [ALC662_5ST_DIG] = "6stack-dig",
16336 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020016337 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010016338 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016339 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020016340 [ALC663_ASUS_M51VA] = "m51va",
16341 [ALC663_ASUS_G71V] = "g71v",
16342 [ALC663_ASUS_H13] = "h13",
16343 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016344 [ALC663_ASUS_MODE1] = "asus-mode1",
16345 [ALC662_ASUS_MODE2] = "asus-mode2",
16346 [ALC663_ASUS_MODE3] = "asus-mode3",
16347 [ALC663_ASUS_MODE4] = "asus-mode4",
16348 [ALC663_ASUS_MODE5] = "asus-mode5",
16349 [ALC663_ASUS_MODE6] = "asus-mode6",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020016350 [ALC272_DELL] = "dell",
16351 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020016352 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016353 [ALC662_AUTO] = "auto",
16354};
16355
16356static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010016357 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020016358 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
16359 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016360 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
16361 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
16362 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
16363 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
16364 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
16365 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
16366 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
16367 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
16368 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
16369 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
16370 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
16371 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016372 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
16373 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
16374 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016375 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
16376 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
16377 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
16378 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016379 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016380 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
16381 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016382 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016383 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
16384 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
16385 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020016386 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
16387 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
16388 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016389 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
16390 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
16391 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016392 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016393 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
16394 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020016395 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016396 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020016397 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016398 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
16399 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
16400 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016401 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016402 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
16403 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010016404 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020016405 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010016406 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016407 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030016408 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
16409 ALC662_3ST_6ch_DIG),
Chris Pockelé9541ba12009-05-12 08:08:53 +020016410 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030016411 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
16412 ALC662_3ST_6ch_DIG),
Vedran Miletic19c009a2008-09-29 20:29:25 +020016413 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020016414 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016415 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020016416 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020016417 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016418 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
16419 ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016420 {}
16421};
16422
16423static struct alc_config_preset alc662_presets[] = {
16424 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016425 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016426 .init_verbs = { alc662_init_verbs },
16427 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16428 .dac_nids = alc662_dac_nids,
16429 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016430 .dig_in_nid = ALC662_DIGIN_NID,
16431 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16432 .channel_mode = alc662_3ST_2ch_modes,
16433 .input_mux = &alc662_capture_source,
16434 },
16435 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016436 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016437 .init_verbs = { alc662_init_verbs },
16438 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16439 .dac_nids = alc662_dac_nids,
16440 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016441 .dig_in_nid = ALC662_DIGIN_NID,
16442 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16443 .channel_mode = alc662_3ST_6ch_modes,
16444 .need_dac_fix = 1,
16445 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016446 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016447 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016448 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016449 .init_verbs = { alc662_init_verbs },
16450 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16451 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016452 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16453 .channel_mode = alc662_3ST_6ch_modes,
16454 .need_dac_fix = 1,
16455 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016456 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016457 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016458 .mixers = { alc662_base_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_5stack_modes),
16465 .channel_mode = alc662_5stack_modes,
16466 .input_mux = &alc662_capture_source,
16467 },
16468 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016469 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016470 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
16471 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16472 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016473 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16474 .channel_mode = alc662_3ST_2ch_modes,
16475 .input_mux = &alc662_lenovo_101e_capture_source,
16476 .unsol_event = alc662_lenovo_101e_unsol_event,
16477 .init_hook = alc662_lenovo_101e_all_automute,
16478 },
Kailang Yang291702f2007-10-16 14:28:03 +020016479 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016480 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020016481 .init_verbs = { alc662_init_verbs,
16482 alc662_eeepc_sue_init_verbs },
16483 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16484 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020016485 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16486 .channel_mode = alc662_3ST_2ch_modes,
16487 .input_mux = &alc662_eeepc_capture_source,
16488 .unsol_event = alc662_eeepc_unsol_event,
16489 .init_hook = alc662_eeepc_inithook,
16490 },
Kailang Yang8c427222008-01-10 13:03:59 +010016491 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016492 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010016493 alc662_chmode_mixer },
16494 .init_verbs = { alc662_init_verbs,
16495 alc662_eeepc_ep20_sue_init_verbs },
16496 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16497 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010016498 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16499 .channel_mode = alc662_3ST_6ch_modes,
16500 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020016501 .unsol_event = alc662_eeepc_unsol_event,
Kailang Yang8c427222008-01-10 13:03:59 +010016502 .init_hook = alc662_eeepc_ep20_inithook,
16503 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016504 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016505 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016506 .init_verbs = { alc662_init_verbs,
16507 alc662_ecs_init_verbs },
16508 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16509 .dac_nids = alc662_dac_nids,
16510 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16511 .channel_mode = alc662_3ST_2ch_modes,
16512 .input_mux = &alc662_eeepc_capture_source,
16513 .unsol_event = alc662_eeepc_unsol_event,
16514 .init_hook = alc662_eeepc_inithook,
16515 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016516 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016517 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016518 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16519 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16520 .dac_nids = alc662_dac_nids,
16521 .dig_out_nid = ALC662_DIGOUT_NID,
16522 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16523 .channel_mode = alc662_3ST_2ch_modes,
16524 .input_mux = &alc663_m51va_capture_source,
16525 .unsol_event = alc663_m51va_unsol_event,
16526 .init_hook = alc663_m51va_inithook,
16527 },
16528 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016529 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016530 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
16531 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16532 .dac_nids = alc662_dac_nids,
16533 .dig_out_nid = ALC662_DIGOUT_NID,
16534 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16535 .channel_mode = alc662_3ST_2ch_modes,
16536 .input_mux = &alc662_eeepc_capture_source,
16537 .unsol_event = alc663_g71v_unsol_event,
16538 .init_hook = alc663_g71v_inithook,
16539 },
16540 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016541 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016542 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16543 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16544 .dac_nids = alc662_dac_nids,
16545 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16546 .channel_mode = alc662_3ST_2ch_modes,
16547 .input_mux = &alc663_m51va_capture_source,
16548 .unsol_event = alc663_m51va_unsol_event,
16549 .init_hook = alc663_m51va_inithook,
16550 },
16551 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016552 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016553 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
16554 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16555 .dac_nids = alc662_dac_nids,
16556 .dig_out_nid = ALC662_DIGOUT_NID,
16557 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16558 .channel_mode = alc662_3ST_6ch_modes,
16559 .input_mux = &alc663_capture_source,
16560 .unsol_event = alc663_g50v_unsol_event,
16561 .init_hook = alc663_g50v_inithook,
16562 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016563 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016564 .mixers = { alc663_m51va_mixer },
16565 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016566 .init_verbs = { alc662_init_verbs,
16567 alc663_21jd_amic_init_verbs },
16568 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16569 .hp_nid = 0x03,
16570 .dac_nids = alc662_dac_nids,
16571 .dig_out_nid = ALC662_DIGOUT_NID,
16572 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16573 .channel_mode = alc662_3ST_2ch_modes,
16574 .input_mux = &alc662_eeepc_capture_source,
16575 .unsol_event = alc663_mode1_unsol_event,
16576 .init_hook = alc663_mode1_inithook,
16577 },
16578 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016579 .mixers = { alc662_1bjd_mixer },
16580 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016581 .init_verbs = { alc662_init_verbs,
16582 alc662_1bjd_amic_init_verbs },
16583 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16584 .dac_nids = alc662_dac_nids,
16585 .dig_out_nid = ALC662_DIGOUT_NID,
16586 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16587 .channel_mode = alc662_3ST_2ch_modes,
16588 .input_mux = &alc662_eeepc_capture_source,
16589 .unsol_event = alc662_mode2_unsol_event,
16590 .init_hook = alc662_mode2_inithook,
16591 },
16592 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016593 .mixers = { alc663_two_hp_m1_mixer },
16594 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016595 .init_verbs = { alc662_init_verbs,
16596 alc663_two_hp_amic_m1_init_verbs },
16597 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16598 .hp_nid = 0x03,
16599 .dac_nids = alc662_dac_nids,
16600 .dig_out_nid = ALC662_DIGOUT_NID,
16601 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16602 .channel_mode = alc662_3ST_2ch_modes,
16603 .input_mux = &alc662_eeepc_capture_source,
16604 .unsol_event = alc663_mode3_unsol_event,
16605 .init_hook = alc663_mode3_inithook,
16606 },
16607 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016608 .mixers = { alc663_asus_21jd_clfe_mixer },
16609 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016610 .init_verbs = { alc662_init_verbs,
16611 alc663_21jd_amic_init_verbs},
16612 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16613 .hp_nid = 0x03,
16614 .dac_nids = alc662_dac_nids,
16615 .dig_out_nid = ALC662_DIGOUT_NID,
16616 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16617 .channel_mode = alc662_3ST_2ch_modes,
16618 .input_mux = &alc662_eeepc_capture_source,
16619 .unsol_event = alc663_mode4_unsol_event,
16620 .init_hook = alc663_mode4_inithook,
16621 },
16622 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016623 .mixers = { alc663_asus_15jd_clfe_mixer },
16624 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016625 .init_verbs = { alc662_init_verbs,
16626 alc663_15jd_amic_init_verbs },
16627 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16628 .hp_nid = 0x03,
16629 .dac_nids = alc662_dac_nids,
16630 .dig_out_nid = ALC662_DIGOUT_NID,
16631 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16632 .channel_mode = alc662_3ST_2ch_modes,
16633 .input_mux = &alc662_eeepc_capture_source,
16634 .unsol_event = alc663_mode5_unsol_event,
16635 .init_hook = alc663_mode5_inithook,
16636 },
16637 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016638 .mixers = { alc663_two_hp_m2_mixer },
16639 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016640 .init_verbs = { alc662_init_verbs,
16641 alc663_two_hp_amic_m2_init_verbs },
16642 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16643 .hp_nid = 0x03,
16644 .dac_nids = alc662_dac_nids,
16645 .dig_out_nid = ALC662_DIGOUT_NID,
16646 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16647 .channel_mode = alc662_3ST_2ch_modes,
16648 .input_mux = &alc662_eeepc_capture_source,
16649 .unsol_event = alc663_mode6_unsol_event,
16650 .init_hook = alc663_mode6_inithook,
16651 },
Kailang Yang622e84c2009-04-21 07:39:04 +020016652 [ALC272_DELL] = {
16653 .mixers = { alc663_m51va_mixer },
16654 .cap_mixer = alc272_auto_capture_mixer,
16655 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
16656 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
16657 .dac_nids = alc662_dac_nids,
16658 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16659 .adc_nids = alc272_adc_nids,
16660 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
16661 .capsrc_nids = alc272_capsrc_nids,
16662 .channel_mode = alc662_3ST_2ch_modes,
16663 .input_mux = &alc663_m51va_capture_source,
16664 .unsol_event = alc663_m51va_unsol_event,
16665 .init_hook = alc663_m51va_inithook,
16666 },
16667 [ALC272_DELL_ZM1] = {
16668 .mixers = { alc663_m51va_mixer },
16669 .cap_mixer = alc662_auto_capture_mixer,
16670 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
16671 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
16672 .dac_nids = alc662_dac_nids,
16673 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16674 .adc_nids = alc662_adc_nids,
16675 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
16676 .capsrc_nids = alc662_capsrc_nids,
16677 .channel_mode = alc662_3ST_2ch_modes,
16678 .input_mux = &alc663_m51va_capture_source,
16679 .unsol_event = alc663_m51va_unsol_event,
16680 .init_hook = alc663_m51va_inithook,
16681 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020016682 [ALC272_SAMSUNG_NC10] = {
16683 .mixers = { alc272_nc10_mixer },
16684 .init_verbs = { alc662_init_verbs,
16685 alc663_21jd_amic_init_verbs },
16686 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
16687 .dac_nids = alc272_dac_nids,
16688 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16689 .channel_mode = alc662_3ST_2ch_modes,
16690 .input_mux = &alc272_nc10_capture_source,
16691 .unsol_event = alc663_mode4_unsol_event,
16692 .init_hook = alc663_mode4_inithook,
16693 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016694};
16695
16696
16697/*
16698 * BIOS auto configuration
16699 */
16700
16701/* add playback controls from the parsed DAC table */
16702static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
16703 const struct auto_pin_cfg *cfg)
16704{
16705 char name[32];
16706 static const char *chname[4] = {
16707 "Front", "Surround", NULL /*CLFE*/, "Side"
16708 };
16709 hda_nid_t nid;
16710 int i, err;
16711
16712 for (i = 0; i < cfg->line_outs; i++) {
16713 if (!spec->multiout.dac_nids[i])
16714 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020016715 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016716 if (i == 2) {
16717 /* Center/LFE */
16718 err = add_control(spec, ALC_CTL_WIDGET_VOL,
16719 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016720 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
16721 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016722 if (err < 0)
16723 return err;
16724 err = add_control(spec, ALC_CTL_WIDGET_VOL,
16725 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016726 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
16727 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016728 if (err < 0)
16729 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016730 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016731 "Center Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016732 HDA_COMPOSE_AMP_VAL(0x0e, 1, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016733 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016734 if (err < 0)
16735 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016736 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016737 "LFE Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016738 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016739 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016740 if (err < 0)
16741 return err;
16742 } else {
16743 sprintf(name, "%s Playback Volume", chname[i]);
16744 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016745 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
16746 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016747 if (err < 0)
16748 return err;
16749 sprintf(name, "%s Playback Switch", chname[i]);
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016750 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16751 HDA_COMPOSE_AMP_VAL(alc880_idx_to_mixer(i),
16752 3, 0, HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016753 if (err < 0)
16754 return err;
16755 }
16756 }
16757 return 0;
16758}
16759
16760/* add playback controls for speaker and HP outputs */
16761static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
16762 const char *pfx)
16763{
16764 hda_nid_t nid;
16765 int err;
16766 char name[32];
16767
16768 if (!pin)
16769 return 0;
16770
Takashi Iwai24fb9172008-09-02 14:48:20 +020016771 if (pin == 0x17) {
16772 /* ALC663 has a mono output pin on 0x17 */
16773 sprintf(name, "%s Playback Switch", pfx);
16774 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16775 HDA_COMPOSE_AMP_VAL(pin, 2, 0, HDA_OUTPUT));
16776 return err;
16777 }
16778
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016779 if (alc880_is_fixed_pin(pin)) {
16780 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai939778a2009-02-05 15:57:55 +010016781 /* printk(KERN_DEBUG "DAC nid=%x\n",nid); */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016782 /* specify the DAC as the extra output */
16783 if (!spec->multiout.hp_nid)
16784 spec->multiout.hp_nid = nid;
16785 else
16786 spec->multiout.extra_out_nid[0] = nid;
16787 /* control HP volume/switch on the output mixer amp */
16788 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16789 sprintf(name, "%s Playback Volume", pfx);
16790 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
16791 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
16792 if (err < 0)
16793 return err;
16794 sprintf(name, "%s Playback Switch", pfx);
16795 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
16796 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
16797 if (err < 0)
16798 return err;
16799 } else if (alc880_is_multi_pin(pin)) {
16800 /* set manual connection */
16801 /* we have only a switch on HP-out PIN */
16802 sprintf(name, "%s Playback Switch", pfx);
16803 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16804 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
16805 if (err < 0)
16806 return err;
16807 }
16808 return 0;
16809}
16810
Takashi Iwai2d864c42009-03-20 12:52:47 +010016811/* return the index of the src widget from the connection list of the nid.
16812 * return -1 if not found
16813 */
16814static int alc662_input_pin_idx(struct hda_codec *codec, hda_nid_t nid,
16815 hda_nid_t src)
16816{
16817 hda_nid_t conn_list[HDA_MAX_CONNECTIONS];
16818 int i, conns;
16819
16820 conns = snd_hda_get_connections(codec, nid, conn_list,
16821 ARRAY_SIZE(conn_list));
16822 if (conns < 0)
16823 return -1;
16824 for (i = 0; i < conns; i++)
16825 if (conn_list[i] == src)
16826 return i;
16827 return -1;
16828}
16829
16830static int alc662_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
16831{
Takashi Iwai1327a322009-03-23 13:07:47 +010016832 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai2d864c42009-03-20 12:52:47 +010016833 return (pincap & AC_PINCAP_IN) != 0;
16834}
16835
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016836/* create playback/capture controls for input pins */
Takashi Iwai2d864c42009-03-20 12:52:47 +010016837static int alc662_auto_create_analog_input_ctls(struct hda_codec *codec,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016838 const struct auto_pin_cfg *cfg)
16839{
Takashi Iwai2d864c42009-03-20 12:52:47 +010016840 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016841 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016842 int i, err, idx;
16843
16844 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai2d864c42009-03-20 12:52:47 +010016845 if (alc662_is_input_pin(codec, cfg->input_pins[i])) {
16846 idx = alc662_input_pin_idx(codec, 0x0b,
16847 cfg->input_pins[i]);
16848 if (idx >= 0) {
16849 err = new_analog_input(spec, cfg->input_pins[i],
16850 auto_pin_cfg_labels[i],
16851 idx, 0x0b);
16852 if (err < 0)
16853 return err;
16854 }
16855 idx = alc662_input_pin_idx(codec, 0x22,
16856 cfg->input_pins[i]);
16857 if (idx >= 0) {
16858 imux->items[imux->num_items].label =
16859 auto_pin_cfg_labels[i];
16860 imux->items[imux->num_items].index = idx;
16861 imux->num_items++;
16862 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016863 }
16864 }
16865 return 0;
16866}
16867
16868static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
16869 hda_nid_t nid, int pin_type,
16870 int dac_idx)
16871{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016872 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016873 /* need the manual connection? */
16874 if (alc880_is_multi_pin(nid)) {
16875 struct alc_spec *spec = codec->spec;
16876 int idx = alc880_multi_pin_idx(nid);
16877 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
16878 AC_VERB_SET_CONNECT_SEL,
16879 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
16880 }
16881}
16882
16883static void alc662_auto_init_multi_out(struct hda_codec *codec)
16884{
16885 struct alc_spec *spec = codec->spec;
16886 int i;
16887
16888 for (i = 0; i <= HDA_SIDE; i++) {
16889 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016890 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016891 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016892 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016893 i);
16894 }
16895}
16896
16897static void alc662_auto_init_hp_out(struct hda_codec *codec)
16898{
16899 struct alc_spec *spec = codec->spec;
16900 hda_nid_t pin;
16901
16902 pin = spec->autocfg.hp_pins[0];
16903 if (pin) /* connect to front */
16904 /* use dac 0 */
16905 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016906 pin = spec->autocfg.speaker_pins[0];
16907 if (pin)
16908 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016909}
16910
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016911#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
16912
16913static void alc662_auto_init_analog_input(struct hda_codec *codec)
16914{
16915 struct alc_spec *spec = codec->spec;
16916 int i;
16917
16918 for (i = 0; i < AUTO_PIN_LAST; i++) {
16919 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai2d864c42009-03-20 12:52:47 +010016920 if (alc662_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010016921 alc_set_input_pin(codec, nid, i);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010016922 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010016923 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016924 snd_hda_codec_write(codec, nid, 0,
16925 AC_VERB_SET_AMP_GAIN_MUTE,
16926 AMP_OUT_MUTE);
16927 }
16928 }
16929}
16930
Takashi Iwaif511b012008-08-15 16:46:42 +020016931#define alc662_auto_init_input_src alc882_auto_init_input_src
16932
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016933static int alc662_parse_auto_config(struct hda_codec *codec)
16934{
16935 struct alc_spec *spec = codec->spec;
16936 int err;
16937 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
16938
16939 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
16940 alc662_ignore);
16941 if (err < 0)
16942 return err;
16943 if (!spec->autocfg.line_outs)
16944 return 0; /* can't find valid BIOS pin config */
16945
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016946 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
16947 if (err < 0)
16948 return err;
16949 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
16950 if (err < 0)
16951 return err;
16952 err = alc662_auto_create_extra_out(spec,
16953 spec->autocfg.speaker_pins[0],
16954 "Speaker");
16955 if (err < 0)
16956 return err;
16957 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
16958 "Headphone");
16959 if (err < 0)
16960 return err;
Takashi Iwai2d864c42009-03-20 12:52:47 +010016961 err = alc662_auto_create_analog_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016962 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016963 return err;
16964
16965 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
16966
Takashi Iwai0852d7a2009-02-11 11:35:15 +010016967 if (spec->autocfg.dig_outs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016968 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
16969
Takashi Iwai603c4012008-07-30 15:01:44 +020016970 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016971 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016972
16973 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016974 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020016975
Takashi Iwaid88897e2008-10-31 15:01:37 +010016976 add_verb(spec, alc662_auto_init_verbs);
Takashi Iwai24fb9172008-09-02 14:48:20 +020016977 if (codec->vendor_id == 0x10ec0663)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016978 add_verb(spec, alc663_auto_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020016979
16980 err = alc_auto_add_mic_boost(codec);
16981 if (err < 0)
16982 return err;
16983
Takashi Iwai4a79ba32009-04-22 16:31:35 +020016984 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
16985
Takashi Iwai8c87286f2007-06-19 12:11:16 +020016986 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016987}
16988
16989/* additional initialization for auto-configuration model */
16990static void alc662_auto_init(struct hda_codec *codec)
16991{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016992 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016993 alc662_auto_init_multi_out(codec);
16994 alc662_auto_init_hp_out(codec);
16995 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020016996 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016997 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020016998 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016999}
17000
17001static int patch_alc662(struct hda_codec *codec)
17002{
17003 struct alc_spec *spec;
17004 int err, board_config;
17005
17006 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
17007 if (!spec)
17008 return -ENOMEM;
17009
17010 codec->spec = spec;
17011
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020017012 alc_fix_pll_init(codec, 0x20, 0x04, 15);
17013
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017014 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
17015 alc662_models,
17016 alc662_cfg_tbl);
17017 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020017018 printk(KERN_INFO "hda_codec: Unknown model for %s, "
17019 "trying auto-probe from BIOS...\n", codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017020 board_config = ALC662_AUTO;
17021 }
17022
17023 if (board_config == ALC662_AUTO) {
17024 /* automatic parse from the BIOS config */
17025 err = alc662_parse_auto_config(codec);
17026 if (err < 0) {
17027 alc_free(codec);
17028 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020017029 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017030 printk(KERN_INFO
17031 "hda_codec: Cannot set up configuration "
17032 "from BIOS. Using base mode...\n");
17033 board_config = ALC662_3ST_2ch_DIG;
17034 }
17035 }
17036
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090017037 err = snd_hda_attach_beep_device(codec, 0x1);
17038 if (err < 0) {
17039 alc_free(codec);
17040 return err;
17041 }
17042
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017043 if (board_config != ALC662_AUTO)
17044 setup_preset(spec, &alc662_presets[board_config]);
17045
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017046 spec->stream_analog_playback = &alc662_pcm_analog_playback;
17047 spec->stream_analog_capture = &alc662_pcm_analog_capture;
17048
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017049 spec->stream_digital_playback = &alc662_pcm_digital_playback;
17050 spec->stream_digital_capture = &alc662_pcm_digital_capture;
17051
Takashi Iwaie1406342008-02-11 18:32:32 +010017052 spec->adc_nids = alc662_adc_nids;
17053 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
17054 spec->capsrc_nids = alc662_capsrc_nids;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017055 spec->capture_style = CAPT_MIX;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017056
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017057 if (!spec->cap_mixer)
17058 set_capture_mixer(spec);
Takashi Iwaib9591442009-03-16 15:25:00 +010017059 if (codec->vendor_id == 0x10ec0662)
17060 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
17061 else
17062 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017063
Takashi Iwai2134ea42008-01-10 16:53:55 +010017064 spec->vmaster_nid = 0x02;
17065
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017066 codec->patch_ops = alc_patch_ops;
17067 if (board_config == ALC662_AUTO)
17068 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020017069#ifdef CONFIG_SND_HDA_POWER_SAVE
17070 if (!spec->loopback.amplist)
17071 spec->loopback.amplist = alc662_loopbacks;
17072#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010017073 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017074
17075 return 0;
17076}
17077
17078/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070017079 * patch entries
17080 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017081static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070017082 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010017083 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017084 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020017085 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017086 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020017087 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017088 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017089 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017090 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
17091 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
17092 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017093 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
17094 .patch = patch_alc883 },
17095 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
17096 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017097 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017098 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017099 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020017100 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Clive Messer669faba2008-09-30 15:49:13 +020017101 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
17102 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Takashi Iwaicb308f92008-04-16 14:13:29 +020017103 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai7943a8a2008-04-16 17:29:09 +020017104 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Kailang Yangdf694da2005-12-05 19:42:22 +010017105 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Kailang Yanga385a522008-10-15 11:20:21 +020017106 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc883 },
Kailang Yang44426082008-10-15 11:18:05 +020017107 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
17108 .patch = patch_alc883 },
Wu Fengguang3fea2cb2008-12-26 12:20:43 +080017109 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017110 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017111 {} /* terminator */
17112};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017113
17114MODULE_ALIAS("snd-hda-codec-id:10ec*");
17115
17116MODULE_LICENSE("GPL");
17117MODULE_DESCRIPTION("Realtek HD-audio codec");
17118
17119static struct hda_codec_preset_list realtek_list = {
17120 .preset = snd_hda_preset_realtek,
17121 .owner = THIS_MODULE,
17122};
17123
17124static int __init patch_realtek_init(void)
17125{
17126 return snd_hda_add_codec_preset(&realtek_list);
17127}
17128
17129static void __exit patch_realtek_exit(void)
17130{
17131 snd_hda_delete_codec_preset(&realtek_list);
17132}
17133
17134module_init(patch_realtek_init)
17135module_exit(patch_realtek_exit)