blob: 3a6306302c709b98f1ecaa4a6c27d1eea4ef360d [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,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200193 ALC662_AUTO,
194 ALC662_MODEL_LAST,
195};
196
Kailang Yangdf694da2005-12-05 19:42:22 +0100197/* ALC882 models */
198enum {
199 ALC882_3ST_DIG,
200 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200201 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200202 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200203 ALC882_TARGA,
204 ALC882_ASUS_A7J,
Takashi Iwai914759b2007-09-06 14:52:04 +0200205 ALC882_ASUS_A7M,
Tobin Davis9102cd12006-12-15 10:02:12 +0100206 ALC885_MACPRO,
Takashi Iwai87350ad2007-08-16 18:19:38 +0200207 ALC885_MBP3,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200208 ALC885_IMAC24,
Kailang Yang272a5272007-05-14 11:00:38 +0200209 ALC882_AUTO,
Kailang Yangdf694da2005-12-05 19:42:22 +0100210 ALC882_MODEL_LAST,
211};
212
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200213/* ALC883 models */
214enum {
215 ALC883_3ST_2ch_DIG,
216 ALC883_3ST_6ch_DIG,
217 ALC883_3ST_6ch,
218 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200219 ALC883_TARGA_DIG,
220 ALC883_TARGA_2ch_DIG,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +0200221 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200222 ALC883_ACER_ASPIRE,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +0800223 ALC888_ACER_ASPIRE_4930G,
Tobin Davisc07584c2006-10-13 12:32:16 +0200224 ALC883_MEDION,
Kailang Yangea1fb292008-08-26 12:58:38 +0200225 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100226 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200227 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200228 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200229 ALC888_LENOVO_MS7195_DIG,
Kailang Yange2757d52008-08-26 13:17:46 +0200230 ALC888_LENOVO_SKY,
Kailang Yangea1fb292008-08-26 12:58:38 +0200231 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200232 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100233 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100234 ALC883_MITAC,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100235 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100236 ALC883_FUJITSU_PI2515,
Vincent Petryef8ef5f2008-11-23 11:31:41 +0800237 ALC888_FUJITSU_XA3530,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200238 ALC883_3ST_6ch_INTEL,
Kailang Yange2757d52008-08-26 13:17:46 +0200239 ALC888_ASUS_M90V,
240 ALC888_ASUS_EEE1601,
Wu Fengguang3ab90932008-11-17 09:51:09 +0100241 ALC1200_ASUS_P5Q,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200242 ALC883_AUTO,
243 ALC883_MODEL_LAST,
244};
245
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200246/* styles of capture selection */
247enum {
248 CAPT_MUX = 0, /* only mux based */
249 CAPT_MIX, /* only mixer based */
250 CAPT_1MUX_MIX, /* first mux and other mixers */
251};
252
Kailang Yangdf694da2005-12-05 19:42:22 +0100253/* for GPIO Poll */
254#define GPIO_MASK 0x03
255
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200256/* extra amp-initialization sequence types */
257enum {
258 ALC_INIT_NONE,
259 ALC_INIT_DEFAULT,
260 ALC_INIT_GPIO1,
261 ALC_INIT_GPIO2,
262 ALC_INIT_GPIO3,
263};
264
Linus Torvalds1da177e2005-04-16 15:20:36 -0700265struct alc_spec {
266 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100267 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700268 unsigned int num_mixers;
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100269 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100270 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700271
Kailang Yangdf694da2005-12-05 19:42:22 +0100272 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200273 * don't forget NULL
274 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200275 */
276 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700277
Takashi Iwai16ded522005-06-10 19:58:24 +0200278 char *stream_name_analog; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700279 struct hda_pcm_stream *stream_analog_playback;
280 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100281 struct hda_pcm_stream *stream_analog_alt_playback;
282 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700283
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200284 char *stream_name_digital; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700285 struct hda_pcm_stream *stream_digital_playback;
286 struct hda_pcm_stream *stream_digital_capture;
287
288 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200289 struct hda_multi_out multiout; /* playback set-up
290 * max_channels, dacs must be set
291 * dig_out_nid and hp_nid are optional
292 */
Takashi Iwai63300792008-01-24 15:31:36 +0100293 hda_nid_t alt_dac_nid;
Takashi Iwai6a05ac42009-02-13 11:19:09 +0100294 hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */
Takashi Iwai8c441982009-01-20 18:30:20 +0100295 int dig_out_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700296
297 /* capture */
298 unsigned int num_adc_nids;
299 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100300 hda_nid_t *capsrc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200301 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200302 int capture_style; /* capture style (CAPT_*) */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700303
304 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200305 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700306 const struct hda_input_mux *input_mux;
307 unsigned int cur_mux[3];
308
309 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100310 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700311 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200312 int need_dac_fix;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700313
314 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100315 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200316
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200317 /* dynamic controls, init_verbs and input_mux */
318 struct auto_pin_cfg autocfg;
Takashi Iwai603c4012008-07-30 15:01:44 +0200319 struct snd_array kctls;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200320 struct hda_input_mux private_imux[3];
Takashi Iwai41923e42007-10-22 17:20:10 +0200321 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100322
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100323 /* hooks */
324 void (*init_hook)(struct hda_codec *codec);
325 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
326
Takashi Iwai834be882006-03-01 14:16:17 +0100327 /* for pin sensing */
328 unsigned int sense_updated: 1;
329 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100330 unsigned int master_sw: 1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200331
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100332 /* other flags */
333 unsigned int no_analog :1; /* digital I/O only */
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200334 int init_amp;
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100335
Takashi Iwai2134ea42008-01-10 16:53:55 +0100336 /* for virtual master */
337 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200338#ifdef CONFIG_SND_HDA_POWER_SAVE
339 struct hda_loopback_check loopback;
340#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200341
342 /* for PLL fix */
343 hda_nid_t pll_nid;
344 unsigned int pll_coef_idx, pll_coef_bit;
Kailang Yangdf694da2005-12-05 19:42:22 +0100345};
346
347/*
348 * configuration template - to be copied to the spec instance
349 */
350struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200351 struct snd_kcontrol_new *mixers[5]; /* should be identical size
352 * with spec
353 */
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100354 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Kailang Yangdf694da2005-12-05 19:42:22 +0100355 const struct hda_verb *init_verbs[5];
356 unsigned int num_dacs;
357 hda_nid_t *dac_nids;
358 hda_nid_t dig_out_nid; /* optional */
359 hda_nid_t hp_nid; /* optional */
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800360 hda_nid_t *slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100361 unsigned int num_adc_nids;
362 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100363 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100364 hda_nid_t dig_in_nid;
365 unsigned int num_channel_mode;
366 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200367 int need_dac_fix;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200368 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100369 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100370 void (*unsol_event)(struct hda_codec *, unsigned int);
371 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200372#ifdef CONFIG_SND_HDA_POWER_SAVE
373 struct hda_amp_list *loopbacks;
374#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700375};
376
Linus Torvalds1da177e2005-04-16 15:20:36 -0700377
378/*
379 * input MUX handling
380 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200381static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
382 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700383{
384 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
385 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200386 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
387 if (mux_idx >= spec->num_mux_defs)
388 mux_idx = 0;
389 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700390}
391
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200392static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
393 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700394{
395 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
396 struct alc_spec *spec = codec->spec;
397 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
398
399 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
400 return 0;
401}
402
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200403static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
404 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700405{
406 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
407 struct alc_spec *spec = codec->spec;
Takashi Iwaicd896c32008-11-18 12:36:33 +0100408 const struct hda_input_mux *imux;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700409 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwaicd896c32008-11-18 12:36:33 +0100410 unsigned int mux_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100411 hda_nid_t nid = spec->capsrc_nids ?
412 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700413
Takashi Iwaicd896c32008-11-18 12:36:33 +0100414 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
415 imux = &spec->input_mux[mux_idx];
416
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200417 if (spec->capture_style &&
418 !(spec->capture_style == CAPT_1MUX_MIX && !adc_idx)) {
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100419 /* Matrix-mixer style (e.g. ALC882) */
420 unsigned int *cur_val = &spec->cur_mux[adc_idx];
421 unsigned int i, idx;
422
423 idx = ucontrol->value.enumerated.item[0];
424 if (idx >= imux->num_items)
425 idx = imux->num_items - 1;
426 if (*cur_val == idx)
427 return 0;
428 for (i = 0; i < imux->num_items; i++) {
429 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
430 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
431 imux->items[i].index,
432 HDA_AMP_MUTE, v);
433 }
434 *cur_val = idx;
435 return 1;
436 } else {
437 /* MUX style (e.g. ALC880) */
Takashi Iwaicd896c32008-11-18 12:36:33 +0100438 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100439 &spec->cur_mux[adc_idx]);
440 }
441}
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200442
Linus Torvalds1da177e2005-04-16 15:20:36 -0700443/*
444 * channel mode setting
445 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200446static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
447 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700448{
449 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
450 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100451 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
452 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700453}
454
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200455static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
456 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700457{
458 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
459 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100460 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200461 spec->num_channel_mode,
462 spec->multiout.max_channels);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700463}
464
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200465static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
466 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700467{
468 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
469 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200470 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
471 spec->num_channel_mode,
472 &spec->multiout.max_channels);
Takashi Iwaibd2033f2006-10-10 19:49:31 +0200473 if (err >= 0 && spec->need_dac_fix)
Takashi Iwai4e195a72006-07-28 14:47:34 +0200474 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
475 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700476}
477
Linus Torvalds1da177e2005-04-16 15:20:36 -0700478/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100479 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200480 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100481 * being part of a format specifier. Maximum allowed length of a value is
482 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100483 *
484 * Note: some retasking pin complexes seem to ignore requests for input
485 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
486 * are requested. Therefore order this list so that this behaviour will not
487 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200488 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
489 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200490 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100491static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100492 "Mic 50pc bias", "Mic 80pc bias",
493 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100494};
495static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100496 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100497};
498/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200499 * in the pin being assumed to be exclusively an input or an output pin. In
500 * addition, "input" pins may or may not process the mic bias option
501 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
502 * accept requests for bias as of chip versions up to March 2006) and/or
503 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100504 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200505#define ALC_PIN_DIR_IN 0x00
506#define ALC_PIN_DIR_OUT 0x01
507#define ALC_PIN_DIR_INOUT 0x02
508#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
509#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100510
Kailang Yangea1fb292008-08-26 12:58:38 +0200511/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100512 * For each direction the minimum and maximum values are given.
513 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200514static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100515 { 0, 2 }, /* ALC_PIN_DIR_IN */
516 { 3, 4 }, /* ALC_PIN_DIR_OUT */
517 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200518 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
519 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100520};
521#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
522#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
523#define alc_pin_mode_n_items(_dir) \
524 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
525
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200526static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
527 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200528{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100529 unsigned int item_num = uinfo->value.enumerated.item;
530 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
531
532 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200533 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100534 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
535
536 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
537 item_num = alc_pin_mode_min(dir);
538 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200539 return 0;
540}
541
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200542static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
543 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200544{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100545 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200546 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
547 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100548 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200549 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200550 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
551 AC_VERB_GET_PIN_WIDGET_CONTROL,
552 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200553
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100554 /* Find enumerated value for current pinctl setting */
555 i = alc_pin_mode_min(dir);
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200556 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100557 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200558 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100559 return 0;
560}
561
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200562static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
563 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100564{
565 signed int change;
566 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
567 hda_nid_t nid = kcontrol->private_value & 0xffff;
568 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
569 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200570 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
571 AC_VERB_GET_PIN_WIDGET_CONTROL,
572 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100573
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200574 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100575 val = alc_pin_mode_min(dir);
576
577 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100578 if (change) {
579 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200580 snd_hda_codec_write_cache(codec, nid, 0,
581 AC_VERB_SET_PIN_WIDGET_CONTROL,
582 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100583
Kailang Yangea1fb292008-08-26 12:58:38 +0200584 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100585 * for the requested pin mode. Enum values of 2 or less are
586 * input modes.
587 *
588 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200589 * reduces noise slightly (particularly on input) so we'll
590 * do it. However, having both input and output buffers
591 * enabled simultaneously doesn't seem to be problematic if
592 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100593 */
594 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200595 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
596 HDA_AMP_MUTE, HDA_AMP_MUTE);
597 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
598 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100599 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200600 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
601 HDA_AMP_MUTE, HDA_AMP_MUTE);
602 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
603 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100604 }
605 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200606 return change;
607}
608
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100609#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200610 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100611 .info = alc_pin_mode_info, \
612 .get = alc_pin_mode_get, \
613 .put = alc_pin_mode_put, \
614 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100615
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100616/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
617 * together using a mask with more than one bit set. This control is
618 * currently used only by the ALC260 test model. At this stage they are not
619 * needed for any "production" models.
620 */
621#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200622#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200623
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200624static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
625 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100626{
627 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
628 hda_nid_t nid = kcontrol->private_value & 0xffff;
629 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
630 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200631 unsigned int val = snd_hda_codec_read(codec, nid, 0,
632 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100633
634 *valp = (val & mask) != 0;
635 return 0;
636}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200637static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
638 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100639{
640 signed int change;
641 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
642 hda_nid_t nid = kcontrol->private_value & 0xffff;
643 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
644 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200645 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
646 AC_VERB_GET_GPIO_DATA,
647 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100648
649 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200650 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
651 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100652 gpio_data &= ~mask;
653 else
654 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200655 snd_hda_codec_write_cache(codec, nid, 0,
656 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100657
658 return change;
659}
660#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
661 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
662 .info = alc_gpio_data_info, \
663 .get = alc_gpio_data_get, \
664 .put = alc_gpio_data_put, \
665 .private_value = nid | (mask<<16) }
666#endif /* CONFIG_SND_DEBUG */
667
Jonathan Woithe92621f12006-02-28 11:47:47 +0100668/* A switch control to allow the enabling of the digital IO pins on the
669 * ALC260. This is incredibly simplistic; the intention of this control is
670 * to provide something in the test model allowing digital outputs to be
671 * identified if present. If models are found which can utilise these
672 * outputs a more complete mixer control can be devised for those models if
673 * necessary.
674 */
675#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200676#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200677
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200678static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
679 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100680{
681 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
682 hda_nid_t nid = kcontrol->private_value & 0xffff;
683 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
684 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200685 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100686 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100687
688 *valp = (val & mask) != 0;
689 return 0;
690}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200691static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
692 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100693{
694 signed int change;
695 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
696 hda_nid_t nid = kcontrol->private_value & 0xffff;
697 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
698 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200699 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100700 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200701 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100702
703 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200704 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100705 if (val==0)
706 ctrl_data &= ~mask;
707 else
708 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200709 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
710 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100711
712 return change;
713}
714#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
715 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
716 .info = alc_spdif_ctrl_info, \
717 .get = alc_spdif_ctrl_get, \
718 .put = alc_spdif_ctrl_put, \
719 .private_value = nid | (mask<<16) }
720#endif /* CONFIG_SND_DEBUG */
721
Jonathan Woithef8225f62008-01-08 12:16:54 +0100722/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
723 * Again, this is only used in the ALC26x test models to help identify when
724 * the EAPD line must be asserted for features to work.
725 */
726#ifdef CONFIG_SND_DEBUG
727#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
728
729static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
730 struct snd_ctl_elem_value *ucontrol)
731{
732 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
733 hda_nid_t nid = kcontrol->private_value & 0xffff;
734 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
735 long *valp = ucontrol->value.integer.value;
736 unsigned int val = snd_hda_codec_read(codec, nid, 0,
737 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
738
739 *valp = (val & mask) != 0;
740 return 0;
741}
742
743static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
744 struct snd_ctl_elem_value *ucontrol)
745{
746 int change;
747 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
748 hda_nid_t nid = kcontrol->private_value & 0xffff;
749 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
750 long val = *ucontrol->value.integer.value;
751 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
752 AC_VERB_GET_EAPD_BTLENABLE,
753 0x00);
754
755 /* Set/unset the masked control bit(s) as needed */
756 change = (!val ? 0 : mask) != (ctrl_data & mask);
757 if (!val)
758 ctrl_data &= ~mask;
759 else
760 ctrl_data |= mask;
761 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
762 ctrl_data);
763
764 return change;
765}
766
767#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
768 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
769 .info = alc_eapd_ctrl_info, \
770 .get = alc_eapd_ctrl_get, \
771 .put = alc_eapd_ctrl_put, \
772 .private_value = nid | (mask<<16) }
773#endif /* CONFIG_SND_DEBUG */
774
Kailang Yangdf694da2005-12-05 19:42:22 +0100775/*
Takashi Iwai23f0c042009-02-26 13:03:58 +0100776 * set up the input pin config (depending on the given auto-pin type)
777 */
778static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
779 int auto_pin_type)
780{
781 unsigned int val = PIN_IN;
782
783 if (auto_pin_type <= AUTO_PIN_FRONT_MIC) {
784 unsigned int pincap;
Takashi Iwai1327a322009-03-23 13:07:47 +0100785 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai23f0c042009-02-26 13:03:58 +0100786 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
787 if (pincap & AC_PINCAP_VREF_80)
788 val = PIN_VREF80;
789 }
790 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
791}
792
793/*
Takashi Iwaid88897e2008-10-31 15:01:37 +0100794 */
795static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
796{
797 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
798 return;
799 spec->mixers[spec->num_mixers++] = mix;
800}
801
802static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
803{
804 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
805 return;
806 spec->init_verbs[spec->num_init_verbs++] = verb;
807}
808
Takashi Iwaidaead532008-11-28 12:55:36 +0100809#ifdef CONFIG_PROC_FS
810/*
811 * hook for proc
812 */
813static void print_realtek_coef(struct snd_info_buffer *buffer,
814 struct hda_codec *codec, hda_nid_t nid)
815{
816 int coeff;
817
818 if (nid != 0x20)
819 return;
820 coeff = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PROC_COEF, 0);
821 snd_iprintf(buffer, " Processing Coefficient: 0x%02x\n", coeff);
822 coeff = snd_hda_codec_read(codec, nid, 0,
823 AC_VERB_GET_COEF_INDEX, 0);
824 snd_iprintf(buffer, " Coefficient Index: 0x%02x\n", coeff);
825}
826#else
827#define print_realtek_coef NULL
828#endif
829
Takashi Iwaid88897e2008-10-31 15:01:37 +0100830/*
Kailang Yangdf694da2005-12-05 19:42:22 +0100831 * set up from the preset table
832 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200833static void setup_preset(struct alc_spec *spec,
834 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100835{
836 int i;
837
838 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100839 add_mixer(spec, preset->mixers[i]);
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100840 spec->cap_mixer = preset->cap_mixer;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200841 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
842 i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100843 add_verb(spec, preset->init_verbs[i]);
Kailang Yangea1fb292008-08-26 12:58:38 +0200844
Kailang Yangdf694da2005-12-05 19:42:22 +0100845 spec->channel_mode = preset->channel_mode;
846 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200847 spec->need_dac_fix = preset->need_dac_fix;
Kailang Yangdf694da2005-12-05 19:42:22 +0100848
849 spec->multiout.max_channels = spec->channel_mode[0].channels;
850
851 spec->multiout.num_dacs = preset->num_dacs;
852 spec->multiout.dac_nids = preset->dac_nids;
853 spec->multiout.dig_out_nid = preset->dig_out_nid;
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800854 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100855 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200856
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200857 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200858 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200859 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100860 spec->input_mux = preset->input_mux;
861
862 spec->num_adc_nids = preset->num_adc_nids;
863 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100864 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100865 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100866
867 spec->unsol_event = preset->unsol_event;
868 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200869#ifdef CONFIG_SND_HDA_POWER_SAVE
870 spec->loopback.amplist = preset->loopbacks;
871#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100872}
873
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200874/* Enable GPIO mask and set output */
875static struct hda_verb alc_gpio1_init_verbs[] = {
876 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
877 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
878 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
879 { }
880};
881
882static struct hda_verb alc_gpio2_init_verbs[] = {
883 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
884 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
885 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
886 { }
887};
888
Kailang Yangbdd148a2007-05-08 15:19:08 +0200889static struct hda_verb alc_gpio3_init_verbs[] = {
890 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
891 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
892 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
893 { }
894};
895
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200896/*
897 * Fix hardware PLL issue
898 * On some codecs, the analog PLL gating control must be off while
899 * the default value is 1.
900 */
901static void alc_fix_pll(struct hda_codec *codec)
902{
903 struct alc_spec *spec = codec->spec;
904 unsigned int val;
905
906 if (!spec->pll_nid)
907 return;
908 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
909 spec->pll_coef_idx);
910 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
911 AC_VERB_GET_PROC_COEF, 0);
912 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
913 spec->pll_coef_idx);
914 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
915 val & ~(1 << spec->pll_coef_bit));
916}
917
918static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
919 unsigned int coef_idx, unsigned int coef_bit)
920{
921 struct alc_spec *spec = codec->spec;
922 spec->pll_nid = nid;
923 spec->pll_coef_idx = coef_idx;
924 spec->pll_coef_bit = coef_bit;
925 alc_fix_pll(codec);
926}
927
Kailang Yangc9b58002007-10-16 14:30:01 +0200928static void alc_sku_automute(struct hda_codec *codec)
929{
930 struct alc_spec *spec = codec->spec;
Kailang Yangc9b58002007-10-16 14:30:01 +0200931 unsigned int present;
932 unsigned int hp_nid = spec->autocfg.hp_pins[0];
933 unsigned int sp_nid = spec->autocfg.speaker_pins[0];
934
935 /* need to execute and sync at first */
936 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
937 present = snd_hda_codec_read(codec, hp_nid, 0,
938 AC_VERB_GET_PIN_SENSE, 0);
939 spec->jack_present = (present & 0x80000000) != 0;
Takashi Iwaif6c7e542008-02-12 18:32:23 +0100940 snd_hda_codec_write(codec, sp_nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
941 spec->jack_present ? 0 : PIN_OUT);
Kailang Yangc9b58002007-10-16 14:30:01 +0200942}
943
Takashi Iwai4605b712008-10-31 14:18:24 +0100944#if 0 /* it's broken in some acses -- temporarily disabled */
Kailang Yang7fb0d782008-10-15 11:12:35 +0200945static void alc_mic_automute(struct hda_codec *codec)
946{
947 struct alc_spec *spec = codec->spec;
948 unsigned int present;
949 unsigned int mic_nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
950 unsigned int fmic_nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
951 unsigned int mix_nid = spec->capsrc_nids[0];
952 unsigned int capsrc_idx_mic, capsrc_idx_fmic;
953
954 capsrc_idx_mic = mic_nid - 0x18;
955 capsrc_idx_fmic = fmic_nid - 0x18;
956 present = snd_hda_codec_read(codec, mic_nid, 0,
957 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
958 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
959 0x7000 | (capsrc_idx_mic << 8) | (present ? 0 : 0x80));
960 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
961 0x7000 | (capsrc_idx_fmic << 8) | (present ? 0x80 : 0));
962 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, capsrc_idx_fmic,
963 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
964}
Takashi Iwai4605b712008-10-31 14:18:24 +0100965#else
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100966#define alc_mic_automute(codec) do {} while(0) /* NOP */
Takashi Iwai4605b712008-10-31 14:18:24 +0100967#endif /* disabled */
Kailang Yang7fb0d782008-10-15 11:12:35 +0200968
Kailang Yangc9b58002007-10-16 14:30:01 +0200969/* unsolicited event for HP jack sensing */
970static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
971{
972 if (codec->vendor_id == 0x10ec0880)
973 res >>= 28;
974 else
975 res >>= 26;
Kailang Yang7fb0d782008-10-15 11:12:35 +0200976 if (res == ALC880_HP_EVENT)
977 alc_sku_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +0200978
Kailang Yang7fb0d782008-10-15 11:12:35 +0200979 if (res == ALC880_MIC_EVENT)
980 alc_mic_automute(codec);
981}
982
983static void alc_inithook(struct hda_codec *codec)
984{
Kailang Yangc9b58002007-10-16 14:30:01 +0200985 alc_sku_automute(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +0200986 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +0200987}
988
Kailang Yangf9423e72008-05-27 12:32:25 +0200989/* additional initialization for ALC888 variants */
990static void alc888_coef_init(struct hda_codec *codec)
991{
992 unsigned int tmp;
993
994 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
995 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
996 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
Takashi Iwai37db6232009-03-05 09:40:16 +0100997 if ((tmp & 0xf0) == 0x20)
Kailang Yangf9423e72008-05-27 12:32:25 +0200998 /* alc888S-VC */
999 snd_hda_codec_read(codec, 0x20, 0,
1000 AC_VERB_SET_PROC_COEF, 0x830);
1001 else
1002 /* alc888-VB */
1003 snd_hda_codec_read(codec, 0x20, 0,
1004 AC_VERB_SET_PROC_COEF, 0x3030);
1005}
1006
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001007static void alc_auto_init_amp(struct hda_codec *codec, int type)
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001008{
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001009 unsigned int tmp;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001010
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001011 switch (type) {
1012 case ALC_INIT_GPIO1:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001013 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1014 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001015 case ALC_INIT_GPIO2:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001016 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1017 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001018 case ALC_INIT_GPIO3:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001019 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1020 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001021 case ALC_INIT_DEFAULT:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001022 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001023 case 0x10ec0260:
1024 snd_hda_codec_write(codec, 0x0f, 0,
1025 AC_VERB_SET_EAPD_BTLENABLE, 2);
1026 snd_hda_codec_write(codec, 0x10, 0,
1027 AC_VERB_SET_EAPD_BTLENABLE, 2);
1028 break;
1029 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001030 case 0x10ec0267:
1031 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001032 case 0x10ec0269:
Takashi Iwaic6e8f2d2009-02-06 12:45:52 +01001033 case 0x10ec0272:
Kailang Yangf9423e72008-05-27 12:32:25 +02001034 case 0x10ec0660:
1035 case 0x10ec0662:
1036 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001037 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001038 case 0x10ec0889:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001039 snd_hda_codec_write(codec, 0x14, 0,
1040 AC_VERB_SET_EAPD_BTLENABLE, 2);
1041 snd_hda_codec_write(codec, 0x15, 0,
1042 AC_VERB_SET_EAPD_BTLENABLE, 2);
Kailang Yangc9b58002007-10-16 14:30:01 +02001043 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001044 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001045 switch (codec->vendor_id) {
1046 case 0x10ec0260:
1047 snd_hda_codec_write(codec, 0x1a, 0,
1048 AC_VERB_SET_COEF_INDEX, 7);
1049 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1050 AC_VERB_GET_PROC_COEF, 0);
1051 snd_hda_codec_write(codec, 0x1a, 0,
1052 AC_VERB_SET_COEF_INDEX, 7);
1053 snd_hda_codec_write(codec, 0x1a, 0,
1054 AC_VERB_SET_PROC_COEF,
1055 tmp | 0x2010);
1056 break;
1057 case 0x10ec0262:
1058 case 0x10ec0880:
1059 case 0x10ec0882:
1060 case 0x10ec0883:
1061 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001062 case 0x10ec0887:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001063 case 0x10ec0889:
Kailang Yangc9b58002007-10-16 14:30:01 +02001064 snd_hda_codec_write(codec, 0x20, 0,
1065 AC_VERB_SET_COEF_INDEX, 7);
1066 tmp = snd_hda_codec_read(codec, 0x20, 0,
1067 AC_VERB_GET_PROC_COEF, 0);
1068 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001069 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001070 snd_hda_codec_write(codec, 0x20, 0,
1071 AC_VERB_SET_PROC_COEF,
1072 tmp | 0x2010);
1073 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001074 case 0x10ec0888:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001075 alc888_coef_init(codec);
Kailang Yangf9423e72008-05-27 12:32:25 +02001076 break;
Kailang Yangc9b58002007-10-16 14:30:01 +02001077 case 0x10ec0267:
1078 case 0x10ec0268:
1079 snd_hda_codec_write(codec, 0x20, 0,
1080 AC_VERB_SET_COEF_INDEX, 7);
1081 tmp = snd_hda_codec_read(codec, 0x20, 0,
1082 AC_VERB_GET_PROC_COEF, 0);
1083 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001084 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001085 snd_hda_codec_write(codec, 0x20, 0,
1086 AC_VERB_SET_PROC_COEF,
1087 tmp | 0x3000);
1088 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001089 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001090 break;
1091 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001092}
Kailang Yangea1fb292008-08-26 12:58:38 +02001093
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001094static void alc_init_auto_hp(struct hda_codec *codec)
1095{
1096 struct alc_spec *spec = codec->spec;
1097
1098 if (!spec->autocfg.hp_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +02001099 return;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001100
Kailang Yangc9b58002007-10-16 14:30:01 +02001101 if (!spec->autocfg.speaker_pins[0]) {
Kailang Yang8c427222008-01-10 13:03:59 +01001102 if (spec->autocfg.line_out_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +02001103 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +01001104 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +02001105 else
1106 return;
1107 }
1108
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001109 snd_hda_codec_write_cache(codec, spec->autocfg.hp_pins[0], 0,
1110 AC_VERB_SET_UNSOLICITED_ENABLE,
1111 AC_USRSP_EN | ALC880_HP_EVENT);
1112 spec->unsol_event = alc_sku_unsol_event;
1113}
1114
1115/* check subsystem ID and set up device-specific initialization;
1116 * return 1 if initialized, 0 if invalid SSID
1117 */
1118/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1119 * 31 ~ 16 : Manufacture ID
1120 * 15 ~ 8 : SKU ID
1121 * 7 ~ 0 : Assembly ID
1122 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1123 */
1124static int alc_subsystem_id(struct hda_codec *codec,
1125 hda_nid_t porta, hda_nid_t porte,
1126 hda_nid_t portd)
1127{
1128 unsigned int ass, tmp, i;
1129 unsigned nid;
1130 struct alc_spec *spec = codec->spec;
1131
1132 ass = codec->subsystem_id & 0xffff;
1133 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1134 goto do_sku;
1135
1136 /* invalid SSID, check the special NID pin defcfg instead */
1137 /*
1138 * 31~30 : port conetcivity
1139 * 29~21 : reserve
1140 * 20 : PCBEEP input
1141 * 19~16 : Check sum (15:1)
1142 * 15~1 : Custom
1143 * 0 : override
1144 */
1145 nid = 0x1d;
1146 if (codec->vendor_id == 0x10ec0260)
1147 nid = 0x17;
1148 ass = snd_hda_codec_get_pincfg(codec, nid);
1149 snd_printd("realtek: No valid SSID, "
1150 "checking pincfg 0x%08x for NID 0x%x\n",
1151 nid, ass);
1152 if (!(ass & 1) && !(ass & 0x100000))
1153 return 0;
1154 if ((ass >> 30) != 1) /* no physical connection */
1155 return 0;
1156
1157 /* check sum */
1158 tmp = 0;
1159 for (i = 1; i < 16; i++) {
1160 if ((ass >> i) & 1)
1161 tmp++;
1162 }
1163 if (((ass >> 16) & 0xf) != tmp)
1164 return 0;
1165do_sku:
1166 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1167 ass & 0xffff, codec->vendor_id);
1168 /*
1169 * 0 : override
1170 * 1 : Swap Jack
1171 * 2 : 0 --> Desktop, 1 --> Laptop
1172 * 3~5 : External Amplifier control
1173 * 7~6 : Reserved
1174 */
1175 tmp = (ass & 0x38) >> 3; /* external Amp control */
1176 switch (tmp) {
1177 case 1:
1178 spec->init_amp = ALC_INIT_GPIO1;
1179 break;
1180 case 3:
1181 spec->init_amp = ALC_INIT_GPIO2;
1182 break;
1183 case 7:
1184 spec->init_amp = ALC_INIT_GPIO3;
1185 break;
1186 case 5:
1187 spec->init_amp = ALC_INIT_DEFAULT;
1188 break;
1189 }
1190
1191 /* is laptop or Desktop and enable the function "Mute internal speaker
1192 * when the external headphone out jack is plugged"
1193 */
1194 if (!(ass & 0x8000))
1195 return 1;
1196 /*
1197 * 10~8 : Jack location
1198 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1199 * 14~13: Resvered
1200 * 15 : 1 --> enable the function "Mute internal speaker
1201 * when the external headphone out jack is plugged"
1202 */
Kailang Yangc9b58002007-10-16 14:30:01 +02001203 if (!spec->autocfg.hp_pins[0]) {
1204 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1205 if (tmp == 0)
1206 spec->autocfg.hp_pins[0] = porta;
1207 else if (tmp == 1)
1208 spec->autocfg.hp_pins[0] = porte;
1209 else if (tmp == 2)
1210 spec->autocfg.hp_pins[0] = portd;
1211 else
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001212 return 1;
Kailang Yangc9b58002007-10-16 14:30:01 +02001213 }
1214
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001215 alc_init_auto_hp(codec);
1216 return 1;
1217}
Kailang Yangea1fb292008-08-26 12:58:38 +02001218
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001219static void alc_ssid_check(struct hda_codec *codec,
1220 hda_nid_t porta, hda_nid_t porte, hda_nid_t portd)
1221{
1222 if (!alc_subsystem_id(codec, porta, porte, portd)) {
1223 struct alc_spec *spec = codec->spec;
1224 snd_printd("realtek: "
1225 "Enable default setup for auto mode as fallback\n");
1226 spec->init_amp = ALC_INIT_DEFAULT;
1227 alc_init_auto_hp(codec);
1228 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001229}
1230
Takashi Iwai41e41f12005-06-08 14:48:49 +02001231/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02001232 * Fix-up pin default configurations
1233 */
1234
1235struct alc_pincfg {
1236 hda_nid_t nid;
1237 u32 val;
1238};
1239
1240static void alc_fix_pincfg(struct hda_codec *codec,
1241 const struct snd_pci_quirk *quirk,
1242 const struct alc_pincfg **pinfix)
1243{
1244 const struct alc_pincfg *cfg;
1245
1246 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1247 if (!quirk)
1248 return;
1249
1250 cfg = pinfix[quirk->value];
Takashi Iwai0e8a21b2009-02-20 14:13:06 +01001251 for (; cfg->nid; cfg++)
1252 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
Takashi Iwaif95474e2007-07-10 00:47:43 +02001253}
1254
1255/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001256 * ALC888
1257 */
1258
1259/*
1260 * 2ch mode
1261 */
1262static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1263/* Mic-in jack as mic in */
1264 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1265 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1266/* Line-in jack as Line in */
1267 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1268 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1269/* Line-Out as Front */
1270 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1271 { } /* end */
1272};
1273
1274/*
1275 * 4ch mode
1276 */
1277static struct hda_verb alc888_4ST_ch4_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 Surround */
1282 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1283 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1284/* Line-Out as Front */
1285 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1286 { } /* end */
1287};
1288
1289/*
1290 * 6ch mode
1291 */
1292static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1293/* Mic-in jack as CLFE */
1294 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1295 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
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 CLFE (workaround because Mic-in is not loud enough) */
1300 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1301 { } /* end */
1302};
1303
1304/*
1305 * 8ch mode
1306 */
1307static struct hda_verb alc888_4ST_ch8_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 Side */
1315 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1316 { } /* end */
1317};
1318
1319static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1320 { 2, alc888_4ST_ch2_intel_init },
1321 { 4, alc888_4ST_ch4_intel_init },
1322 { 6, alc888_4ST_ch6_intel_init },
1323 { 8, alc888_4ST_ch8_intel_init },
1324};
1325
1326/*
1327 * ALC888 Fujitsu Siemens Amillo xa3530
1328 */
1329
1330static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1331/* Front Mic: set to PIN_IN (empty by default) */
1332 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1333/* Connect Internal HP to Front */
1334 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1335 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1336 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1337/* Connect Bass HP to Front */
1338 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1339 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1340 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1341/* Connect Line-Out side jack (SPDIF) to Side */
1342 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1343 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1344 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1345/* Connect Mic jack to CLFE */
1346 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1347 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1348 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1349/* Connect Line-in jack to Surround */
1350 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1351 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1352 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1353/* Connect HP out jack to Front */
1354 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1355 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1356 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1357/* Enable unsolicited event for HP jack and Line-out jack */
1358 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1359 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1360 {}
1361};
1362
1363static void alc888_fujitsu_xa3530_automute(struct hda_codec *codec)
1364{
1365 unsigned int present;
1366 unsigned int bits;
1367 /* Line out presence */
1368 present = snd_hda_codec_read(codec, 0x17, 0,
1369 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1370 /* HP out presence */
1371 present = present || snd_hda_codec_read(codec, 0x1b, 0,
1372 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1373 bits = present ? HDA_AMP_MUTE : 0;
1374 /* Toggle internal speakers muting */
1375 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
1376 HDA_AMP_MUTE, bits);
1377 /* Toggle internal bass muting */
1378 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
1379 HDA_AMP_MUTE, bits);
1380}
1381
1382static void alc888_fujitsu_xa3530_unsol_event(struct hda_codec *codec,
1383 unsigned int res)
1384{
1385 if (res >> 26 == ALC880_HP_EVENT)
1386 alc888_fujitsu_xa3530_automute(codec);
1387}
1388
1389
1390/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001391 * ALC888 Acer Aspire 4930G model
1392 */
1393
1394static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1395/* Front Mic: set to PIN_IN (empty by default) */
1396 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1397/* Unselect Front Mic by default in input mixer 3 */
1398 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001399/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001400 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1401/* Connect Internal HP to front */
1402 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1403 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1404 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1405/* Connect HP out to front */
1406 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1407 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1408 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1409 { }
1410};
1411
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001412static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001413 /* Front mic only available on one ADC */
1414 {
1415 .num_items = 4,
1416 .items = {
1417 { "Mic", 0x0 },
1418 { "Line", 0x2 },
1419 { "CD", 0x4 },
1420 { "Front Mic", 0xb },
1421 },
1422 },
1423 {
1424 .num_items = 3,
1425 .items = {
1426 { "Mic", 0x0 },
1427 { "Line", 0x2 },
1428 { "CD", 0x4 },
1429 },
1430 }
1431};
1432
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001433static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001434 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1435 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1436 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1437 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1438 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1439 HDA_OUTPUT),
1440 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1441 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1442 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1443 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1444 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1445 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1446 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1447 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1448 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1449 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1450 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1451 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001452 { } /* end */
1453};
1454
1455static void alc888_acer_aspire_4930g_automute(struct hda_codec *codec)
1456{
1457 unsigned int present;
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001458 unsigned int bits;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001459 present = snd_hda_codec_read(codec, 0x15, 0,
1460 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001461 bits = present ? HDA_AMP_MUTE : 0;
1462 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
1463 HDA_AMP_MUTE, bits);
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001464}
1465
1466static void alc888_acer_aspire_4930g_unsol_event(struct hda_codec *codec,
1467 unsigned int res)
1468{
1469 if (res >> 26 == ALC880_HP_EVENT)
1470 alc888_acer_aspire_4930g_automute(codec);
1471}
1472
1473/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001474 * ALC880 3-stack model
1475 *
1476 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001477 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1478 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07001479 */
1480
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001481static hda_nid_t alc880_dac_nids[4] = {
1482 /* front, rear, clfe, rear_surr */
1483 0x02, 0x05, 0x04, 0x03
1484};
1485
1486static hda_nid_t alc880_adc_nids[3] = {
1487 /* ADC0-2 */
1488 0x07, 0x08, 0x09,
1489};
1490
1491/* The datasheet says the node 0x07 is connected from inputs,
1492 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01001493 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07001494 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001495static hda_nid_t alc880_adc_nids_alt[2] = {
1496 /* ADC1-2 */
1497 0x08, 0x09,
1498};
1499
1500#define ALC880_DIGOUT_NID 0x06
1501#define ALC880_DIGIN_NID 0x0a
1502
1503static struct hda_input_mux alc880_capture_source = {
1504 .num_items = 4,
1505 .items = {
1506 { "Mic", 0x0 },
1507 { "Front Mic", 0x3 },
1508 { "Line", 0x2 },
1509 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001510 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001511};
1512
1513/* channel source setting (2/6 channel selection for 3-stack) */
1514/* 2ch mode */
1515static struct hda_verb alc880_threestack_ch2_init[] = {
1516 /* set line-in to input, mute it */
1517 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1518 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1519 /* set mic-in to input vref 80%, mute it */
1520 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1521 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001522 { } /* end */
1523};
1524
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001525/* 6ch mode */
1526static struct hda_verb alc880_threestack_ch6_init[] = {
1527 /* set line-in to output, unmute it */
1528 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1529 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1530 /* set mic-in to output, unmute it */
1531 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1532 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1533 { } /* end */
1534};
1535
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001536static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001537 { 2, alc880_threestack_ch2_init },
1538 { 6, alc880_threestack_ch6_init },
1539};
1540
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001541static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001542 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001543 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001544 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001545 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001546 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1547 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001548 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1549 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001550 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1551 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1552 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1553 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1554 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1555 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1556 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1557 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001558 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001559 {
1560 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1561 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001562 .info = alc_ch_mode_info,
1563 .get = alc_ch_mode_get,
1564 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001565 },
1566 { } /* end */
1567};
1568
1569/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001570static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1571 struct snd_ctl_elem_info *uinfo)
1572{
1573 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1574 struct alc_spec *spec = codec->spec;
1575 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001576
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001577 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001578 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1579 HDA_INPUT);
1580 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001581 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001582 return err;
1583}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001584
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001585static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1586 unsigned int size, unsigned int __user *tlv)
1587{
1588 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1589 struct alc_spec *spec = codec->spec;
1590 int err;
1591
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001592 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001593 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1594 HDA_INPUT);
1595 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001596 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001597 return err;
1598}
1599
1600typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1601 struct snd_ctl_elem_value *ucontrol);
1602
1603static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1604 struct snd_ctl_elem_value *ucontrol,
1605 getput_call_t func)
1606{
1607 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1608 struct alc_spec *spec = codec->spec;
1609 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1610 int err;
1611
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001612 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001613 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
1614 3, 0, HDA_INPUT);
1615 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001616 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001617 return err;
1618}
1619
1620static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
1621 struct snd_ctl_elem_value *ucontrol)
1622{
1623 return alc_cap_getput_caller(kcontrol, ucontrol,
1624 snd_hda_mixer_amp_volume_get);
1625}
1626
1627static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
1628 struct snd_ctl_elem_value *ucontrol)
1629{
1630 return alc_cap_getput_caller(kcontrol, ucontrol,
1631 snd_hda_mixer_amp_volume_put);
1632}
1633
1634/* capture mixer elements */
1635#define alc_cap_sw_info snd_ctl_boolean_stereo_info
1636
1637static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
1638 struct snd_ctl_elem_value *ucontrol)
1639{
1640 return alc_cap_getput_caller(kcontrol, ucontrol,
1641 snd_hda_mixer_amp_switch_get);
1642}
1643
1644static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
1645 struct snd_ctl_elem_value *ucontrol)
1646{
1647 return alc_cap_getput_caller(kcontrol, ucontrol,
1648 snd_hda_mixer_amp_switch_put);
1649}
1650
Takashi Iwaia23b6882009-03-23 15:21:36 +01001651#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001652 { \
1653 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1654 .name = "Capture Switch", \
1655 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1656 .count = num, \
1657 .info = alc_cap_sw_info, \
1658 .get = alc_cap_sw_get, \
1659 .put = alc_cap_sw_put, \
1660 }, \
1661 { \
1662 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1663 .name = "Capture Volume", \
1664 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1665 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1666 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
1667 .count = num, \
1668 .info = alc_cap_vol_info, \
1669 .get = alc_cap_vol_get, \
1670 .put = alc_cap_vol_put, \
1671 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01001672 }
1673
1674#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01001675 { \
1676 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1677 /* .name = "Capture Source", */ \
1678 .name = "Input Source", \
1679 .count = num, \
1680 .info = alc_mux_enum_info, \
1681 .get = alc_mux_enum_get, \
1682 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01001683 }
1684
1685#define DEFINE_CAPMIX(num) \
1686static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
1687 _DEFINE_CAPMIX(num), \
1688 _DEFINE_CAPSRC(num), \
1689 { } /* end */ \
1690}
1691
1692#define DEFINE_CAPMIX_NOSRC(num) \
1693static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
1694 _DEFINE_CAPMIX(num), \
1695 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001696}
1697
1698/* up to three ADCs */
1699DEFINE_CAPMIX(1);
1700DEFINE_CAPMIX(2);
1701DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01001702DEFINE_CAPMIX_NOSRC(1);
1703DEFINE_CAPMIX_NOSRC(2);
1704DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001705
1706/*
1707 * ALC880 5-stack model
1708 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001709 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
1710 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001711 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
1712 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
1713 */
1714
1715/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001716static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001717 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001718 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001719 { } /* end */
1720};
1721
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001722/* channel source setting (6/8 channel selection for 5-stack) */
1723/* 6ch mode */
1724static struct hda_verb alc880_fivestack_ch6_init[] = {
1725 /* set line-in to input, mute it */
1726 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1727 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001728 { } /* end */
1729};
1730
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001731/* 8ch mode */
1732static struct hda_verb alc880_fivestack_ch8_init[] = {
1733 /* set line-in to output, unmute it */
1734 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1735 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1736 { } /* end */
1737};
1738
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001739static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001740 { 6, alc880_fivestack_ch6_init },
1741 { 8, alc880_fivestack_ch8_init },
1742};
1743
1744
1745/*
1746 * ALC880 6-stack model
1747 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001748 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
1749 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001750 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
1751 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
1752 */
1753
1754static hda_nid_t alc880_6st_dac_nids[4] = {
1755 /* front, rear, clfe, rear_surr */
1756 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001757};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001758
1759static struct hda_input_mux alc880_6stack_capture_source = {
1760 .num_items = 4,
1761 .items = {
1762 { "Mic", 0x0 },
1763 { "Front Mic", 0x1 },
1764 { "Line", 0x2 },
1765 { "CD", 0x4 },
1766 },
1767};
1768
1769/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001770static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001771 { 8, NULL },
1772};
1773
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001774static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001775 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001776 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001777 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001778 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001779 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1780 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001781 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1782 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001783 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001784 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001785 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1786 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1787 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1788 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1789 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1790 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1791 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1792 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001793 {
1794 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1795 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001796 .info = alc_ch_mode_info,
1797 .get = alc_ch_mode_get,
1798 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001799 },
1800 { } /* end */
1801};
1802
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001803
1804/*
1805 * ALC880 W810 model
1806 *
1807 * W810 has rear IO for:
1808 * Front (DAC 02)
1809 * Surround (DAC 03)
1810 * Center/LFE (DAC 04)
1811 * Digital out (06)
1812 *
1813 * The system also has a pair of internal speakers, and a headphone jack.
1814 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02001815 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001816 * There is a variable resistor to control the speaker or headphone
1817 * volume. This is a hardware-only device without a software API.
1818 *
1819 * Plugging headphones in will disable the internal speakers. This is
1820 * implemented in hardware, not via the driver using jack sense. In
1821 * a similar fashion, plugging into the rear socket marked "front" will
1822 * disable both the speakers and headphones.
1823 *
1824 * For input, there's a microphone jack, and an "audio in" jack.
1825 * These may not do anything useful with this driver yet, because I
1826 * haven't setup any initialization verbs for these yet...
1827 */
1828
1829static hda_nid_t alc880_w810_dac_nids[3] = {
1830 /* front, rear/surround, clfe */
1831 0x02, 0x03, 0x04
1832};
1833
1834/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001835static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001836 { 6, NULL }
1837};
1838
1839/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001840static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001841 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001842 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001843 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001844 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001845 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1846 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001847 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1848 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001849 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1850 { } /* end */
1851};
1852
1853
1854/*
1855 * Z710V model
1856 *
1857 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001858 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1859 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001860 */
1861
1862static hda_nid_t alc880_z71v_dac_nids[1] = {
1863 0x02
1864};
1865#define ALC880_Z71V_HP_DAC 0x03
1866
1867/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001868static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001869 { 2, NULL }
1870};
1871
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001872static struct snd_kcontrol_new alc880_z71v_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("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001876 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001877 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1878 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1879 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1880 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1881 { } /* end */
1882};
1883
1884
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001885/*
1886 * ALC880 F1734 model
1887 *
1888 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1889 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1890 */
1891
1892static hda_nid_t alc880_f1734_dac_nids[1] = {
1893 0x03
1894};
1895#define ALC880_F1734_HP_DAC 0x02
1896
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001897static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001898 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001899 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01001900 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1901 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001902 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1903 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01001904 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1905 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001906 { } /* end */
1907};
1908
Takashi Iwai937b4162008-02-11 14:52:36 +01001909static struct hda_input_mux alc880_f1734_capture_source = {
1910 .num_items = 2,
1911 .items = {
1912 { "Mic", 0x1 },
1913 { "CD", 0x4 },
1914 },
1915};
1916
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001917
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001918/*
1919 * ALC880 ASUS model
1920 *
1921 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1922 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1923 * Mic = 0x18, Line = 0x1a
1924 */
1925
1926#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1927#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1928
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001929static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001930 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001931 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001932 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001933 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001934 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1935 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001936 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1937 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001938 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1939 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1940 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1941 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1942 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1943 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001944 {
1945 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1946 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001947 .info = alc_ch_mode_info,
1948 .get = alc_ch_mode_get,
1949 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001950 },
1951 { } /* end */
1952};
1953
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001954/*
1955 * ALC880 ASUS W1V model
1956 *
1957 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1958 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1959 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1960 */
1961
1962/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001963static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001964 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1965 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001966 { } /* end */
1967};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001968
Kailang Yangdf694da2005-12-05 19:42:22 +01001969/* TCL S700 */
1970static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1971 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1972 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1973 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1974 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1975 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1976 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1977 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1978 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1979 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01001980 { } /* end */
1981};
1982
Kailang Yangccc656c2006-10-17 12:32:26 +02001983/* Uniwill */
1984static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001985 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1986 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1987 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1988 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001989 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1990 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1991 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1992 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1993 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1994 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1995 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1996 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1997 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1998 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1999 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2000 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002001 {
2002 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2003 .name = "Channel Mode",
2004 .info = alc_ch_mode_info,
2005 .get = alc_ch_mode_get,
2006 .put = alc_ch_mode_put,
2007 },
2008 { } /* end */
2009};
2010
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002011static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2012 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2013 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2014 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2015 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2016 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2017 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2018 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2019 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2020 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2021 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2022 { } /* end */
2023};
2024
Kailang Yangccc656c2006-10-17 12:32:26 +02002025static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002026 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2027 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2028 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2029 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002030 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2031 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2032 { } /* end */
2033};
2034
Linus Torvalds1da177e2005-04-16 15:20:36 -07002035/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01002036 * virtual master controls
2037 */
2038
2039/*
2040 * slave controls for virtual master
2041 */
2042static const char *alc_slave_vols[] = {
2043 "Front Playback Volume",
2044 "Surround Playback Volume",
2045 "Center Playback Volume",
2046 "LFE Playback Volume",
2047 "Side Playback Volume",
2048 "Headphone Playback Volume",
2049 "Speaker Playback Volume",
2050 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002051 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01002052 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002053 NULL,
2054};
2055
2056static const char *alc_slave_sws[] = {
2057 "Front Playback Switch",
2058 "Surround Playback Switch",
2059 "Center Playback Switch",
2060 "LFE Playback Switch",
2061 "Side Playback Switch",
2062 "Headphone Playback Switch",
2063 "Speaker Playback Switch",
2064 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01002065 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002066 NULL,
2067};
2068
2069/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002070 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002071 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002072
2073static void alc_free_kctls(struct hda_codec *codec);
2074
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002075/* additional beep mixers; the actual parameters are overwritten at build */
2076static struct snd_kcontrol_new alc_beep_mixer[] = {
2077 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
2078 HDA_CODEC_MUTE("Beep Playback Switch", 0, 0, HDA_INPUT),
2079 { } /* end */
2080};
2081
Linus Torvalds1da177e2005-04-16 15:20:36 -07002082static int alc_build_controls(struct hda_codec *codec)
2083{
2084 struct alc_spec *spec = codec->spec;
2085 int err;
2086 int i;
2087
2088 for (i = 0; i < spec->num_mixers; i++) {
2089 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2090 if (err < 0)
2091 return err;
2092 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002093 if (spec->cap_mixer) {
2094 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2095 if (err < 0)
2096 return err;
2097 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002098 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002099 err = snd_hda_create_spdif_out_ctls(codec,
2100 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002101 if (err < 0)
2102 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002103 if (!spec->no_analog) {
2104 err = snd_hda_create_spdif_share_sw(codec,
2105 &spec->multiout);
2106 if (err < 0)
2107 return err;
2108 spec->multiout.share_spdif = 1;
2109 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002110 }
2111 if (spec->dig_in_nid) {
2112 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2113 if (err < 0)
2114 return err;
2115 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002116
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002117 /* create beep controls if needed */
2118 if (spec->beep_amp) {
2119 struct snd_kcontrol_new *knew;
2120 for (knew = alc_beep_mixer; knew->name; knew++) {
2121 struct snd_kcontrol *kctl;
2122 kctl = snd_ctl_new1(knew, codec);
2123 if (!kctl)
2124 return -ENOMEM;
2125 kctl->private_value = spec->beep_amp;
2126 err = snd_hda_ctl_add(codec, kctl);
2127 if (err < 0)
2128 return err;
2129 }
2130 }
2131
Takashi Iwai2134ea42008-01-10 16:53:55 +01002132 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002133 if (!spec->no_analog &&
2134 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002135 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002136 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002137 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002138 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002139 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002140 if (err < 0)
2141 return err;
2142 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002143 if (!spec->no_analog &&
2144 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002145 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2146 NULL, alc_slave_sws);
2147 if (err < 0)
2148 return err;
2149 }
2150
Takashi Iwai603c4012008-07-30 15:01:44 +02002151 alc_free_kctls(codec); /* no longer needed */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002152 return 0;
2153}
2154
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002155
Linus Torvalds1da177e2005-04-16 15:20:36 -07002156/*
2157 * initialize the codec volumes, etc
2158 */
2159
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002160/*
2161 * generic initialization of ADC, input mixers and output mixers
2162 */
2163static struct hda_verb alc880_volume_init_verbs[] = {
2164 /*
2165 * Unmute ADC0-2 and set the default input to mic-in
2166 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002167 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002168 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002169 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002170 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002171 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002172 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002173
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002174 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2175 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002176 * Note: PASD motherboards uses the Line In 2 as the input for front
2177 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002178 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002179 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02002180 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2181 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2182 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2183 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2184 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2185 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2186 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002187
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002188 /*
2189 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002190 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002191 /* set vol=0 to output mixers */
2192 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2193 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2194 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2195 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2196 /* set up input amps for analog loopback */
2197 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002198 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2199 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002200 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2201 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002202 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2203 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002204 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2205 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002206
2207 { }
2208};
2209
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002210/*
2211 * 3-stack pin configuration:
2212 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2213 */
2214static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2215 /*
2216 * preset connection lists of input pins
2217 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2218 */
2219 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2220 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2221 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2222
2223 /*
2224 * Set pin mode and muting
2225 */
2226 /* set front pin widgets 0x14 for output */
2227 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2228 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2229 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2230 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2231 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2232 /* Mic2 (as headphone out) for HP output */
2233 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2234 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2235 /* Line In pin widget for input */
2236 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2237 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2238 /* Line2 (as front mic) pin widget for input and vref at 80% */
2239 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2240 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2241 /* CD pin widget for input */
2242 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2243
2244 { }
2245};
2246
2247/*
2248 * 5-stack pin configuration:
2249 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2250 * line-in/side = 0x1a, f-mic = 0x1b
2251 */
2252static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2253 /*
2254 * preset connection lists of input pins
2255 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2256 */
2257 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2258 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2259
2260 /*
2261 * Set pin mode and muting
2262 */
2263 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02002264 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2265 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2266 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2267 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002268 /* unmute pins for output (no gain on this amp) */
2269 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2270 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2271 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2272 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2273
Linus Torvalds1da177e2005-04-16 15:20:36 -07002274 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02002275 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002276 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2277 /* Mic2 (as headphone out) for HP output */
2278 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002279 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002280 /* Line In pin widget for input */
2281 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2282 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2283 /* Line2 (as front mic) pin widget for input and vref at 80% */
2284 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2285 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2286 /* CD pin widget for input */
2287 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002288
2289 { }
2290};
2291
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002292/*
2293 * W810 pin configuration:
2294 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2295 */
2296static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002297 /* hphone/speaker input selector: front DAC */
2298 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2299
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002300 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2301 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2302 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2303 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2304 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2305 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2306
2307 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002308 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002309
Linus Torvalds1da177e2005-04-16 15:20:36 -07002310 { }
2311};
2312
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002313/*
2314 * Z71V pin configuration:
2315 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2316 */
2317static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002318 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002319 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02002320 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002321 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002322
Takashi Iwai16ded522005-06-10 19:58:24 +02002323 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002324 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002325 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002326 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002327
2328 { }
2329};
2330
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002331/*
2332 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002333 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2334 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002335 */
2336static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2337 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2338
Takashi Iwai16ded522005-06-10 19:58:24 +02002339 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002340 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002341 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002342 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002343 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002344 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002345 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002346 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2347
Takashi Iwai16ded522005-06-10 19:58:24 +02002348 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002349 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002350 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002351 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002352 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002353 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002354 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02002355 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002356 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002357
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002358 { }
2359};
Takashi Iwai16ded522005-06-10 19:58:24 +02002360
Kailang Yangccc656c2006-10-17 12:32:26 +02002361/*
2362 * Uniwill pin configuration:
2363 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2364 * line = 0x1a
2365 */
2366static struct hda_verb alc880_uniwill_init_verbs[] = {
2367 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2368
2369 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2370 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2371 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2372 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2373 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2374 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2375 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2376 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2377 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2378 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2379 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2380 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2381 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2382 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2383
2384 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2385 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2386 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2387 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2388 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2389 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2390 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2391 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2392 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2393
2394 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2395 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2396
2397 { }
2398};
2399
2400/*
2401* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02002402* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02002403 */
2404static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2405 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2406
2407 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2408 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2409 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2410 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2411 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2412 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2413 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2414 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2415 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2416 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2417 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2418 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2419
2420 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2421 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2422 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2423 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2424 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2425 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2426
2427 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2428 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2429
2430 { }
2431};
2432
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002433static struct hda_verb alc880_beep_init_verbs[] = {
2434 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2435 { }
2436};
2437
Kailang Yangccc656c2006-10-17 12:32:26 +02002438/* toggle speaker-output according to the hp-jack state */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002439static void alc880_uniwill_hp_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02002440{
2441 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002442 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002443
2444 present = snd_hda_codec_read(codec, 0x14, 0,
2445 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002446 bits = present ? HDA_AMP_MUTE : 0;
2447 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
2448 HDA_AMP_MUTE, bits);
2449 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
2450 HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002451}
2452
2453/* auto-toggle front mic */
2454static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2455{
2456 unsigned int present;
2457 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002458
2459 present = snd_hda_codec_read(codec, 0x18, 0,
2460 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002461 bits = present ? HDA_AMP_MUTE : 0;
2462 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002463}
2464
2465static void alc880_uniwill_automute(struct hda_codec *codec)
2466{
2467 alc880_uniwill_hp_automute(codec);
2468 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002469}
2470
2471static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2472 unsigned int res)
2473{
2474 /* Looks like the unsol event is incompatible with the standard
2475 * definition. 4bit tag is placed at 28 bit!
2476 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002477 switch (res >> 28) {
2478 case ALC880_HP_EVENT:
2479 alc880_uniwill_hp_automute(codec);
2480 break;
2481 case ALC880_MIC_EVENT:
2482 alc880_uniwill_mic_automute(codec);
2483 break;
2484 }
Kailang Yangccc656c2006-10-17 12:32:26 +02002485}
2486
2487static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
2488{
2489 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002490 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002491
2492 present = snd_hda_codec_read(codec, 0x14, 0,
2493 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002494 bits = present ? HDA_AMP_MUTE : 0;
Jiang zhe64654c22008-04-14 13:26:21 +02002495 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, HDA_AMP_MUTE, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02002496}
2497
2498static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2499{
2500 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02002501
Kailang Yangccc656c2006-10-17 12:32:26 +02002502 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02002503 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2504 present &= HDA_AMP_VOLMASK;
2505 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2506 HDA_AMP_VOLMASK, present);
2507 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2508 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02002509}
Takashi Iwai47fd8302007-08-10 17:11:07 +02002510
Kailang Yangccc656c2006-10-17 12:32:26 +02002511static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2512 unsigned int res)
2513{
2514 /* Looks like the unsol event is incompatible with the standard
2515 * definition. 4bit tag is placed at 28 bit!
2516 */
2517 if ((res >> 28) == ALC880_HP_EVENT)
2518 alc880_uniwill_p53_hp_automute(codec);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002519 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02002520 alc880_uniwill_p53_dcvol_automute(codec);
2521}
2522
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002523/*
2524 * F1734 pin configuration:
2525 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2526 */
2527static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01002528 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002529 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2530 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2531 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2532 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2533
2534 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2535 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2536 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2537 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2538
2539 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2540 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01002541 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002542 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2543 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2544 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2545 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2546 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2547 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002548
Takashi Iwai937b4162008-02-11 14:52:36 +01002549 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2550 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2551
Takashi Iwai16ded522005-06-10 19:58:24 +02002552 { }
2553};
2554
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002555/*
2556 * ASUS pin configuration:
2557 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2558 */
2559static struct hda_verb alc880_pin_asus_init_verbs[] = {
2560 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2561 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2562 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2563 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2564
2565 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2566 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2567 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2568 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2569 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2570 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2571 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2572 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2573
2574 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2575 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2576 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2577 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2578 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2579 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2580 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2581 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2582 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002583
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002584 { }
2585};
2586
2587/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02002588#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2589#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002590
Kailang Yangdf694da2005-12-05 19:42:22 +01002591/* Clevo m520g init */
2592static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2593 /* headphone output */
2594 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2595 /* line-out */
2596 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2597 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2598 /* Line-in */
2599 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2600 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2601 /* CD */
2602 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2603 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2604 /* Mic1 (rear panel) */
2605 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2606 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2607 /* Mic2 (front panel) */
2608 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2609 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2610 /* headphone */
2611 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2612 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2613 /* change to EAPD mode */
2614 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2615 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2616
2617 { }
2618};
2619
2620static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002621 /* change to EAPD mode */
2622 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2623 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2624
Kailang Yangdf694da2005-12-05 19:42:22 +01002625 /* Headphone output */
2626 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2627 /* Front output*/
2628 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2629 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2630
2631 /* Line In pin widget for input */
2632 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2633 /* CD pin widget for input */
2634 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2635 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2636 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2637
2638 /* change to EAPD mode */
2639 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2640 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2641
2642 { }
2643};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002644
2645/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002646 * LG m1 express dual
2647 *
2648 * Pin assignment:
2649 * Rear Line-In/Out (blue): 0x14
2650 * Build-in Mic-In: 0x15
2651 * Speaker-out: 0x17
2652 * HP-Out (green): 0x1b
2653 * Mic-In/Out (red): 0x19
2654 * SPDIF-Out: 0x1e
2655 */
2656
2657/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2658static hda_nid_t alc880_lg_dac_nids[3] = {
2659 0x05, 0x02, 0x03
2660};
2661
2662/* seems analog CD is not working */
2663static struct hda_input_mux alc880_lg_capture_source = {
2664 .num_items = 3,
2665 .items = {
2666 { "Mic", 0x1 },
2667 { "Line", 0x5 },
2668 { "Internal Mic", 0x6 },
2669 },
2670};
2671
2672/* 2,4,6 channel modes */
2673static struct hda_verb alc880_lg_ch2_init[] = {
2674 /* set line-in and mic-in to input */
2675 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2676 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2677 { }
2678};
2679
2680static struct hda_verb alc880_lg_ch4_init[] = {
2681 /* set line-in to out and mic-in to input */
2682 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2683 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2684 { }
2685};
2686
2687static struct hda_verb alc880_lg_ch6_init[] = {
2688 /* set line-in and mic-in to output */
2689 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2690 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2691 { }
2692};
2693
2694static struct hda_channel_mode alc880_lg_ch_modes[3] = {
2695 { 2, alc880_lg_ch2_init },
2696 { 4, alc880_lg_ch4_init },
2697 { 6, alc880_lg_ch6_init },
2698};
2699
2700static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002701 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2702 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002703 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2704 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
2705 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
2706 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
2707 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
2708 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
2709 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2710 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2711 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
2712 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
2713 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
2714 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
2715 {
2716 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2717 .name = "Channel Mode",
2718 .info = alc_ch_mode_info,
2719 .get = alc_ch_mode_get,
2720 .put = alc_ch_mode_put,
2721 },
2722 { } /* end */
2723};
2724
2725static struct hda_verb alc880_lg_init_verbs[] = {
2726 /* set capture source to mic-in */
2727 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2728 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2729 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2730 /* mute all amp mixer inputs */
2731 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002732 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2733 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002734 /* line-in to input */
2735 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2736 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2737 /* built-in mic */
2738 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2739 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2740 /* speaker-out */
2741 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2742 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2743 /* mic-in to input */
2744 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2745 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2746 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2747 /* HP-out */
2748 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
2749 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2750 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2751 /* jack sense */
2752 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2753 { }
2754};
2755
2756/* toggle speaker-output according to the hp-jack state */
2757static void alc880_lg_automute(struct hda_codec *codec)
2758{
2759 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002760 unsigned char bits;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002761
2762 present = snd_hda_codec_read(codec, 0x1b, 0,
2763 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002764 bits = present ? HDA_AMP_MUTE : 0;
2765 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
2766 HDA_AMP_MUTE, bits);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002767}
2768
2769static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
2770{
2771 /* Looks like the unsol event is incompatible with the standard
2772 * definition. 4bit tag is placed at 28 bit!
2773 */
2774 if ((res >> 28) == 0x01)
2775 alc880_lg_automute(codec);
2776}
2777
2778/*
Takashi Iwaid6815182006-03-23 16:06:23 +01002779 * LG LW20
2780 *
2781 * Pin assignment:
2782 * Speaker-out: 0x14
2783 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002784 * Built-in Mic-In: 0x19
2785 * Line-In: 0x1b
2786 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01002787 * SPDIF-Out: 0x1e
2788 */
2789
Takashi Iwaid6815182006-03-23 16:06:23 +01002790static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002791 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01002792 .items = {
2793 { "Mic", 0x0 },
2794 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002795 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002796 },
2797};
2798
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002799#define alc880_lg_lw_modes alc880_threestack_modes
2800
Takashi Iwaid6815182006-03-23 16:06:23 +01002801static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002802 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2803 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2804 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2805 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2806 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2807 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2808 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2809 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2810 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2811 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01002812 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2813 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2814 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
2815 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002816 {
2817 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2818 .name = "Channel Mode",
2819 .info = alc_ch_mode_info,
2820 .get = alc_ch_mode_get,
2821 .put = alc_ch_mode_put,
2822 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002823 { } /* end */
2824};
2825
2826static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002827 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2828 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2829 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2830
Takashi Iwaid6815182006-03-23 16:06:23 +01002831 /* set capture source to mic-in */
2832 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2833 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2834 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002835 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01002836 /* speaker-out */
2837 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2838 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2839 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01002840 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2841 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2842 /* mic-in to input */
2843 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2844 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2845 /* built-in mic */
2846 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2847 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2848 /* jack sense */
2849 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2850 { }
2851};
2852
2853/* toggle speaker-output according to the hp-jack state */
2854static void alc880_lg_lw_automute(struct hda_codec *codec)
2855{
2856 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002857 unsigned char bits;
Takashi Iwaid6815182006-03-23 16:06:23 +01002858
2859 present = snd_hda_codec_read(codec, 0x1b, 0,
2860 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002861 bits = present ? HDA_AMP_MUTE : 0;
2862 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
2863 HDA_AMP_MUTE, bits);
Takashi Iwaid6815182006-03-23 16:06:23 +01002864}
2865
2866static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
2867{
2868 /* Looks like the unsol event is incompatible with the standard
2869 * definition. 4bit tag is placed at 28 bit!
2870 */
2871 if ((res >> 28) == 0x01)
2872 alc880_lg_lw_automute(codec);
2873}
2874
Takashi Iwaidf99cd32008-04-25 15:25:04 +02002875static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
2876 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2877 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
2878 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2879 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2880 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2881 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
2882 { } /* end */
2883};
2884
2885static struct hda_input_mux alc880_medion_rim_capture_source = {
2886 .num_items = 2,
2887 .items = {
2888 { "Mic", 0x0 },
2889 { "Internal Mic", 0x1 },
2890 },
2891};
2892
2893static struct hda_verb alc880_medion_rim_init_verbs[] = {
2894 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2895
2896 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2897 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2898
2899 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2900 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2901 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2902 /* Mic2 (as headphone out) for HP output */
2903 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2904 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2905 /* Internal Speaker */
2906 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2907 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2908
2909 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2910 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2911
2912 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2913 { }
2914};
2915
2916/* toggle speaker-output according to the hp-jack state */
2917static void alc880_medion_rim_automute(struct hda_codec *codec)
2918{
2919 unsigned int present;
2920 unsigned char bits;
2921
2922 present = snd_hda_codec_read(codec, 0x14, 0,
2923 AC_VERB_GET_PIN_SENSE, 0)
2924 & AC_PINSENSE_PRESENCE;
2925 bits = present ? HDA_AMP_MUTE : 0;
2926 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
2927 HDA_AMP_MUTE, bits);
2928 if (present)
2929 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
2930 else
2931 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
2932}
2933
2934static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
2935 unsigned int res)
2936{
2937 /* Looks like the unsol event is incompatible with the standard
2938 * definition. 4bit tag is placed at 28 bit!
2939 */
2940 if ((res >> 28) == ALC880_HP_EVENT)
2941 alc880_medion_rim_automute(codec);
2942}
2943
Takashi Iwaicb53c622007-08-10 17:21:45 +02002944#ifdef CONFIG_SND_HDA_POWER_SAVE
2945static struct hda_amp_list alc880_loopbacks[] = {
2946 { 0x0b, HDA_INPUT, 0 },
2947 { 0x0b, HDA_INPUT, 1 },
2948 { 0x0b, HDA_INPUT, 2 },
2949 { 0x0b, HDA_INPUT, 3 },
2950 { 0x0b, HDA_INPUT, 4 },
2951 { } /* end */
2952};
2953
2954static struct hda_amp_list alc880_lg_loopbacks[] = {
2955 { 0x0b, HDA_INPUT, 1 },
2956 { 0x0b, HDA_INPUT, 6 },
2957 { 0x0b, HDA_INPUT, 7 },
2958 { } /* end */
2959};
2960#endif
2961
Takashi Iwaid6815182006-03-23 16:06:23 +01002962/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002963 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002964 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002965
Linus Torvalds1da177e2005-04-16 15:20:36 -07002966static int alc_init(struct hda_codec *codec)
2967{
2968 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002969 unsigned int i;
2970
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02002971 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02002972 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02002973
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002974 for (i = 0; i < spec->num_init_verbs; i++)
2975 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002976
2977 if (spec->init_hook)
2978 spec->init_hook(codec);
2979
Linus Torvalds1da177e2005-04-16 15:20:36 -07002980 return 0;
2981}
2982
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002983static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2984{
2985 struct alc_spec *spec = codec->spec;
2986
2987 if (spec->unsol_event)
2988 spec->unsol_event(codec, res);
2989}
2990
Takashi Iwaicb53c622007-08-10 17:21:45 +02002991#ifdef CONFIG_SND_HDA_POWER_SAVE
2992static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
2993{
2994 struct alc_spec *spec = codec->spec;
2995 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
2996}
2997#endif
2998
Linus Torvalds1da177e2005-04-16 15:20:36 -07002999/*
3000 * Analog playback callbacks
3001 */
3002static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3003 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003004 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003005{
3006 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01003007 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3008 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003009}
3010
3011static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3012 struct hda_codec *codec,
3013 unsigned int stream_tag,
3014 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003015 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003016{
3017 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003018 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3019 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003020}
3021
3022static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3023 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003024 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003025{
3026 struct alc_spec *spec = codec->spec;
3027 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3028}
3029
3030/*
3031 * Digital out
3032 */
3033static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3034 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003035 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003036{
3037 struct alc_spec *spec = codec->spec;
3038 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3039}
3040
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003041static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3042 struct hda_codec *codec,
3043 unsigned int stream_tag,
3044 unsigned int format,
3045 struct snd_pcm_substream *substream)
3046{
3047 struct alc_spec *spec = codec->spec;
3048 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3049 stream_tag, format, substream);
3050}
3051
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003052static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3053 struct hda_codec *codec,
3054 struct snd_pcm_substream *substream)
3055{
3056 struct alc_spec *spec = codec->spec;
3057 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3058}
3059
Linus Torvalds1da177e2005-04-16 15:20:36 -07003060static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3061 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003062 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003063{
3064 struct alc_spec *spec = codec->spec;
3065 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3066}
3067
3068/*
3069 * Analog capture
3070 */
Takashi Iwai63300792008-01-24 15:31:36 +01003071static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003072 struct hda_codec *codec,
3073 unsigned int stream_tag,
3074 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003075 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003076{
3077 struct alc_spec *spec = codec->spec;
3078
Takashi Iwai63300792008-01-24 15:31:36 +01003079 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07003080 stream_tag, 0, format);
3081 return 0;
3082}
3083
Takashi Iwai63300792008-01-24 15:31:36 +01003084static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003085 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003086 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003087{
3088 struct alc_spec *spec = codec->spec;
3089
Takashi Iwai888afa12008-03-18 09:57:50 +01003090 snd_hda_codec_cleanup_stream(codec,
3091 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003092 return 0;
3093}
3094
3095
3096/*
3097 */
3098static struct hda_pcm_stream alc880_pcm_analog_playback = {
3099 .substreams = 1,
3100 .channels_min = 2,
3101 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003102 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003103 .ops = {
3104 .open = alc880_playback_pcm_open,
3105 .prepare = alc880_playback_pcm_prepare,
3106 .cleanup = alc880_playback_pcm_cleanup
3107 },
3108};
3109
3110static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01003111 .substreams = 1,
3112 .channels_min = 2,
3113 .channels_max = 2,
3114 /* NID is set in alc_build_pcms */
3115};
3116
3117static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3118 .substreams = 1,
3119 .channels_min = 2,
3120 .channels_max = 2,
3121 /* NID is set in alc_build_pcms */
3122};
3123
3124static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3125 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003126 .channels_min = 2,
3127 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003128 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003129 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01003130 .prepare = alc880_alt_capture_pcm_prepare,
3131 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003132 },
3133};
3134
3135static struct hda_pcm_stream alc880_pcm_digital_playback = {
3136 .substreams = 1,
3137 .channels_min = 2,
3138 .channels_max = 2,
3139 /* NID is set in alc_build_pcms */
3140 .ops = {
3141 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003142 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003143 .prepare = alc880_dig_playback_pcm_prepare,
3144 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003145 },
3146};
3147
3148static struct hda_pcm_stream alc880_pcm_digital_capture = {
3149 .substreams = 1,
3150 .channels_min = 2,
3151 .channels_max = 2,
3152 /* NID is set in alc_build_pcms */
3153};
3154
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003155/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01003156static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003157 .substreams = 0,
3158 .channels_min = 0,
3159 .channels_max = 0,
3160};
3161
Linus Torvalds1da177e2005-04-16 15:20:36 -07003162static int alc_build_pcms(struct hda_codec *codec)
3163{
3164 struct alc_spec *spec = codec->spec;
3165 struct hda_pcm *info = spec->pcm_rec;
3166 int i;
3167
3168 codec->num_pcms = 1;
3169 codec->pcm_info = info;
3170
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003171 if (spec->no_analog)
3172 goto skip_analog;
3173
Linus Torvalds1da177e2005-04-16 15:20:36 -07003174 info->name = spec->stream_name_analog;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003175 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003176 if (snd_BUG_ON(!spec->multiout.dac_nids))
3177 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003178 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3179 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3180 }
3181 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003182 if (snd_BUG_ON(!spec->adc_nids))
3183 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003184 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3185 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3186 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003187
Takashi Iwai4a471b72005-12-07 13:56:29 +01003188 if (spec->channel_mode) {
3189 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3190 for (i = 0; i < spec->num_channel_mode; i++) {
3191 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3192 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3193 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003194 }
3195 }
3196
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003197 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02003198 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003199 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003200 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08003201 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003202 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003203 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01003204 if (spec->dig_out_type)
3205 info->pcm_type = spec->dig_out_type;
3206 else
3207 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003208 if (spec->multiout.dig_out_nid &&
3209 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003210 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
3211 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3212 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01003213 if (spec->dig_in_nid &&
3214 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003215 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
3216 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3217 }
Takashi Iwai963f8032008-08-11 10:04:40 +02003218 /* FIXME: do we need this for all Realtek codec models? */
3219 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003220 }
3221
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003222 if (spec->no_analog)
3223 return 0;
3224
Takashi Iwaie08a0072006-09-07 17:52:14 +02003225 /* If the use of more than one ADC is requested for the current
3226 * model, configure a second analog capture-only PCM.
3227 */
3228 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01003229 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
3230 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003231 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003232 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003233 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01003234 if (spec->alt_dac_nid) {
3235 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3236 *spec->stream_analog_alt_playback;
3237 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3238 spec->alt_dac_nid;
3239 } else {
3240 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3241 alc_pcm_null_stream;
3242 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
3243 }
3244 if (spec->num_adc_nids > 1) {
3245 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3246 *spec->stream_analog_alt_capture;
3247 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
3248 spec->adc_nids[1];
3249 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
3250 spec->num_adc_nids - 1;
3251 } else {
3252 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3253 alc_pcm_null_stream;
3254 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003255 }
3256 }
3257
Linus Torvalds1da177e2005-04-16 15:20:36 -07003258 return 0;
3259}
3260
Takashi Iwai603c4012008-07-30 15:01:44 +02003261static void alc_free_kctls(struct hda_codec *codec)
3262{
3263 struct alc_spec *spec = codec->spec;
3264
3265 if (spec->kctls.list) {
3266 struct snd_kcontrol_new *kctl = spec->kctls.list;
3267 int i;
3268 for (i = 0; i < spec->kctls.used; i++)
3269 kfree(kctl[i].name);
3270 }
3271 snd_array_free(&spec->kctls);
3272}
3273
Linus Torvalds1da177e2005-04-16 15:20:36 -07003274static void alc_free(struct hda_codec *codec)
3275{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003276 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003277
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003278 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003279 return;
3280
Takashi Iwai603c4012008-07-30 15:01:44 +02003281 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003282 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09003283 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003284}
3285
Takashi Iwaie044c392008-10-27 16:56:24 +01003286#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01003287static int alc_resume(struct hda_codec *codec)
3288{
Takashi Iwaie044c392008-10-27 16:56:24 +01003289 codec->patch_ops.init(codec);
3290 snd_hda_codec_resume_amp(codec);
3291 snd_hda_codec_resume_cache(codec);
3292 return 0;
3293}
Takashi Iwaie044c392008-10-27 16:56:24 +01003294#endif
3295
Linus Torvalds1da177e2005-04-16 15:20:36 -07003296/*
3297 */
3298static struct hda_codec_ops alc_patch_ops = {
3299 .build_controls = alc_build_controls,
3300 .build_pcms = alc_build_pcms,
3301 .init = alc_init,
3302 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003303 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01003304#ifdef SND_HDA_NEEDS_RESUME
3305 .resume = alc_resume,
3306#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02003307#ifdef CONFIG_SND_HDA_POWER_SAVE
3308 .check_power_status = alc_check_power_status,
3309#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003310};
3311
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003312
3313/*
3314 * Test configuration for debugging
3315 *
3316 * Almost all inputs/outputs are enabled. I/O pins can be configured via
3317 * enum controls.
3318 */
3319#ifdef CONFIG_SND_DEBUG
3320static hda_nid_t alc880_test_dac_nids[4] = {
3321 0x02, 0x03, 0x04, 0x05
3322};
3323
3324static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003325 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003326 .items = {
3327 { "In-1", 0x0 },
3328 { "In-2", 0x1 },
3329 { "In-3", 0x2 },
3330 { "In-4", 0x3 },
3331 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003332 { "Front", 0x5 },
3333 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003334 },
3335};
3336
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003337static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003338 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003339 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003340 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003341 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003342};
3343
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003344static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
3345 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003346{
3347 static char *texts[] = {
3348 "N/A", "Line Out", "HP Out",
3349 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
3350 };
3351 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3352 uinfo->count = 1;
3353 uinfo->value.enumerated.items = 8;
3354 if (uinfo->value.enumerated.item >= 8)
3355 uinfo->value.enumerated.item = 7;
3356 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3357 return 0;
3358}
3359
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003360static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
3361 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003362{
3363 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3364 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3365 unsigned int pin_ctl, item = 0;
3366
3367 pin_ctl = snd_hda_codec_read(codec, nid, 0,
3368 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3369 if (pin_ctl & AC_PINCTL_OUT_EN) {
3370 if (pin_ctl & AC_PINCTL_HP_EN)
3371 item = 2;
3372 else
3373 item = 1;
3374 } else if (pin_ctl & AC_PINCTL_IN_EN) {
3375 switch (pin_ctl & AC_PINCTL_VREFEN) {
3376 case AC_PINCTL_VREF_HIZ: item = 3; break;
3377 case AC_PINCTL_VREF_50: item = 4; break;
3378 case AC_PINCTL_VREF_GRD: item = 5; break;
3379 case AC_PINCTL_VREF_80: item = 6; break;
3380 case AC_PINCTL_VREF_100: item = 7; break;
3381 }
3382 }
3383 ucontrol->value.enumerated.item[0] = item;
3384 return 0;
3385}
3386
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003387static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
3388 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003389{
3390 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3391 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3392 static unsigned int ctls[] = {
3393 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
3394 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
3395 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
3396 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
3397 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
3398 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
3399 };
3400 unsigned int old_ctl, new_ctl;
3401
3402 old_ctl = snd_hda_codec_read(codec, nid, 0,
3403 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3404 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
3405 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003406 int val;
3407 snd_hda_codec_write_cache(codec, nid, 0,
3408 AC_VERB_SET_PIN_WIDGET_CONTROL,
3409 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003410 val = ucontrol->value.enumerated.item[0] >= 3 ?
3411 HDA_AMP_MUTE : 0;
3412 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3413 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003414 return 1;
3415 }
3416 return 0;
3417}
3418
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003419static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
3420 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003421{
3422 static char *texts[] = {
3423 "Front", "Surround", "CLFE", "Side"
3424 };
3425 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3426 uinfo->count = 1;
3427 uinfo->value.enumerated.items = 4;
3428 if (uinfo->value.enumerated.item >= 4)
3429 uinfo->value.enumerated.item = 3;
3430 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3431 return 0;
3432}
3433
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003434static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
3435 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003436{
3437 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3438 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3439 unsigned int sel;
3440
3441 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
3442 ucontrol->value.enumerated.item[0] = sel & 3;
3443 return 0;
3444}
3445
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003446static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
3447 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003448{
3449 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3450 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3451 unsigned int sel;
3452
3453 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
3454 if (ucontrol->value.enumerated.item[0] != sel) {
3455 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003456 snd_hda_codec_write_cache(codec, nid, 0,
3457 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003458 return 1;
3459 }
3460 return 0;
3461}
3462
3463#define PIN_CTL_TEST(xname,nid) { \
3464 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3465 .name = xname, \
3466 .info = alc_test_pin_ctl_info, \
3467 .get = alc_test_pin_ctl_get, \
3468 .put = alc_test_pin_ctl_put, \
3469 .private_value = nid \
3470 }
3471
3472#define PIN_SRC_TEST(xname,nid) { \
3473 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3474 .name = xname, \
3475 .info = alc_test_pin_src_info, \
3476 .get = alc_test_pin_src_get, \
3477 .put = alc_test_pin_src_put, \
3478 .private_value = nid \
3479 }
3480
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003481static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003482 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3483 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3484 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
3485 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003486 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3487 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
3488 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
3489 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003490 PIN_CTL_TEST("Front Pin Mode", 0x14),
3491 PIN_CTL_TEST("Surround Pin Mode", 0x15),
3492 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
3493 PIN_CTL_TEST("Side Pin Mode", 0x17),
3494 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
3495 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
3496 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
3497 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
3498 PIN_SRC_TEST("In-1 Pin Source", 0x18),
3499 PIN_SRC_TEST("In-2 Pin Source", 0x19),
3500 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
3501 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
3502 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
3503 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
3504 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
3505 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
3506 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
3507 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
3508 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
3509 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
3510 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
3511 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003512 {
3513 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3514 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01003515 .info = alc_ch_mode_info,
3516 .get = alc_ch_mode_get,
3517 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003518 },
3519 { } /* end */
3520};
3521
3522static struct hda_verb alc880_test_init_verbs[] = {
3523 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003524 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3525 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3526 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3527 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3528 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3529 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3530 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3531 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003532 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003533 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3534 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3535 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3536 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003537 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003538 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3539 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3540 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3541 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003542 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003543 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3544 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3545 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3546 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003547 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02003548 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3549 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02003550 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3551 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3552 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003553 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02003554 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3555 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3556 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3557 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003558 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02003559 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003560 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003561 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003562 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003563 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003564 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003565 /* Analog input/passthru */
3566 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3567 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3568 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3569 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3570 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003571 { }
3572};
3573#endif
3574
Linus Torvalds1da177e2005-04-16 15:20:36 -07003575/*
3576 */
3577
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003578static const char *alc880_models[ALC880_MODEL_LAST] = {
3579 [ALC880_3ST] = "3stack",
3580 [ALC880_TCL_S700] = "tcl",
3581 [ALC880_3ST_DIG] = "3stack-digout",
3582 [ALC880_CLEVO] = "clevo",
3583 [ALC880_5ST] = "5stack",
3584 [ALC880_5ST_DIG] = "5stack-digout",
3585 [ALC880_W810] = "w810",
3586 [ALC880_Z71V] = "z71v",
3587 [ALC880_6ST] = "6stack",
3588 [ALC880_6ST_DIG] = "6stack-digout",
3589 [ALC880_ASUS] = "asus",
3590 [ALC880_ASUS_W1V] = "asus-w1v",
3591 [ALC880_ASUS_DIG] = "asus-dig",
3592 [ALC880_ASUS_DIG2] = "asus-dig2",
3593 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003594 [ALC880_UNIWILL_P53] = "uniwill-p53",
3595 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003596 [ALC880_F1734] = "F1734",
3597 [ALC880_LG] = "lg",
3598 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003599 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003600#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003601 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003602#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003603 [ALC880_AUTO] = "auto",
3604};
3605
3606static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003607 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003608 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
3609 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
3610 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
3611 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
3612 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
3613 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
3614 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
3615 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003616 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
3617 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003618 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
3619 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
3620 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
3621 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
3622 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
3623 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
3624 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
3625 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
3626 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
3627 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02003628 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003629 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
3630 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
3631 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01003632 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003633 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003634 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
3635 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003636 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
3637 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003638 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
3639 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
3640 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
3641 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003642 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
3643 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003644 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003645 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003646 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003647 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003648 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
3649 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003650 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003651 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003652 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003653 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003654 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02003655 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003656 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003657 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003658 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003659 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
3660 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003661 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003662 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
3663 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
3664 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
3665 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003666 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
3667 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003668 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003669 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003670 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
3671 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003672 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
3673 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
3674 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01003675 /* default Intel */
3676 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003677 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
3678 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003679 {}
3680};
3681
Takashi Iwai16ded522005-06-10 19:58:24 +02003682/*
Kailang Yangdf694da2005-12-05 19:42:22 +01003683 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02003684 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003685static struct alc_config_preset alc880_presets[] = {
3686 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003687 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003688 .init_verbs = { alc880_volume_init_verbs,
3689 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003690 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003691 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003692 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3693 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003694 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003695 .input_mux = &alc880_capture_source,
3696 },
3697 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003698 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003699 .init_verbs = { alc880_volume_init_verbs,
3700 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003701 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003702 .dac_nids = alc880_dac_nids,
3703 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003704 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3705 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003706 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003707 .input_mux = &alc880_capture_source,
3708 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003709 [ALC880_TCL_S700] = {
3710 .mixers = { alc880_tcl_s700_mixer },
3711 .init_verbs = { alc880_volume_init_verbs,
3712 alc880_pin_tcl_S700_init_verbs,
3713 alc880_gpio2_init_verbs },
3714 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3715 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01003716 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
3717 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01003718 .hp_nid = 0x03,
3719 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3720 .channel_mode = alc880_2_jack_modes,
3721 .input_mux = &alc880_capture_source,
3722 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003723 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003724 .mixers = { alc880_three_stack_mixer,
3725 alc880_five_stack_mixer},
3726 .init_verbs = { alc880_volume_init_verbs,
3727 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003728 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3729 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003730 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3731 .channel_mode = alc880_fivestack_modes,
3732 .input_mux = &alc880_capture_source,
3733 },
3734 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003735 .mixers = { alc880_three_stack_mixer,
3736 alc880_five_stack_mixer },
3737 .init_verbs = { alc880_volume_init_verbs,
3738 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003739 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3740 .dac_nids = alc880_dac_nids,
3741 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003742 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3743 .channel_mode = alc880_fivestack_modes,
3744 .input_mux = &alc880_capture_source,
3745 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003746 [ALC880_6ST] = {
3747 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003748 .init_verbs = { alc880_volume_init_verbs,
3749 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003750 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3751 .dac_nids = alc880_6st_dac_nids,
3752 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3753 .channel_mode = alc880_sixstack_modes,
3754 .input_mux = &alc880_6stack_capture_source,
3755 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003756 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003757 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003758 .init_verbs = { alc880_volume_init_verbs,
3759 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003760 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3761 .dac_nids = alc880_6st_dac_nids,
3762 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003763 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3764 .channel_mode = alc880_sixstack_modes,
3765 .input_mux = &alc880_6stack_capture_source,
3766 },
3767 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003768 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003769 .init_verbs = { alc880_volume_init_verbs,
3770 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003771 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003772 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
3773 .dac_nids = alc880_w810_dac_nids,
3774 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003775 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3776 .channel_mode = alc880_w810_modes,
3777 .input_mux = &alc880_capture_source,
3778 },
3779 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003780 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003781 .init_verbs = { alc880_volume_init_verbs,
3782 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003783 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
3784 .dac_nids = alc880_z71v_dac_nids,
3785 .dig_out_nid = ALC880_DIGOUT_NID,
3786 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003787 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3788 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02003789 .input_mux = &alc880_capture_source,
3790 },
3791 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003792 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003793 .init_verbs = { alc880_volume_init_verbs,
3794 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003795 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
3796 .dac_nids = alc880_f1734_dac_nids,
3797 .hp_nid = 0x02,
3798 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3799 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01003800 .input_mux = &alc880_f1734_capture_source,
3801 .unsol_event = alc880_uniwill_p53_unsol_event,
3802 .init_hook = alc880_uniwill_p53_hp_automute,
Takashi Iwai16ded522005-06-10 19:58:24 +02003803 },
3804 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003805 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003806 .init_verbs = { alc880_volume_init_verbs,
3807 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003808 alc880_gpio1_init_verbs },
3809 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3810 .dac_nids = alc880_asus_dac_nids,
3811 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3812 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003813 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003814 .input_mux = &alc880_capture_source,
3815 },
3816 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003817 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003818 .init_verbs = { alc880_volume_init_verbs,
3819 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003820 alc880_gpio1_init_verbs },
3821 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3822 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003823 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003824 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3825 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003826 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003827 .input_mux = &alc880_capture_source,
3828 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003829 [ALC880_ASUS_DIG2] = {
3830 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003831 .init_verbs = { alc880_volume_init_verbs,
3832 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01003833 alc880_gpio2_init_verbs }, /* use GPIO2 */
3834 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3835 .dac_nids = alc880_asus_dac_nids,
3836 .dig_out_nid = ALC880_DIGOUT_NID,
3837 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3838 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003839 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003840 .input_mux = &alc880_capture_source,
3841 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003842 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003843 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003844 .init_verbs = { alc880_volume_init_verbs,
3845 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003846 alc880_gpio1_init_verbs },
3847 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3848 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003849 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003850 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3851 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003852 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003853 .input_mux = &alc880_capture_source,
3854 },
3855 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01003856 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02003857 .init_verbs = { alc880_volume_init_verbs,
3858 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003859 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3860 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003861 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003862 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3863 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003864 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003865 .input_mux = &alc880_capture_source,
3866 },
Kailang Yangccc656c2006-10-17 12:32:26 +02003867 [ALC880_UNIWILL] = {
3868 .mixers = { alc880_uniwill_mixer },
3869 .init_verbs = { alc880_volume_init_verbs,
3870 alc880_uniwill_init_verbs },
3871 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3872 .dac_nids = alc880_asus_dac_nids,
3873 .dig_out_nid = ALC880_DIGOUT_NID,
3874 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3875 .channel_mode = alc880_threestack_modes,
3876 .need_dac_fix = 1,
3877 .input_mux = &alc880_capture_source,
3878 .unsol_event = alc880_uniwill_unsol_event,
3879 .init_hook = alc880_uniwill_automute,
3880 },
3881 [ALC880_UNIWILL_P53] = {
3882 .mixers = { alc880_uniwill_p53_mixer },
3883 .init_verbs = { alc880_volume_init_verbs,
3884 alc880_uniwill_p53_init_verbs },
3885 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3886 .dac_nids = alc880_asus_dac_nids,
3887 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003888 .channel_mode = alc880_threestack_modes,
3889 .input_mux = &alc880_capture_source,
3890 .unsol_event = alc880_uniwill_p53_unsol_event,
3891 .init_hook = alc880_uniwill_p53_hp_automute,
3892 },
3893 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01003894 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003895 .init_verbs = { alc880_volume_init_verbs,
3896 alc880_uniwill_p53_init_verbs,
3897 alc880_beep_init_verbs },
3898 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3899 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02003900 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003901 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3902 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02003903 .input_mux = &alc880_capture_source,
3904 .unsol_event = alc880_uniwill_p53_unsol_event,
3905 .init_hook = alc880_uniwill_p53_hp_automute,
3906 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003907 [ALC880_CLEVO] = {
3908 .mixers = { alc880_three_stack_mixer },
3909 .init_verbs = { alc880_volume_init_verbs,
3910 alc880_pin_clevo_init_verbs },
3911 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3912 .dac_nids = alc880_dac_nids,
3913 .hp_nid = 0x03,
3914 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3915 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003916 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003917 .input_mux = &alc880_capture_source,
3918 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003919 [ALC880_LG] = {
3920 .mixers = { alc880_lg_mixer },
3921 .init_verbs = { alc880_volume_init_verbs,
3922 alc880_lg_init_verbs },
3923 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
3924 .dac_nids = alc880_lg_dac_nids,
3925 .dig_out_nid = ALC880_DIGOUT_NID,
3926 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
3927 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003928 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003929 .input_mux = &alc880_lg_capture_source,
3930 .unsol_event = alc880_lg_unsol_event,
3931 .init_hook = alc880_lg_automute,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003932#ifdef CONFIG_SND_HDA_POWER_SAVE
3933 .loopbacks = alc880_lg_loopbacks,
3934#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003935 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003936 [ALC880_LG_LW] = {
3937 .mixers = { alc880_lg_lw_mixer },
3938 .init_verbs = { alc880_volume_init_verbs,
3939 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003940 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01003941 .dac_nids = alc880_dac_nids,
3942 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003943 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
3944 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01003945 .input_mux = &alc880_lg_lw_capture_source,
3946 .unsol_event = alc880_lg_lw_unsol_event,
3947 .init_hook = alc880_lg_lw_automute,
3948 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003949 [ALC880_MEDION_RIM] = {
3950 .mixers = { alc880_medion_rim_mixer },
3951 .init_verbs = { alc880_volume_init_verbs,
3952 alc880_medion_rim_init_verbs,
3953 alc_gpio2_init_verbs },
3954 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3955 .dac_nids = alc880_dac_nids,
3956 .dig_out_nid = ALC880_DIGOUT_NID,
3957 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3958 .channel_mode = alc880_2_jack_modes,
3959 .input_mux = &alc880_medion_rim_capture_source,
3960 .unsol_event = alc880_medion_rim_unsol_event,
3961 .init_hook = alc880_medion_rim_automute,
3962 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003963#ifdef CONFIG_SND_DEBUG
3964 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003965 .mixers = { alc880_test_mixer },
3966 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003967 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
3968 .dac_nids = alc880_test_dac_nids,
3969 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003970 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
3971 .channel_mode = alc880_test_modes,
3972 .input_mux = &alc880_test_capture_source,
3973 },
3974#endif
3975};
3976
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003977/*
3978 * Automatic parse of I/O pins from the BIOS configuration
3979 */
3980
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003981enum {
3982 ALC_CTL_WIDGET_VOL,
3983 ALC_CTL_WIDGET_MUTE,
3984 ALC_CTL_BIND_MUTE,
3985};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003986static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003987 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
3988 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01003989 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003990};
3991
3992/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003993static int add_control(struct alc_spec *spec, int type, const char *name,
3994 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003995{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003996 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003997
Takashi Iwai603c4012008-07-30 15:01:44 +02003998 snd_array_init(&spec->kctls, sizeof(*knew), 32);
3999 knew = snd_array_new(&spec->kctls);
4000 if (!knew)
4001 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004002 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07004003 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004004 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004005 return -ENOMEM;
4006 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004007 return 0;
4008}
4009
4010#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
4011#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
4012#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
4013#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
4014#define alc880_is_input_pin(nid) ((nid) >= 0x18)
4015#define alc880_input_pin_idx(nid) ((nid) - 0x18)
4016#define alc880_idx_to_dac(nid) ((nid) + 0x02)
4017#define alc880_dac_to_idx(nid) ((nid) - 0x02)
4018#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
4019#define alc880_idx_to_selector(nid) ((nid) + 0x10)
4020#define ALC880_PIN_CD_NID 0x1c
4021
4022/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004023static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
4024 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004025{
4026 hda_nid_t nid;
4027 int assigned[4];
4028 int i, j;
4029
4030 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004031 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004032
4033 /* check the pins hardwired to audio widget */
4034 for (i = 0; i < cfg->line_outs; i++) {
4035 nid = cfg->line_out_pins[i];
4036 if (alc880_is_fixed_pin(nid)) {
4037 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01004038 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004039 assigned[idx] = 1;
4040 }
4041 }
4042 /* left pins can be connect to any audio widget */
4043 for (i = 0; i < cfg->line_outs; i++) {
4044 nid = cfg->line_out_pins[i];
4045 if (alc880_is_fixed_pin(nid))
4046 continue;
4047 /* search for an empty channel */
4048 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004049 if (!assigned[j]) {
4050 spec->multiout.dac_nids[i] =
4051 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004052 assigned[j] = 1;
4053 break;
4054 }
4055 }
4056 }
4057 spec->multiout.num_dacs = cfg->line_outs;
4058 return 0;
4059}
4060
4061/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01004062static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
4063 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004064{
4065 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004066 static const char *chname[4] = {
4067 "Front", "Surround", NULL /*CLFE*/, "Side"
4068 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004069 hda_nid_t nid;
4070 int i, err;
4071
4072 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004073 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004074 continue;
4075 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4076 if (i == 2) {
4077 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004078 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4079 "Center Playback Volume",
4080 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
4081 HDA_OUTPUT));
4082 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004083 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004084 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4085 "LFE Playback Volume",
4086 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
4087 HDA_OUTPUT));
4088 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004089 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004090 err = add_control(spec, ALC_CTL_BIND_MUTE,
4091 "Center Playback Switch",
4092 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
4093 HDA_INPUT));
4094 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004095 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004096 err = add_control(spec, ALC_CTL_BIND_MUTE,
4097 "LFE Playback Switch",
4098 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
4099 HDA_INPUT));
4100 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004101 return err;
4102 } else {
4103 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004104 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4105 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4106 HDA_OUTPUT));
4107 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004108 return err;
4109 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004110 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4111 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4112 HDA_INPUT));
4113 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004114 return err;
4115 }
4116 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004117 return 0;
4118}
4119
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004120/* add playback controls for speaker and HP outputs */
4121static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
4122 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004123{
4124 hda_nid_t nid;
4125 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004126 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004127
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004128 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004129 return 0;
4130
4131 if (alc880_is_fixed_pin(pin)) {
4132 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01004133 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004134 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004135 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004136 else
4137 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004138 /* control HP volume/switch on the output mixer amp */
4139 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004140 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004141 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4142 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
4143 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004144 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004145 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004146 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4147 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
4148 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004149 return err;
4150 } else if (alc880_is_multi_pin(pin)) {
4151 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004152 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004153 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004154 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4155 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
4156 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004157 return err;
4158 }
4159 return 0;
4160}
4161
4162/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004163static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4164 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01004165 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004166{
4167 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01004168 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004169
4170 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004171 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4172 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4173 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004174 return err;
4175 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004176 err = add_control(spec, ALC_CTL_WIDGET_MUTE, 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 return 0;
4181}
4182
4183/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01004184static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
4185 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004186{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004187 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004188 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004189
4190 for (i = 0; i < AUTO_PIN_LAST; i++) {
4191 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01004192 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01004193 err = new_analog_input(spec, cfg->input_pins[i],
4194 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01004195 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004196 if (err < 0)
4197 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004198 imux->items[imux->num_items].label =
4199 auto_pin_cfg_labels[i];
4200 imux->items[imux->num_items].index =
4201 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004202 imux->num_items++;
4203 }
4204 }
4205 return 0;
4206}
4207
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004208static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
4209 unsigned int pin_type)
4210{
4211 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4212 pin_type);
4213 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01004214 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4215 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004216}
4217
Kailang Yangdf694da2005-12-05 19:42:22 +01004218static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
4219 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004220 int dac_idx)
4221{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004222 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004223 /* need the manual connection? */
4224 if (alc880_is_multi_pin(nid)) {
4225 struct alc_spec *spec = codec->spec;
4226 int idx = alc880_multi_pin_idx(nid);
4227 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
4228 AC_VERB_SET_CONNECT_SEL,
4229 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
4230 }
4231}
4232
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004233static int get_pin_type(int line_out_type)
4234{
4235 if (line_out_type == AUTO_PIN_HP_OUT)
4236 return PIN_HP;
4237 else
4238 return PIN_OUT;
4239}
4240
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004241static void alc880_auto_init_multi_out(struct hda_codec *codec)
4242{
4243 struct alc_spec *spec = codec->spec;
4244 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02004245
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004246 for (i = 0; i < spec->autocfg.line_outs; i++) {
4247 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004248 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4249 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004250 }
4251}
4252
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004253static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004254{
4255 struct alc_spec *spec = codec->spec;
4256 hda_nid_t pin;
4257
Takashi Iwai82bc9552006-03-21 11:24:42 +01004258 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004259 if (pin) /* connect to front */
4260 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004261 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004262 if (pin) /* connect to front */
4263 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
4264}
4265
4266static void alc880_auto_init_analog_input(struct hda_codec *codec)
4267{
4268 struct alc_spec *spec = codec->spec;
4269 int i;
4270
4271 for (i = 0; i < AUTO_PIN_LAST; i++) {
4272 hda_nid_t nid = spec->autocfg.input_pins[i];
4273 if (alc880_is_input_pin(nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01004274 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01004275 if (nid != ALC880_PIN_CD_NID &&
4276 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004277 snd_hda_codec_write(codec, nid, 0,
4278 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004279 AMP_OUT_MUTE);
4280 }
4281 }
4282}
4283
4284/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004285/* return 1 if successful, 0 if the proper config is not found,
4286 * or a negative error code
4287 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004288static int alc880_parse_auto_config(struct hda_codec *codec)
4289{
4290 struct alc_spec *spec = codec->spec;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004291 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +01004292 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004293
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004294 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4295 alc880_ignore);
4296 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004297 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004298 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004299 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01004300
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004301 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
4302 if (err < 0)
4303 return err;
4304 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
4305 if (err < 0)
4306 return err;
4307 err = alc880_auto_create_extra_out(spec,
4308 spec->autocfg.speaker_pins[0],
4309 "Speaker");
4310 if (err < 0)
4311 return err;
4312 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
4313 "Headphone");
4314 if (err < 0)
4315 return err;
4316 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
4317 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004318 return err;
4319
4320 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4321
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004322 /* check multiple SPDIF-out (for recent codecs) */
4323 for (i = 0; i < spec->autocfg.dig_outs; i++) {
4324 hda_nid_t dig_nid;
4325 err = snd_hda_get_connections(codec,
4326 spec->autocfg.dig_out_pins[i],
4327 &dig_nid, 1);
4328 if (err < 0)
4329 continue;
4330 if (!i)
4331 spec->multiout.dig_out_nid = dig_nid;
4332 else {
4333 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
4334 spec->slave_dig_outs[i - 1] = dig_nid;
4335 if (i == ARRAY_SIZE(spec->slave_dig_outs) - 1)
4336 break;
4337 }
4338 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004339 if (spec->autocfg.dig_in_pin)
4340 spec->dig_in_nid = ALC880_DIGIN_NID;
4341
Takashi Iwai603c4012008-07-30 15:01:44 +02004342 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01004343 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004344
Takashi Iwaid88897e2008-10-31 15:01:37 +01004345 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004346
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004347 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004348 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004349
Takashi Iwai4a79ba32009-04-22 16:31:35 +02004350 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
4351
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004352 return 1;
4353}
4354
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004355/* additional initialization for auto-configuration model */
4356static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004357{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004358 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004359 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004360 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004361 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004362 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02004363 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004364}
4365
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004366static void set_capture_mixer(struct alc_spec *spec)
4367{
Takashi Iwaia23b6882009-03-23 15:21:36 +01004368 static struct snd_kcontrol_new *caps[2][3] = {
4369 { alc_capture_mixer_nosrc1,
4370 alc_capture_mixer_nosrc2,
4371 alc_capture_mixer_nosrc3 },
4372 { alc_capture_mixer1,
4373 alc_capture_mixer2,
4374 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004375 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01004376 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
4377 int mux;
4378 if (spec->input_mux && spec->input_mux->num_items > 1)
4379 mux = 1;
4380 else
4381 mux = 0;
4382 spec->cap_mixer = caps[mux][spec->num_adc_nids - 1];
4383 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004384}
4385
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004386#define set_beep_amp(spec, nid, idx, dir) \
4387 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
4388
4389/*
4390 * OK, here we have finally the patch for ALC880
4391 */
4392
Linus Torvalds1da177e2005-04-16 15:20:36 -07004393static int patch_alc880(struct hda_codec *codec)
4394{
4395 struct alc_spec *spec;
4396 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01004397 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004398
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004399 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004400 if (spec == NULL)
4401 return -ENOMEM;
4402
4403 codec->spec = spec;
4404
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004405 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
4406 alc880_models,
4407 alc880_cfg_tbl);
4408 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004409 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
4410 "trying auto-probe from BIOS...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004411 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004412 }
4413
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004414 if (board_config == ALC880_AUTO) {
4415 /* automatic parse from the BIOS config */
4416 err = alc880_parse_auto_config(codec);
4417 if (err < 0) {
4418 alc_free(codec);
4419 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004420 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004421 printk(KERN_INFO
4422 "hda_codec: Cannot set up configuration "
4423 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004424 board_config = ALC880_3ST;
4425 }
4426 }
4427
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09004428 err = snd_hda_attach_beep_device(codec, 0x1);
4429 if (err < 0) {
4430 alc_free(codec);
4431 return err;
4432 }
4433
Kailang Yangdf694da2005-12-05 19:42:22 +01004434 if (board_config != ALC880_AUTO)
4435 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004436
4437 spec->stream_name_analog = "ALC880 Analog";
4438 spec->stream_analog_playback = &alc880_pcm_analog_playback;
4439 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01004440 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004441
4442 spec->stream_name_digital = "ALC880 Digital";
4443 spec->stream_digital_playback = &alc880_pcm_digital_playback;
4444 spec->stream_digital_capture = &alc880_pcm_digital_capture;
4445
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004446 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004447 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01004448 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004449 /* get type */
4450 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004451 if (wcap != AC_WID_AUD_IN) {
4452 spec->adc_nids = alc880_adc_nids_alt;
4453 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004454 } else {
4455 spec->adc_nids = alc880_adc_nids;
4456 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004457 }
4458 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004459 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004460 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004461
Takashi Iwai2134ea42008-01-10 16:53:55 +01004462 spec->vmaster_nid = 0x0c;
4463
Linus Torvalds1da177e2005-04-16 15:20:36 -07004464 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004465 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004466 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02004467#ifdef CONFIG_SND_HDA_POWER_SAVE
4468 if (!spec->loopback.amplist)
4469 spec->loopback.amplist = alc880_loopbacks;
4470#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01004471 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004472
4473 return 0;
4474}
4475
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004476
Linus Torvalds1da177e2005-04-16 15:20:36 -07004477/*
4478 * ALC260 support
4479 */
4480
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004481static hda_nid_t alc260_dac_nids[1] = {
4482 /* front */
4483 0x02,
4484};
4485
4486static hda_nid_t alc260_adc_nids[1] = {
4487 /* ADC0 */
4488 0x04,
4489};
4490
Kailang Yangdf694da2005-12-05 19:42:22 +01004491static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004492 /* ADC1 */
4493 0x05,
4494};
4495
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004496/* NIDs used when simultaneous access to both ADCs makes sense. Note that
4497 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
4498 */
4499static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004500 /* ADC0, ADC1 */
4501 0x04, 0x05
4502};
4503
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004504#define ALC260_DIGOUT_NID 0x03
4505#define ALC260_DIGIN_NID 0x06
4506
4507static struct hda_input_mux alc260_capture_source = {
4508 .num_items = 4,
4509 .items = {
4510 { "Mic", 0x0 },
4511 { "Front Mic", 0x1 },
4512 { "Line", 0x2 },
4513 { "CD", 0x4 },
4514 },
4515};
4516
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004517/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004518 * headphone jack and the internal CD lines since these are the only pins at
4519 * which audio can appear. For flexibility, also allow the option of
4520 * recording the mixer output on the second ADC (ADC0 doesn't have a
4521 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004522 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004523static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
4524 {
4525 .num_items = 3,
4526 .items = {
4527 { "Mic/Line", 0x0 },
4528 { "CD", 0x4 },
4529 { "Headphone", 0x2 },
4530 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004531 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004532 {
4533 .num_items = 4,
4534 .items = {
4535 { "Mic/Line", 0x0 },
4536 { "CD", 0x4 },
4537 { "Headphone", 0x2 },
4538 { "Mixer", 0x5 },
4539 },
4540 },
4541
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004542};
4543
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004544/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
4545 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004546 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004547static struct hda_input_mux alc260_acer_capture_sources[2] = {
4548 {
4549 .num_items = 4,
4550 .items = {
4551 { "Mic", 0x0 },
4552 { "Line", 0x2 },
4553 { "CD", 0x4 },
4554 { "Headphone", 0x5 },
4555 },
4556 },
4557 {
4558 .num_items = 5,
4559 .items = {
4560 { "Mic", 0x0 },
4561 { "Line", 0x2 },
4562 { "CD", 0x4 },
4563 { "Headphone", 0x6 },
4564 { "Mixer", 0x5 },
4565 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004566 },
4567};
Michael Schwingencc959482009-02-22 18:58:45 +01004568
4569/* Maxdata Favorit 100XS */
4570static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
4571 {
4572 .num_items = 2,
4573 .items = {
4574 { "Line/Mic", 0x0 },
4575 { "CD", 0x4 },
4576 },
4577 },
4578 {
4579 .num_items = 3,
4580 .items = {
4581 { "Line/Mic", 0x0 },
4582 { "CD", 0x4 },
4583 { "Mixer", 0x5 },
4584 },
4585 },
4586};
4587
Linus Torvalds1da177e2005-04-16 15:20:36 -07004588/*
4589 * This is just place-holder, so there's something for alc_build_pcms to look
4590 * at when it calculates the maximum number of channels. ALC260 has no mixer
4591 * element which allows changing the channel mode, so the verb list is
4592 * never used.
4593 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004594static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004595 { 2, NULL },
4596};
4597
Kailang Yangdf694da2005-12-05 19:42:22 +01004598
4599/* Mixer combinations
4600 *
4601 * basic: base_output + input + pc_beep + capture
4602 * HP: base_output + input + capture_alt
4603 * HP_3013: hp_3013 + input + capture
4604 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004605 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01004606 */
4607
4608static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004609 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004610 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004611 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4612 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4613 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4614 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4615 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004616};
Kailang Yangdf694da2005-12-05 19:42:22 +01004617
4618static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004619 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4620 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4621 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4622 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4623 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4624 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4625 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
4626 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004627 { } /* end */
4628};
4629
Takashi Iwaibec15c32008-01-28 18:16:30 +01004630/* update HP, line and mono out pins according to the master switch */
4631static void alc260_hp_master_update(struct hda_codec *codec,
4632 hda_nid_t hp, hda_nid_t line,
4633 hda_nid_t mono)
4634{
4635 struct alc_spec *spec = codec->spec;
4636 unsigned int val = spec->master_sw ? PIN_HP : 0;
4637 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004638 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004639 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004640 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004641 val);
4642 /* mono (speaker) depending on the HP jack sense */
4643 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004644 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004645 val);
4646}
4647
4648static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
4649 struct snd_ctl_elem_value *ucontrol)
4650{
4651 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4652 struct alc_spec *spec = codec->spec;
4653 *ucontrol->value.integer.value = spec->master_sw;
4654 return 0;
4655}
4656
4657static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
4658 struct snd_ctl_elem_value *ucontrol)
4659{
4660 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4661 struct alc_spec *spec = codec->spec;
4662 int val = !!*ucontrol->value.integer.value;
4663 hda_nid_t hp, line, mono;
4664
4665 if (val == spec->master_sw)
4666 return 0;
4667 spec->master_sw = val;
4668 hp = (kcontrol->private_value >> 16) & 0xff;
4669 line = (kcontrol->private_value >> 8) & 0xff;
4670 mono = kcontrol->private_value & 0xff;
4671 alc260_hp_master_update(codec, hp, line, mono);
4672 return 1;
4673}
4674
4675static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
4676 {
4677 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4678 .name = "Master Playback Switch",
4679 .info = snd_ctl_boolean_mono_info,
4680 .get = alc260_hp_master_sw_get,
4681 .put = alc260_hp_master_sw_put,
4682 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
4683 },
4684 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4685 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
4686 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4687 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4688 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
4689 HDA_OUTPUT),
4690 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4691 { } /* end */
4692};
4693
4694static struct hda_verb alc260_hp_unsol_verbs[] = {
4695 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4696 {},
4697};
4698
4699static void alc260_hp_automute(struct hda_codec *codec)
4700{
4701 struct alc_spec *spec = codec->spec;
4702 unsigned int present;
4703
4704 present = snd_hda_codec_read(codec, 0x10, 0,
4705 AC_VERB_GET_PIN_SENSE, 0);
4706 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4707 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
4708}
4709
4710static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
4711{
4712 if ((res >> 26) == ALC880_HP_EVENT)
4713 alc260_hp_automute(codec);
4714}
4715
Kailang Yangdf694da2005-12-05 19:42:22 +01004716static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01004717 {
4718 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4719 .name = "Master Playback Switch",
4720 .info = snd_ctl_boolean_mono_info,
4721 .get = alc260_hp_master_sw_get,
4722 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004723 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01004724 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004725 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4726 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4727 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
4728 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
4729 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4730 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01004731 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4732 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02004733 { } /* end */
4734};
4735
Kailang Yang3f878302008-08-26 13:02:23 +02004736static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
4737 .ops = &snd_hda_bind_vol,
4738 .values = {
4739 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
4740 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
4741 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
4742 0
4743 },
4744};
4745
4746static struct hda_bind_ctls alc260_dc7600_bind_switch = {
4747 .ops = &snd_hda_bind_sw,
4748 .values = {
4749 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
4750 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
4751 0
4752 },
4753};
4754
4755static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
4756 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
4757 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
4758 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
4759 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4760 { } /* end */
4761};
4762
Takashi Iwaibec15c32008-01-28 18:16:30 +01004763static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
4764 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4765 {},
4766};
4767
4768static void alc260_hp_3013_automute(struct hda_codec *codec)
4769{
4770 struct alc_spec *spec = codec->spec;
4771 unsigned int present;
4772
4773 present = snd_hda_codec_read(codec, 0x15, 0,
4774 AC_VERB_GET_PIN_SENSE, 0);
4775 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004776 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01004777}
4778
4779static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
4780 unsigned int res)
4781{
4782 if ((res >> 26) == ALC880_HP_EVENT)
4783 alc260_hp_3013_automute(codec);
4784}
4785
Kailang Yang3f878302008-08-26 13:02:23 +02004786static void alc260_hp_3012_automute(struct hda_codec *codec)
4787{
4788 unsigned int present, bits;
4789
4790 present = snd_hda_codec_read(codec, 0x10, 0,
4791 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
4792
4793 bits = present ? 0 : PIN_OUT;
4794 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4795 bits);
4796 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4797 bits);
4798 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4799 bits);
4800}
4801
4802static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
4803 unsigned int res)
4804{
4805 if ((res >> 26) == ALC880_HP_EVENT)
4806 alc260_hp_3012_automute(codec);
4807}
4808
4809/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004810 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
4811 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004812static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004813 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004814 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004815 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004816 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4817 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4818 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
4819 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004820 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004821 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4822 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004823 { } /* end */
4824};
4825
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004826/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
4827 * versions of the ALC260 don't act on requests to enable mic bias from NID
4828 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
4829 * datasheet doesn't mention this restriction. At this stage it's not clear
4830 * whether this behaviour is intentional or is a hardware bug in chip
4831 * revisions available in early 2006. Therefore for now allow the
4832 * "Headphone Jack Mode" control to span all choices, but if it turns out
4833 * that the lack of mic bias for this NID is intentional we could change the
4834 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4835 *
4836 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
4837 * don't appear to make the mic bias available from the "line" jack, even
4838 * though the NID used for this jack (0x14) can supply it. The theory is
4839 * that perhaps Acer have included blocking capacitors between the ALC260
4840 * and the output jack. If this turns out to be the case for all such
4841 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
4842 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01004843 *
4844 * The C20x Tablet series have a mono internal speaker which is controlled
4845 * via the chip's Mono sum widget and pin complex, so include the necessary
4846 * controls for such models. On models without a "mono speaker" the control
4847 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004848 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004849static struct snd_kcontrol_new alc260_acer_mixer[] = {
4850 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4851 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004852 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004853 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01004854 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004855 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01004856 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004857 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4858 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4859 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4860 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4861 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4862 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4863 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4864 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004865 { } /* end */
4866};
4867
Michael Schwingencc959482009-02-22 18:58:45 +01004868/* Maxdata Favorit 100XS: one output and one input (0x12) jack
4869 */
4870static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
4871 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4872 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
4873 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
4874 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4875 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4876 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4877 { } /* end */
4878};
4879
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004880/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
4881 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
4882 */
4883static struct snd_kcontrol_new alc260_will_mixer[] = {
4884 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4885 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4886 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4887 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4888 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4889 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4890 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4891 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4892 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4893 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004894 { } /* end */
4895};
4896
4897/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
4898 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
4899 */
4900static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
4901 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4902 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4903 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4904 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4905 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4906 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
4907 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
4908 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4909 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4910 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4911 { } /* end */
4912};
4913
Kailang Yangdf694da2005-12-05 19:42:22 +01004914/*
4915 * initialization verbs
4916 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004917static struct hda_verb alc260_init_verbs[] = {
4918 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004919 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004920 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004921 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004922 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004923 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004924 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004925 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004926 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02004927 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004928 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01004929 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004930 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02004931 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004932 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02004933 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004934 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02004935 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4936 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02004937 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004938 /* set connection select to line in (default select for this ADC) */
4939 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02004940 /* mute capture amp left and right */
4941 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4942 /* set connection select to line in (default select for this ADC) */
4943 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02004944 /* set vol=0 Line-Out mixer amp left and right */
4945 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4946 /* unmute pin widget amp left and right (no gain on this amp) */
4947 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4948 /* set vol=0 HP mixer amp left and right */
4949 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4950 /* unmute pin widget amp left and right (no gain on this amp) */
4951 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4952 /* set vol=0 Mono mixer amp left and right */
4953 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4954 /* unmute pin widget amp left and right (no gain on this amp) */
4955 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4956 /* unmute LINE-2 out pin */
4957 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004958 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4959 * Line In 2 = 0x03
4960 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004961 /* mute analog inputs */
4962 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4963 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4964 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4965 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4966 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004967 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004968 /* mute Front out path */
4969 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4970 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4971 /* mute Headphone out path */
4972 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4973 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4974 /* mute Mono out path */
4975 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4976 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004977 { }
4978};
4979
Takashi Iwai474167d2006-05-17 17:17:43 +02004980#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01004981static struct hda_verb alc260_hp_init_verbs[] = {
4982 /* Headphone and output */
4983 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4984 /* mono output */
4985 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4986 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4987 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4988 /* Mic2 (front panel) pin widget for input and vref at 80% */
4989 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4990 /* Line In pin widget for input */
4991 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4992 /* Line-2 pin widget for output */
4993 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4994 /* CD pin widget for input */
4995 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4996 /* unmute amp left and right */
4997 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4998 /* set connection select to line in (default select for this ADC) */
4999 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5000 /* unmute Line-Out mixer amp left and right (volume = 0) */
5001 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5002 /* mute pin widget amp left and right (no gain on this amp) */
5003 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5004 /* unmute HP mixer amp left and right (volume = 0) */
5005 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5006 /* mute pin widget amp left and right (no gain on this amp) */
5007 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005008 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5009 * Line In 2 = 0x03
5010 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005011 /* mute analog inputs */
5012 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5013 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5014 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5015 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5016 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005017 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5018 /* Unmute Front out path */
5019 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5020 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5021 /* Unmute Headphone out path */
5022 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5023 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5024 /* Unmute Mono out path */
5025 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5026 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5027 { }
5028};
Takashi Iwai474167d2006-05-17 17:17:43 +02005029#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005030
5031static struct hda_verb alc260_hp_3013_init_verbs[] = {
5032 /* Line out and output */
5033 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5034 /* mono output */
5035 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5036 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5037 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5038 /* Mic2 (front panel) pin widget for input and vref at 80% */
5039 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5040 /* Line In pin widget for input */
5041 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5042 /* Headphone pin widget for output */
5043 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5044 /* CD pin widget for input */
5045 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5046 /* unmute amp left and right */
5047 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5048 /* set connection select to line in (default select for this ADC) */
5049 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5050 /* unmute Line-Out mixer amp left and right (volume = 0) */
5051 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5052 /* mute pin widget amp left and right (no gain on this amp) */
5053 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5054 /* unmute HP mixer amp left and right (volume = 0) */
5055 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5056 /* mute pin widget amp left and right (no gain on this amp) */
5057 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005058 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5059 * Line In 2 = 0x03
5060 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005061 /* mute analog inputs */
5062 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5063 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5064 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5065 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5066 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005067 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5068 /* Unmute Front out path */
5069 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5070 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5071 /* Unmute Headphone out path */
5072 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5073 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5074 /* Unmute Mono out path */
5075 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5076 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5077 { }
5078};
5079
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005080/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005081 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
5082 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005083 */
5084static struct hda_verb alc260_fujitsu_init_verbs[] = {
5085 /* Disable all GPIOs */
5086 {0x01, AC_VERB_SET_GPIO_MASK, 0},
5087 /* Internal speaker is connected to headphone pin */
5088 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5089 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
5090 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005091 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
5092 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5093 /* Ensure all other unused pins are disabled and muted. */
5094 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5095 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005096 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005097 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005098 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005099 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5100 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5101 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005102
Jonathan Woithef7ace402006-02-28 11:46:14 +01005103 /* Disable digital (SPDIF) pins */
5104 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5105 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005106
Kailang Yangea1fb292008-08-26 12:58:38 +02005107 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01005108 * when acting as an output.
5109 */
5110 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5111
5112 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01005113 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5114 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5115 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5116 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5117 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5118 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5119 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5120 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5121 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005122
Jonathan Woithef7ace402006-02-28 11:46:14 +01005123 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
5124 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5125 /* Unmute Line1 pin widget output buffer since it starts as an output.
5126 * If the pin mode is changed by the user the pin mode control will
5127 * take care of enabling the pin's input/output buffers as needed.
5128 * Therefore there's no need to enable the input buffer at this
5129 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005130 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005131 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02005132 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005133 * mixer ctrl)
5134 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005135 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005136
Jonathan Woithef7ace402006-02-28 11:46:14 +01005137 /* Mute capture amp left and right */
5138 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005139 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01005140 * in (on mic1 pin)
5141 */
5142 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005143
Jonathan Woithef7ace402006-02-28 11:46:14 +01005144 /* Do the same for the second ADC: mute capture input amp and
5145 * set ADC connection to line in (on mic1 pin)
5146 */
5147 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5148 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005149
Jonathan Woithef7ace402006-02-28 11:46:14 +01005150 /* Mute all inputs to mixer widget (even unconnected ones) */
5151 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5152 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5153 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5154 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5155 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5156 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5157 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5158 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005159
5160 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005161};
5162
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005163/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
5164 * similar laptops (adapted from Fujitsu init verbs).
5165 */
5166static struct hda_verb alc260_acer_init_verbs[] = {
5167 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
5168 * the headphone jack. Turn this on and rely on the standard mute
5169 * methods whenever the user wants to turn these outputs off.
5170 */
5171 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5172 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5173 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5174 /* Internal speaker/Headphone jack is connected to Line-out pin */
5175 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5176 /* Internal microphone/Mic jack is connected to Mic1 pin */
5177 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5178 /* Line In jack is connected to Line1 pin */
5179 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01005180 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
5181 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005182 /* Ensure all other unused pins are disabled and muted. */
5183 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5184 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005185 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5186 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5187 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5188 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5189 /* Disable digital (SPDIF) pins */
5190 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5191 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5192
Kailang Yangea1fb292008-08-26 12:58:38 +02005193 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005194 * bus when acting as outputs.
5195 */
5196 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5197 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5198
5199 /* Start with output sum widgets muted and their output gains at min */
5200 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5201 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5202 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5203 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5204 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5205 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5206 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5207 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5208 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5209
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005210 /* Unmute Line-out pin widget amp left and right
5211 * (no equiv mixer ctrl)
5212 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005213 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01005214 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
5215 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005216 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5217 * inputs. If the pin mode is changed by the user the pin mode control
5218 * will take care of enabling the pin's input/output buffers as needed.
5219 * Therefore there's no need to enable the input buffer at this
5220 * stage.
5221 */
5222 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5223 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5224
5225 /* Mute capture amp left and right */
5226 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5227 /* Set ADC connection select to match default mixer setting - mic
5228 * (on mic1 pin)
5229 */
5230 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5231
5232 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005233 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005234 */
5235 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005236 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005237
5238 /* Mute all inputs to mixer widget (even unconnected ones) */
5239 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5240 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5241 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5242 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5243 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5244 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5245 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5246 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5247
5248 { }
5249};
5250
Michael Schwingencc959482009-02-22 18:58:45 +01005251/* Initialisation sequence for Maxdata Favorit 100XS
5252 * (adapted from Acer init verbs).
5253 */
5254static struct hda_verb alc260_favorit100_init_verbs[] = {
5255 /* GPIO 0 enables the output jack.
5256 * Turn this on and rely on the standard mute
5257 * methods whenever the user wants to turn these outputs off.
5258 */
5259 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5260 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5261 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5262 /* Line/Mic input jack is connected to Mic1 pin */
5263 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5264 /* Ensure all other unused pins are disabled and muted. */
5265 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5266 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5267 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5268 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5269 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5270 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5271 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5272 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5273 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5274 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5275 /* Disable digital (SPDIF) pins */
5276 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5277 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5278
5279 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
5280 * bus when acting as outputs.
5281 */
5282 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5283 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5284
5285 /* Start with output sum widgets muted and their output gains at min */
5286 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5287 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5288 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5289 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5290 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5291 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5292 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5293 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5294 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5295
5296 /* Unmute Line-out pin widget amp left and right
5297 * (no equiv mixer ctrl)
5298 */
5299 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5300 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5301 * inputs. If the pin mode is changed by the user the pin mode control
5302 * will take care of enabling the pin's input/output buffers as needed.
5303 * Therefore there's no need to enable the input buffer at this
5304 * stage.
5305 */
5306 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5307
5308 /* Mute capture amp left and right */
5309 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5310 /* Set ADC connection select to match default mixer setting - mic
5311 * (on mic1 pin)
5312 */
5313 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5314
5315 /* Do similar with the second ADC: mute capture input amp and
5316 * set ADC connection to mic to match ALSA's default state.
5317 */
5318 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5319 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5320
5321 /* Mute all inputs to mixer widget (even unconnected ones) */
5322 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5323 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5324 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5325 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5326 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5327 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5328 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5329 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5330
5331 { }
5332};
5333
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005334static struct hda_verb alc260_will_verbs[] = {
5335 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5336 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
5337 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
5338 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5339 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5340 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
5341 {}
5342};
5343
5344static struct hda_verb alc260_replacer_672v_verbs[] = {
5345 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5346 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5347 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
5348
5349 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5350 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5351 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5352
5353 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5354 {}
5355};
5356
5357/* toggle speaker-output according to the hp-jack state */
5358static void alc260_replacer_672v_automute(struct hda_codec *codec)
5359{
5360 unsigned int present;
5361
5362 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
5363 present = snd_hda_codec_read(codec, 0x0f, 0,
5364 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5365 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005366 snd_hda_codec_write_cache(codec, 0x01, 0,
5367 AC_VERB_SET_GPIO_DATA, 1);
5368 snd_hda_codec_write_cache(codec, 0x0f, 0,
5369 AC_VERB_SET_PIN_WIDGET_CONTROL,
5370 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005371 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005372 snd_hda_codec_write_cache(codec, 0x01, 0,
5373 AC_VERB_SET_GPIO_DATA, 0);
5374 snd_hda_codec_write_cache(codec, 0x0f, 0,
5375 AC_VERB_SET_PIN_WIDGET_CONTROL,
5376 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005377 }
5378}
5379
5380static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
5381 unsigned int res)
5382{
5383 if ((res >> 26) == ALC880_HP_EVENT)
5384 alc260_replacer_672v_automute(codec);
5385}
5386
Kailang Yang3f878302008-08-26 13:02:23 +02005387static struct hda_verb alc260_hp_dc7600_verbs[] = {
5388 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
5389 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5390 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5391 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5392 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5393 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5394 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5395 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5396 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5397 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5398 {}
5399};
5400
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005401/* Test configuration for debugging, modelled after the ALC880 test
5402 * configuration.
5403 */
5404#ifdef CONFIG_SND_DEBUG
5405static hda_nid_t alc260_test_dac_nids[1] = {
5406 0x02,
5407};
5408static hda_nid_t alc260_test_adc_nids[2] = {
5409 0x04, 0x05,
5410};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005411/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02005412 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005413 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005414 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005415static struct hda_input_mux alc260_test_capture_sources[2] = {
5416 {
5417 .num_items = 7,
5418 .items = {
5419 { "MIC1 pin", 0x0 },
5420 { "MIC2 pin", 0x1 },
5421 { "LINE1 pin", 0x2 },
5422 { "LINE2 pin", 0x3 },
5423 { "CD pin", 0x4 },
5424 { "LINE-OUT pin", 0x5 },
5425 { "HP-OUT pin", 0x6 },
5426 },
5427 },
5428 {
5429 .num_items = 8,
5430 .items = {
5431 { "MIC1 pin", 0x0 },
5432 { "MIC2 pin", 0x1 },
5433 { "LINE1 pin", 0x2 },
5434 { "LINE2 pin", 0x3 },
5435 { "CD pin", 0x4 },
5436 { "Mixer", 0x5 },
5437 { "LINE-OUT pin", 0x6 },
5438 { "HP-OUT pin", 0x7 },
5439 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005440 },
5441};
5442static struct snd_kcontrol_new alc260_test_mixer[] = {
5443 /* Output driver widgets */
5444 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5445 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5446 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5447 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
5448 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5449 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
5450
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005451 /* Modes for retasking pin widgets
5452 * Note: the ALC260 doesn't seem to act on requests to enable mic
5453 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
5454 * mention this restriction. At this stage it's not clear whether
5455 * this behaviour is intentional or is a hardware bug in chip
5456 * revisions available at least up until early 2006. Therefore for
5457 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
5458 * choices, but if it turns out that the lack of mic bias for these
5459 * NIDs is intentional we could change their modes from
5460 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5461 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005462 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
5463 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
5464 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
5465 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
5466 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
5467 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
5468
5469 /* Loopback mixer controls */
5470 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
5471 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
5472 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
5473 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
5474 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
5475 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
5476 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
5477 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
5478 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5479 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005480 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
5481 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
5482 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
5483 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005484
5485 /* Controls for GPIO pins, assuming they are configured as outputs */
5486 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
5487 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
5488 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
5489 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
5490
Jonathan Woithe92621f12006-02-28 11:47:47 +01005491 /* Switches to allow the digital IO pins to be enabled. The datasheet
5492 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02005493 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01005494 */
5495 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
5496 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
5497
Jonathan Woithef8225f62008-01-08 12:16:54 +01005498 /* A switch allowing EAPD to be enabled. Some laptops seem to use
5499 * this output to turn on an external amplifier.
5500 */
5501 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
5502 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
5503
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005504 { } /* end */
5505};
5506static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005507 /* Enable all GPIOs as outputs with an initial value of 0 */
5508 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
5509 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5510 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
5511
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005512 /* Enable retasking pins as output, initially without power amp */
5513 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5514 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5515 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5516 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5517 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5518 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5519
Jonathan Woithe92621f12006-02-28 11:47:47 +01005520 /* Disable digital (SPDIF) pins initially, but users can enable
5521 * them via a mixer switch. In the case of SPDIF-out, this initverb
5522 * payload also sets the generation to 0, output to be in "consumer"
5523 * PCM format, copyright asserted, no pre-emphasis and no validity
5524 * control.
5525 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005526 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5527 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5528
Kailang Yangea1fb292008-08-26 12:58:38 +02005529 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005530 * OUT1 sum bus when acting as an output.
5531 */
5532 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5533 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
5534 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5535 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
5536
5537 /* Start with output sum widgets muted and their output gains at min */
5538 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5539 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5540 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5541 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5542 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5543 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5544 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5545 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5546 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5547
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005548 /* Unmute retasking pin widget output buffers since the default
5549 * state appears to be output. As the pin mode is changed by the
5550 * user the pin mode control will take care of enabling the pin's
5551 * input/output buffers as needed.
5552 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005553 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5554 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5555 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5556 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5557 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5558 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5559 /* Also unmute the mono-out pin widget */
5560 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5561
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005562 /* Mute capture amp left and right */
5563 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005564 /* Set ADC connection select to match default mixer setting (mic1
5565 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005566 */
5567 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5568
5569 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01005570 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005571 */
5572 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5573 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5574
5575 /* Mute all inputs to mixer widget (even unconnected ones) */
5576 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5577 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5578 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5579 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5580 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5581 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5582 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5583 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5584
5585 { }
5586};
5587#endif
5588
Takashi Iwai63300792008-01-24 15:31:36 +01005589#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
5590#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07005591
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005592#define alc260_pcm_digital_playback alc880_pcm_digital_playback
5593#define alc260_pcm_digital_capture alc880_pcm_digital_capture
5594
Kailang Yangdf694da2005-12-05 19:42:22 +01005595/*
5596 * for BIOS auto-configuration
5597 */
5598
5599static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02005600 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01005601{
5602 hda_nid_t nid_vol;
5603 unsigned long vol_val, sw_val;
5604 char name[32];
5605 int err;
5606
5607 if (nid >= 0x0f && nid < 0x11) {
5608 nid_vol = nid - 0x7;
5609 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5610 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5611 } else if (nid == 0x11) {
5612 nid_vol = nid - 0x7;
5613 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
5614 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
5615 } else if (nid >= 0x12 && nid <= 0x15) {
5616 nid_vol = 0x08;
5617 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5618 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5619 } else
5620 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02005621
Takashi Iwai863b4512008-10-21 17:01:47 +02005622 if (!(*vol_bits & (1 << nid_vol))) {
5623 /* first control for the volume widget */
5624 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
5625 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
5626 if (err < 0)
5627 return err;
5628 *vol_bits |= (1 << nid_vol);
5629 }
Kailang Yangdf694da2005-12-05 19:42:22 +01005630 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005631 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
5632 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005633 return err;
5634 return 1;
5635}
5636
5637/* add playback controls from the parsed DAC table */
5638static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
5639 const struct auto_pin_cfg *cfg)
5640{
5641 hda_nid_t nid;
5642 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02005643 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005644
5645 spec->multiout.num_dacs = 1;
5646 spec->multiout.dac_nids = spec->private_dac_nids;
5647 spec->multiout.dac_nids[0] = 0x02;
5648
5649 nid = cfg->line_out_pins[0];
5650 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005651 err = alc260_add_playback_controls(spec, nid, "Front", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005652 if (err < 0)
5653 return err;
5654 }
5655
Takashi Iwai82bc9552006-03-21 11:24:42 +01005656 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005657 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005658 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005659 if (err < 0)
5660 return err;
5661 }
5662
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005663 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005664 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005665 err = alc260_add_playback_controls(spec, nid, "Headphone",
5666 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005667 if (err < 0)
5668 return err;
5669 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005670 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005671}
5672
5673/* create playback/capture controls for input pins */
5674static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
5675 const struct auto_pin_cfg *cfg)
5676{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005677 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005678 int i, err, idx;
5679
5680 for (i = 0; i < AUTO_PIN_LAST; i++) {
5681 if (cfg->input_pins[i] >= 0x12) {
5682 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005683 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005684 auto_pin_cfg_labels[i], idx,
5685 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005686 if (err < 0)
5687 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005688 imux->items[imux->num_items].label =
5689 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005690 imux->items[imux->num_items].index = idx;
5691 imux->num_items++;
5692 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005693 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01005694 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005695 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005696 auto_pin_cfg_labels[i], idx,
5697 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005698 if (err < 0)
5699 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005700 imux->items[imux->num_items].label =
5701 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005702 imux->items[imux->num_items].index = idx;
5703 imux->num_items++;
5704 }
5705 }
5706 return 0;
5707}
5708
5709static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
5710 hda_nid_t nid, int pin_type,
5711 int sel_idx)
5712{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005713 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01005714 /* need the manual connection? */
5715 if (nid >= 0x12) {
5716 int idx = nid - 0x12;
5717 snd_hda_codec_write(codec, idx + 0x0b, 0,
5718 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01005719 }
5720}
5721
5722static void alc260_auto_init_multi_out(struct hda_codec *codec)
5723{
5724 struct alc_spec *spec = codec->spec;
5725 hda_nid_t nid;
5726
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005727 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005728 if (nid) {
5729 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5730 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
5731 }
Kailang Yangea1fb292008-08-26 12:58:38 +02005732
Takashi Iwai82bc9552006-03-21 11:24:42 +01005733 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005734 if (nid)
5735 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
5736
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005737 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005738 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005739 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005740}
Kailang Yangdf694da2005-12-05 19:42:22 +01005741
5742#define ALC260_PIN_CD_NID 0x16
5743static void alc260_auto_init_analog_input(struct hda_codec *codec)
5744{
5745 struct alc_spec *spec = codec->spec;
5746 int i;
5747
5748 for (i = 0; i < AUTO_PIN_LAST; i++) {
5749 hda_nid_t nid = spec->autocfg.input_pins[i];
5750 if (nid >= 0x12) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01005751 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01005752 if (nid != ALC260_PIN_CD_NID &&
5753 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005754 snd_hda_codec_write(codec, nid, 0,
5755 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01005756 AMP_OUT_MUTE);
5757 }
5758 }
5759}
5760
5761/*
5762 * generic initialization of ADC, input mixers and output mixers
5763 */
5764static struct hda_verb alc260_volume_init_verbs[] = {
5765 /*
5766 * Unmute ADC0-1 and set the default input to mic-in
5767 */
5768 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5769 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5770 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5771 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005772
Kailang Yangdf694da2005-12-05 19:42:22 +01005773 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5774 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005775 * Note: PASD motherboards uses the Line In 2 as the input for
5776 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01005777 */
5778 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005779 /* mute analog inputs */
5780 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5781 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5782 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5783 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5784 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005785
5786 /*
5787 * Set up output mixers (0x08 - 0x0a)
5788 */
5789 /* set vol=0 to output mixers */
5790 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5791 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5792 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5793 /* set up input amps for analog loopback */
5794 /* Amp Indices: DAC = 0, mixer = 1 */
5795 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5796 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5797 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5798 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5799 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5800 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005801
Kailang Yangdf694da2005-12-05 19:42:22 +01005802 { }
5803};
5804
5805static int alc260_parse_auto_config(struct hda_codec *codec)
5806{
5807 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005808 int err;
5809 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
5810
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005811 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5812 alc260_ignore);
5813 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005814 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005815 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
5816 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01005817 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02005818 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01005819 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005820 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
5821 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005822 return err;
5823
5824 spec->multiout.max_channels = 2;
5825
Takashi Iwai0852d7a2009-02-11 11:35:15 +01005826 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01005827 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02005828 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01005829 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01005830
Takashi Iwaid88897e2008-10-31 15:01:37 +01005831 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01005832
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005833 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005834 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005835
Takashi Iwai4a79ba32009-04-22 16:31:35 +02005836 alc_ssid_check(codec, 0x10, 0x15, 0x0f);
5837
Kailang Yangdf694da2005-12-05 19:42:22 +01005838 return 1;
5839}
5840
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005841/* additional initialization for auto-configuration model */
5842static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01005843{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005844 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005845 alc260_auto_init_multi_out(codec);
5846 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005847 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02005848 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005849}
5850
Takashi Iwaicb53c622007-08-10 17:21:45 +02005851#ifdef CONFIG_SND_HDA_POWER_SAVE
5852static struct hda_amp_list alc260_loopbacks[] = {
5853 { 0x07, HDA_INPUT, 0 },
5854 { 0x07, HDA_INPUT, 1 },
5855 { 0x07, HDA_INPUT, 2 },
5856 { 0x07, HDA_INPUT, 3 },
5857 { 0x07, HDA_INPUT, 4 },
5858 { } /* end */
5859};
5860#endif
5861
Kailang Yangdf694da2005-12-05 19:42:22 +01005862/*
5863 * ALC260 configurations
5864 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005865static const char *alc260_models[ALC260_MODEL_LAST] = {
5866 [ALC260_BASIC] = "basic",
5867 [ALC260_HP] = "hp",
5868 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02005869 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005870 [ALC260_FUJITSU_S702X] = "fujitsu",
5871 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005872 [ALC260_WILL] = "will",
5873 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01005874 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005875#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005876 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005877#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005878 [ALC260_AUTO] = "auto",
5879};
5880
5881static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01005882 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005883 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01005884 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01005885 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01005886 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005887 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02005888 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02005889 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005890 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
5891 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
5892 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
5893 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
5894 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
5895 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
5896 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
5897 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
5898 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005899 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01005900 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02005901 {}
5902};
5903
Kailang Yangdf694da2005-12-05 19:42:22 +01005904static struct alc_config_preset alc260_presets[] = {
5905 [ALC260_BASIC] = {
5906 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005907 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01005908 .init_verbs = { alc260_init_verbs },
5909 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5910 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005911 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Kailang Yangdf694da2005-12-05 19:42:22 +01005912 .adc_nids = alc260_adc_nids,
5913 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5914 .channel_mode = alc260_modes,
5915 .input_mux = &alc260_capture_source,
5916 },
5917 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005918 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005919 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005920 .init_verbs = { alc260_init_verbs,
5921 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005922 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5923 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005924 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5925 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01005926 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5927 .channel_mode = alc260_modes,
5928 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005929 .unsol_event = alc260_hp_unsol_event,
5930 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005931 },
Kailang Yang3f878302008-08-26 13:02:23 +02005932 [ALC260_HP_DC7600] = {
5933 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005934 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02005935 .init_verbs = { alc260_init_verbs,
5936 alc260_hp_dc7600_verbs },
5937 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5938 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005939 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5940 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02005941 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5942 .channel_mode = alc260_modes,
5943 .input_mux = &alc260_capture_source,
5944 .unsol_event = alc260_hp_3012_unsol_event,
5945 .init_hook = alc260_hp_3012_automute,
5946 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005947 [ALC260_HP_3013] = {
5948 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005949 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005950 .init_verbs = { alc260_hp_3013_init_verbs,
5951 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005952 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5953 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005954 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5955 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01005956 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5957 .channel_mode = alc260_modes,
5958 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005959 .unsol_event = alc260_hp_3013_unsol_event,
5960 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005961 },
5962 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005963 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01005964 .init_verbs = { alc260_fujitsu_init_verbs },
5965 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5966 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005967 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5968 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01005969 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5970 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005971 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
5972 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01005973 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005974 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005975 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005976 .init_verbs = { alc260_acer_init_verbs },
5977 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5978 .dac_nids = alc260_dac_nids,
5979 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5980 .adc_nids = alc260_dual_adc_nids,
5981 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5982 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005983 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
5984 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005985 },
Michael Schwingencc959482009-02-22 18:58:45 +01005986 [ALC260_FAVORIT100] = {
5987 .mixers = { alc260_favorit100_mixer },
5988 .init_verbs = { alc260_favorit100_init_verbs },
5989 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5990 .dac_nids = alc260_dac_nids,
5991 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5992 .adc_nids = alc260_dual_adc_nids,
5993 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5994 .channel_mode = alc260_modes,
5995 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
5996 .input_mux = alc260_favorit100_capture_sources,
5997 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005998 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005999 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006000 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
6001 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6002 .dac_nids = alc260_dac_nids,
6003 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6004 .adc_nids = alc260_adc_nids,
6005 .dig_out_nid = ALC260_DIGOUT_NID,
6006 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6007 .channel_mode = alc260_modes,
6008 .input_mux = &alc260_capture_source,
6009 },
6010 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006011 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006012 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
6013 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6014 .dac_nids = alc260_dac_nids,
6015 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6016 .adc_nids = alc260_adc_nids,
6017 .dig_out_nid = ALC260_DIGOUT_NID,
6018 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6019 .channel_mode = alc260_modes,
6020 .input_mux = &alc260_capture_source,
6021 .unsol_event = alc260_replacer_672v_unsol_event,
6022 .init_hook = alc260_replacer_672v_automute,
6023 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006024#ifdef CONFIG_SND_DEBUG
6025 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006026 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006027 .init_verbs = { alc260_test_init_verbs },
6028 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
6029 .dac_nids = alc260_test_dac_nids,
6030 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
6031 .adc_nids = alc260_test_adc_nids,
6032 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6033 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006034 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
6035 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006036 },
6037#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006038};
6039
Linus Torvalds1da177e2005-04-16 15:20:36 -07006040static int patch_alc260(struct hda_codec *codec)
6041{
6042 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006043 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006044
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006045 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006046 if (spec == NULL)
6047 return -ENOMEM;
6048
6049 codec->spec = spec;
6050
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006051 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
6052 alc260_models,
6053 alc260_cfg_tbl);
6054 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006055 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
6056 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006057 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02006058 }
6059
Kailang Yangdf694da2005-12-05 19:42:22 +01006060 if (board_config == ALC260_AUTO) {
6061 /* automatic parse from the BIOS config */
6062 err = alc260_parse_auto_config(codec);
6063 if (err < 0) {
6064 alc_free(codec);
6065 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006066 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006067 printk(KERN_INFO
6068 "hda_codec: Cannot set up configuration "
6069 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006070 board_config = ALC260_BASIC;
6071 }
Takashi Iwai16ded522005-06-10 19:58:24 +02006072 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006073
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09006074 err = snd_hda_attach_beep_device(codec, 0x1);
6075 if (err < 0) {
6076 alc_free(codec);
6077 return err;
6078 }
6079
Kailang Yangdf694da2005-12-05 19:42:22 +01006080 if (board_config != ALC260_AUTO)
6081 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006082
6083 spec->stream_name_analog = "ALC260 Analog";
6084 spec->stream_analog_playback = &alc260_pcm_analog_playback;
6085 spec->stream_analog_capture = &alc260_pcm_analog_capture;
6086
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006087 spec->stream_name_digital = "ALC260 Digital";
6088 spec->stream_digital_playback = &alc260_pcm_digital_playback;
6089 spec->stream_digital_capture = &alc260_pcm_digital_capture;
6090
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006091 if (!spec->adc_nids && spec->input_mux) {
6092 /* check whether NID 0x04 is valid */
6093 unsigned int wcap = get_wcaps(codec, 0x04);
6094 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
6095 /* get type */
6096 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
6097 spec->adc_nids = alc260_adc_nids_alt;
6098 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
6099 } else {
6100 spec->adc_nids = alc260_adc_nids;
6101 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
6102 }
6103 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006104 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006105 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006106
Takashi Iwai2134ea42008-01-10 16:53:55 +01006107 spec->vmaster_nid = 0x08;
6108
Linus Torvalds1da177e2005-04-16 15:20:36 -07006109 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006110 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006111 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006112#ifdef CONFIG_SND_HDA_POWER_SAVE
6113 if (!spec->loopback.amplist)
6114 spec->loopback.amplist = alc260_loopbacks;
6115#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01006116 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006117
6118 return 0;
6119}
6120
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006121
Linus Torvalds1da177e2005-04-16 15:20:36 -07006122/*
6123 * ALC882 support
6124 *
6125 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
6126 * configuration. Each pin widget can choose any input DACs and a mixer.
6127 * Each ADC is connected from a mixer of all inputs. This makes possible
6128 * 6-channel independent captures.
6129 *
6130 * In addition, an independent DAC for the multi-playback (not used in this
6131 * driver yet).
6132 */
Kailang Yangdf694da2005-12-05 19:42:22 +01006133#define ALC882_DIGOUT_NID 0x06
6134#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07006135
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01006136static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07006137 { 8, NULL }
6138};
6139
6140static hda_nid_t alc882_dac_nids[4] = {
6141 /* front, rear, clfe, rear_surr */
6142 0x02, 0x03, 0x04, 0x05
6143};
6144
Kailang Yangdf694da2005-12-05 19:42:22 +01006145/* identical with ALC880 */
6146#define alc882_adc_nids alc880_adc_nids
6147#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07006148
Takashi Iwaie1406342008-02-11 18:32:32 +01006149static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
6150static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
6151
Linus Torvalds1da177e2005-04-16 15:20:36 -07006152/* input MUX */
6153/* FIXME: should be a matrix-type input source selection */
6154
6155static struct hda_input_mux alc882_capture_source = {
6156 .num_items = 4,
6157 .items = {
6158 { "Mic", 0x0 },
6159 { "Front Mic", 0x1 },
6160 { "Line", 0x2 },
6161 { "CD", 0x4 },
6162 },
6163};
Kailang Yangdf694da2005-12-05 19:42:22 +01006164/*
Kailang Yang272a5272007-05-14 11:00:38 +02006165 * 2ch mode
6166 */
6167static struct hda_verb alc882_3ST_ch2_init[] = {
6168 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6169 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6170 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6171 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6172 { } /* end */
6173};
6174
6175/*
6176 * 6ch mode
6177 */
6178static struct hda_verb alc882_3ST_ch6_init[] = {
6179 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6180 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6181 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6182 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6183 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6184 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6185 { } /* end */
6186};
6187
6188static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
6189 { 2, alc882_3ST_ch2_init },
6190 { 6, alc882_3ST_ch6_init },
6191};
6192
6193/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006194 * 6ch mode
6195 */
6196static struct hda_verb alc882_sixstack_ch6_init[] = {
6197 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6198 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6199 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6200 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6201 { } /* end */
6202};
6203
6204/*
6205 * 8ch mode
6206 */
6207static struct hda_verb alc882_sixstack_ch8_init[] = {
6208 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6209 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6210 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6211 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6212 { } /* end */
6213};
6214
6215static struct hda_channel_mode alc882_sixstack_modes[2] = {
6216 { 6, alc882_sixstack_ch6_init },
6217 { 8, alc882_sixstack_ch8_init },
6218};
6219
Takashi Iwai87350ad2007-08-16 18:19:38 +02006220/*
6221 * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
6222 */
6223
6224/*
6225 * 2ch mode
6226 */
6227static struct hda_verb alc885_mbp_ch2_init[] = {
6228 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6229 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6230 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6231 { } /* end */
6232};
6233
6234/*
6235 * 6ch mode
6236 */
6237static struct hda_verb alc885_mbp_ch6_init[] = {
6238 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6239 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6240 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6241 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6242 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6243 { } /* end */
6244};
6245
6246static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
6247 { 2, alc885_mbp_ch2_init },
6248 { 6, alc885_mbp_ch6_init },
6249};
6250
6251
Linus Torvalds1da177e2005-04-16 15:20:36 -07006252/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6253 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6254 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01006255static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02006256 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006257 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006258 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006259 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006260 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6261 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006262 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6263 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006264 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006265 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006266 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6267 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6268 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6269 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6270 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6271 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006272 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006273 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6274 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006275 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006276 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006277 { } /* end */
6278};
6279
Takashi Iwai87350ad2007-08-16 18:19:38 +02006280static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01006281 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6282 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
6283 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
6284 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
6285 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6286 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006287 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
6288 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01006289 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006290 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
6291 { } /* end */
6292};
Kailang Yangbdd148a2007-05-08 15:19:08 +02006293static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
6294 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6295 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6296 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6297 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6298 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6299 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6300 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6301 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6302 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02006303 { } /* end */
6304};
6305
Kailang Yang272a5272007-05-14 11:00:38 +02006306static struct snd_kcontrol_new alc882_targa_mixer[] = {
6307 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6308 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6309 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6310 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6311 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6312 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6313 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6314 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6315 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006316 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006317 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6318 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006319 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006320 { } /* end */
6321};
6322
6323/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
6324 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
6325 */
6326static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
6327 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6328 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6329 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6330 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
6331 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6332 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6333 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6334 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6335 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
6336 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
6337 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6338 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006339 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006340 { } /* end */
6341};
6342
Takashi Iwai914759b2007-09-06 14:52:04 +02006343static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
6344 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6345 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6346 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6347 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6348 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6349 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6350 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6351 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6352 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6353 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02006354 { } /* end */
6355};
6356
Kailang Yangdf694da2005-12-05 19:42:22 +01006357static struct snd_kcontrol_new alc882_chmode_mixer[] = {
6358 {
6359 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6360 .name = "Channel Mode",
6361 .info = alc_ch_mode_info,
6362 .get = alc_ch_mode_get,
6363 .put = alc_ch_mode_put,
6364 },
6365 { } /* end */
6366};
6367
Linus Torvalds1da177e2005-04-16 15:20:36 -07006368static struct hda_verb alc882_init_verbs[] = {
6369 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006370 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6371 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6372 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006373 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006374 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6375 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6376 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006377 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006378 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6379 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6380 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006381 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006382 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6383 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6384 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006385
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006386 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006387 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006388 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006389 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006390 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006391 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006392 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006393 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006394 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006395 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006396 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006397 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006398 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006399 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006400 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006401 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006402 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006403 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006404 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6405 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006406 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006407 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6408 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006409 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006410 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6411 /* Line-2 In: Headphone output (output 0 - 0x0c) */
6412 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6413 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6414 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006415 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006416 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006417
6418 /* FIXME: use matrix-type input source selection */
6419 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6420 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02006421 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6422 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6423 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6424 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006425 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006426 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6427 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6428 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6429 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006430 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006431 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6432 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6433 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6434 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6435 /* ADC1: mute amp left and right */
6436 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006437 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02006438 /* ADC2: mute amp left and right */
6439 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006440 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02006441 /* ADC3: mute amp left and right */
6442 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006443 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006444
6445 { }
6446};
6447
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006448static struct hda_verb alc882_eapd_verbs[] = {
6449 /* change to EAPD mode */
6450 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006451 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006452 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006453};
6454
Tobin Davis9102cd12006-12-15 10:02:12 +01006455/* Mac Pro test */
6456static struct snd_kcontrol_new alc882_macpro_mixer[] = {
6457 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6458 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6459 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
6460 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
6461 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006462 /* FIXME: this looks suspicious...
Tobin Davis9102cd12006-12-15 10:02:12 +01006463 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
6464 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006465 */
Tobin Davis9102cd12006-12-15 10:02:12 +01006466 { } /* end */
6467};
6468
6469static struct hda_verb alc882_macpro_init_verbs[] = {
6470 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6471 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6472 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6473 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6474 /* Front Pin: output 0 (0x0c) */
6475 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6476 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6477 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6478 /* Front Mic pin: input vref at 80% */
6479 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6480 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6481 /* Speaker: output */
6482 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6483 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6484 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
6485 /* Headphone output (output 0 - 0x0c) */
6486 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6487 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6488 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6489
6490 /* FIXME: use matrix-type input source selection */
6491 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6492 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6493 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6494 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6495 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6496 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6497 /* Input mixer2 */
6498 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6499 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6500 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6501 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6502 /* Input mixer3 */
6503 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6504 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6505 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6506 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6507 /* ADC1: mute amp left and right */
6508 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6509 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6510 /* ADC2: mute amp left and right */
6511 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6512 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6513 /* ADC3: mute amp left and right */
6514 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6515 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6516
6517 { }
6518};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006519
Takashi Iwai87350ad2007-08-16 18:19:38 +02006520/* Macbook Pro rev3 */
6521static struct hda_verb alc885_mbp3_init_verbs[] = {
6522 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6523 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6524 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6525 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6526 /* Rear mixer */
6527 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6528 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6529 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6530 /* Front Pin: output 0 (0x0c) */
6531 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6532 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6533 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6534 /* HP Pin: output 0 (0x0d) */
6535 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
6536 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6537 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6538 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6539 /* Mic (rear) pin: input vref at 80% */
6540 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6541 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6542 /* Front Mic pin: input vref at 80% */
6543 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6544 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6545 /* Line In pin: use output 1 when in LineOut mode */
6546 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6547 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6548 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
6549
6550 /* FIXME: use matrix-type input source selection */
6551 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6552 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6553 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6554 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6555 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6556 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6557 /* Input mixer2 */
6558 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6559 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6560 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6561 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6562 /* Input mixer3 */
6563 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6564 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6565 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6566 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6567 /* ADC1: mute amp left and right */
6568 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6569 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6570 /* ADC2: mute amp left and right */
6571 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6572 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6573 /* ADC3: mute amp left and right */
6574 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6575 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6576
6577 { }
6578};
6579
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006580/* iMac 24 mixer. */
6581static struct snd_kcontrol_new alc885_imac24_mixer[] = {
6582 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6583 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
6584 { } /* end */
6585};
6586
6587/* iMac 24 init verbs. */
6588static struct hda_verb alc885_imac24_init_verbs[] = {
6589 /* Internal speakers: output 0 (0x0c) */
6590 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6591 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6592 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6593 /* Internal speakers: output 0 (0x0c) */
6594 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6595 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6596 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
6597 /* Headphone: output 0 (0x0c) */
6598 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6599 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6600 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6601 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6602 /* Front Mic: input vref at 80% */
6603 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6604 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6605 { }
6606};
6607
6608/* Toggle speaker-output according to the hp-jack state */
6609static void alc885_imac24_automute(struct hda_codec *codec)
6610{
6611 unsigned int present;
6612
6613 present = snd_hda_codec_read(codec, 0x14, 0,
6614 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02006615 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
6616 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6617 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
6618 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006619}
6620
6621/* Processes unsolicited events. */
6622static void alc885_imac24_unsol_event(struct hda_codec *codec,
6623 unsigned int res)
6624{
6625 /* Headphone insertion or removal. */
6626 if ((res >> 26) == ALC880_HP_EVENT)
6627 alc885_imac24_automute(codec);
6628}
6629
Takashi Iwai87350ad2007-08-16 18:19:38 +02006630static void alc885_mbp3_automute(struct hda_codec *codec)
6631{
6632 unsigned int present;
6633
6634 present = snd_hda_codec_read(codec, 0x15, 0,
6635 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6636 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
6637 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6638 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6639 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
6640
6641}
6642static void alc885_mbp3_unsol_event(struct hda_codec *codec,
6643 unsigned int res)
6644{
6645 /* Headphone insertion or removal. */
6646 if ((res >> 26) == ALC880_HP_EVENT)
6647 alc885_mbp3_automute(codec);
6648}
6649
6650
Kailang Yang272a5272007-05-14 11:00:38 +02006651static struct hda_verb alc882_targa_verbs[] = {
6652 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6653 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6654
6655 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6656 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006657
Kailang Yang272a5272007-05-14 11:00:38 +02006658 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6659 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6660 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6661
6662 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6663 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
6664 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
6665 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
6666 { } /* end */
6667};
6668
6669/* toggle speaker-output according to the hp-jack state */
6670static void alc882_targa_automute(struct hda_codec *codec)
6671{
6672 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02006673
Kailang Yang272a5272007-05-14 11:00:38 +02006674 present = snd_hda_codec_read(codec, 0x14, 0,
6675 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02006676 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
6677 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006678 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
6679 present ? 1 : 3);
Kailang Yang272a5272007-05-14 11:00:38 +02006680}
6681
6682static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
6683{
6684 /* Looks like the unsol event is incompatible with the standard
6685 * definition. 4bit tag is placed at 26 bit!
6686 */
6687 if (((res >> 26) == ALC880_HP_EVENT)) {
6688 alc882_targa_automute(codec);
6689 }
6690}
6691
6692static struct hda_verb alc882_asus_a7j_verbs[] = {
6693 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6694 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6695
6696 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6697 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6698 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006699
Kailang Yang272a5272007-05-14 11:00:38 +02006700 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6701 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6702 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6703
6704 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6705 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6706 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6707 { } /* end */
6708};
6709
Takashi Iwai914759b2007-09-06 14:52:04 +02006710static struct hda_verb alc882_asus_a7m_verbs[] = {
6711 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6712 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6713
6714 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6715 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6716 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006717
Takashi Iwai914759b2007-09-06 14:52:04 +02006718 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6719 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6720 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6721
6722 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6723 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6724 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6725 { } /* end */
6726};
6727
Tobin Davis9102cd12006-12-15 10:02:12 +01006728static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
6729{
6730 unsigned int gpiostate, gpiomask, gpiodir;
6731
6732 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
6733 AC_VERB_GET_GPIO_DATA, 0);
6734
6735 if (!muted)
6736 gpiostate |= (1 << pin);
6737 else
6738 gpiostate &= ~(1 << pin);
6739
6740 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
6741 AC_VERB_GET_GPIO_MASK, 0);
6742 gpiomask |= (1 << pin);
6743
6744 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
6745 AC_VERB_GET_GPIO_DIRECTION, 0);
6746 gpiodir |= (1 << pin);
6747
6748
6749 snd_hda_codec_write(codec, codec->afg, 0,
6750 AC_VERB_SET_GPIO_MASK, gpiomask);
6751 snd_hda_codec_write(codec, codec->afg, 0,
6752 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
6753
6754 msleep(1);
6755
6756 snd_hda_codec_write(codec, codec->afg, 0,
6757 AC_VERB_SET_GPIO_DATA, gpiostate);
6758}
6759
Takashi Iwai7debbe52007-08-16 15:01:03 +02006760/* set up GPIO at initialization */
6761static void alc885_macpro_init_hook(struct hda_codec *codec)
6762{
6763 alc882_gpio_mute(codec, 0, 0);
6764 alc882_gpio_mute(codec, 1, 0);
6765}
6766
6767/* set up GPIO and update auto-muting at initialization */
6768static void alc885_imac24_init_hook(struct hda_codec *codec)
6769{
6770 alc885_macpro_init_hook(codec);
6771 alc885_imac24_automute(codec);
6772}
6773
Kailang Yangdf694da2005-12-05 19:42:22 +01006774/*
6775 * generic initialization of ADC, input mixers and output mixers
6776 */
6777static struct hda_verb alc882_auto_init_verbs[] = {
6778 /*
6779 * Unmute ADC0-2 and set the default input to mic-in
6780 */
6781 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6782 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6783 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6784 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6785 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6786 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6787
Takashi Iwaicb53c622007-08-10 17:21:45 +02006788 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01006789 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006790 * Note: PASD motherboards uses the Line In 2 as the input for
6791 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006792 */
6793 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006794 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6795 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6796 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6797 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6798 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006799
6800 /*
6801 * Set up output mixers (0x0c - 0x0f)
6802 */
6803 /* set vol=0 to output mixers */
6804 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6805 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6806 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6807 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6808 /* set up input amps for analog loopback */
6809 /* Amp Indices: DAC = 0, mixer = 1 */
6810 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6811 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6812 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6813 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6814 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6815 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6816 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6817 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6818 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6819 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6820
6821 /* FIXME: use matrix-type input source selection */
6822 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6823 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6824 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6825 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6826 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6827 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6828 /* Input mixer2 */
6829 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6830 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6831 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6832 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6833 /* Input mixer3 */
6834 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6835 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6836 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6837 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6838
6839 { }
6840};
6841
Takashi Iwaicb53c622007-08-10 17:21:45 +02006842#ifdef CONFIG_SND_HDA_POWER_SAVE
6843#define alc882_loopbacks alc880_loopbacks
6844#endif
6845
Kailang Yangdf694da2005-12-05 19:42:22 +01006846/* pcm configuration: identiacal with ALC880 */
6847#define alc882_pcm_analog_playback alc880_pcm_analog_playback
6848#define alc882_pcm_analog_capture alc880_pcm_analog_capture
6849#define alc882_pcm_digital_playback alc880_pcm_digital_playback
6850#define alc882_pcm_digital_capture alc880_pcm_digital_capture
6851
6852/*
6853 * configuration and preset
6854 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006855static const char *alc882_models[ALC882_MODEL_LAST] = {
6856 [ALC882_3ST_DIG] = "3stack-dig",
6857 [ALC882_6ST_DIG] = "6stack-dig",
6858 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02006859 [ALC882_W2JC] = "w2jc",
Takashi Iwai0438a002007-09-06 14:54:11 +02006860 [ALC882_TARGA] = "targa",
6861 [ALC882_ASUS_A7J] = "asus-a7j",
6862 [ALC882_ASUS_A7M] = "asus-a7m",
Tobin Davis9102cd12006-12-15 10:02:12 +01006863 [ALC885_MACPRO] = "macpro",
Takashi Iwai87350ad2007-08-16 18:19:38 +02006864 [ALC885_MBP3] = "mbp3",
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006865 [ALC885_IMAC24] = "imac24",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006866 [ALC882_AUTO] = "auto",
6867};
6868
6869static struct snd_pci_quirk alc882_cfg_tbl[] = {
6870 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02006871 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Kailang Yangac8842a2007-09-20 12:51:39 +02006872 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
Takashi Iwai914759b2007-09-06 14:52:04 +02006873 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006874 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Claudio Matsuokac5d9f1c2007-07-19 23:18:32 +02006875 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
Tobin Davis7b9470d2006-12-28 13:56:48 +01006876 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006877 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Jiang zhe44447042008-01-28 12:28:24 +01006878 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006879 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
6880 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
6881 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yangdf694da2005-12-05 19:42:22 +01006882 {}
6883};
6884
6885static struct alc_config_preset alc882_presets[] = {
6886 [ALC882_3ST_DIG] = {
6887 .mixers = { alc882_base_mixer },
6888 .init_verbs = { alc882_init_verbs },
6889 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6890 .dac_nids = alc882_dac_nids,
6891 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006892 .dig_in_nid = ALC882_DIGIN_NID,
6893 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6894 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006895 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01006896 .input_mux = &alc882_capture_source,
6897 },
6898 [ALC882_6ST_DIG] = {
6899 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6900 .init_verbs = { alc882_init_verbs },
6901 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6902 .dac_nids = alc882_dac_nids,
6903 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006904 .dig_in_nid = ALC882_DIGIN_NID,
6905 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6906 .channel_mode = alc882_sixstack_modes,
6907 .input_mux = &alc882_capture_source,
6908 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006909 [ALC882_ARIMA] = {
6910 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6911 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
6912 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6913 .dac_nids = alc882_dac_nids,
6914 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6915 .channel_mode = alc882_sixstack_modes,
6916 .input_mux = &alc882_capture_source,
6917 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02006918 [ALC882_W2JC] = {
6919 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
6920 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6921 alc880_gpio1_init_verbs },
6922 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6923 .dac_nids = alc882_dac_nids,
6924 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6925 .channel_mode = alc880_threestack_modes,
6926 .need_dac_fix = 1,
6927 .input_mux = &alc882_capture_source,
6928 .dig_out_nid = ALC882_DIGOUT_NID,
6929 },
Takashi Iwai87350ad2007-08-16 18:19:38 +02006930 [ALC885_MBP3] = {
6931 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
6932 .init_verbs = { alc885_mbp3_init_verbs,
6933 alc880_gpio1_init_verbs },
6934 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6935 .dac_nids = alc882_dac_nids,
6936 .channel_mode = alc885_mbp_6ch_modes,
6937 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
6938 .input_mux = &alc882_capture_source,
6939 .dig_out_nid = ALC882_DIGOUT_NID,
6940 .dig_in_nid = ALC882_DIGIN_NID,
6941 .unsol_event = alc885_mbp3_unsol_event,
6942 .init_hook = alc885_mbp3_automute,
6943 },
Tobin Davis9102cd12006-12-15 10:02:12 +01006944 [ALC885_MACPRO] = {
6945 .mixers = { alc882_macpro_mixer },
6946 .init_verbs = { alc882_macpro_init_verbs },
6947 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6948 .dac_nids = alc882_dac_nids,
6949 .dig_out_nid = ALC882_DIGOUT_NID,
6950 .dig_in_nid = ALC882_DIGIN_NID,
6951 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6952 .channel_mode = alc882_ch_modes,
6953 .input_mux = &alc882_capture_source,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006954 .init_hook = alc885_macpro_init_hook,
Tobin Davis9102cd12006-12-15 10:02:12 +01006955 },
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006956 [ALC885_IMAC24] = {
6957 .mixers = { alc885_imac24_mixer },
6958 .init_verbs = { alc885_imac24_init_verbs },
6959 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6960 .dac_nids = alc882_dac_nids,
6961 .dig_out_nid = ALC882_DIGOUT_NID,
6962 .dig_in_nid = ALC882_DIGIN_NID,
6963 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6964 .channel_mode = alc882_ch_modes,
6965 .input_mux = &alc882_capture_source,
6966 .unsol_event = alc885_imac24_unsol_event,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006967 .init_hook = alc885_imac24_init_hook,
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006968 },
Kailang Yang272a5272007-05-14 11:00:38 +02006969 [ALC882_TARGA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006970 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Kailang Yang272a5272007-05-14 11:00:38 +02006971 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
6972 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6973 .dac_nids = alc882_dac_nids,
6974 .dig_out_nid = ALC882_DIGOUT_NID,
6975 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6976 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01006977 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02006978 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6979 .channel_mode = alc882_3ST_6ch_modes,
6980 .need_dac_fix = 1,
6981 .input_mux = &alc882_capture_source,
6982 .unsol_event = alc882_targa_unsol_event,
6983 .init_hook = alc882_targa_automute,
6984 },
6985 [ALC882_ASUS_A7J] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006986 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Kailang Yang272a5272007-05-14 11:00:38 +02006987 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
6988 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6989 .dac_nids = alc882_dac_nids,
6990 .dig_out_nid = ALC882_DIGOUT_NID,
6991 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6992 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01006993 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02006994 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6995 .channel_mode = alc882_3ST_6ch_modes,
6996 .need_dac_fix = 1,
6997 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02006998 },
Takashi Iwai914759b2007-09-06 14:52:04 +02006999 [ALC882_ASUS_A7M] = {
7000 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
7001 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
7002 alc880_gpio1_init_verbs,
7003 alc882_asus_a7m_verbs },
7004 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7005 .dac_nids = alc882_dac_nids,
7006 .dig_out_nid = ALC882_DIGOUT_NID,
7007 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
7008 .channel_mode = alc880_threestack_modes,
7009 .need_dac_fix = 1,
7010 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02007011 },
Kailang Yangdf694da2005-12-05 19:42:22 +01007012};
7013
7014
7015/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02007016 * Pin config fixes
7017 */
Kailang Yangea1fb292008-08-26 12:58:38 +02007018enum {
Takashi Iwaif95474e2007-07-10 00:47:43 +02007019 PINFIX_ABIT_AW9D_MAX
7020};
7021
7022static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
7023 { 0x15, 0x01080104 }, /* side */
7024 { 0x16, 0x01011012 }, /* rear */
7025 { 0x17, 0x01016011 }, /* clfe */
7026 { }
7027};
7028
7029static const struct alc_pincfg *alc882_pin_fixes[] = {
7030 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
7031};
7032
7033static struct snd_pci_quirk alc882_pinfix_tbl[] = {
7034 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
7035 {}
7036};
7037
7038/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007039 * BIOS auto configuration
7040 */
7041static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
7042 hda_nid_t nid, int pin_type,
7043 int dac_idx)
7044{
7045 /* set as output */
7046 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007047 int idx;
7048
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007049 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01007050 if (spec->multiout.dac_nids[dac_idx] == 0x25)
7051 idx = 4;
7052 else
7053 idx = spec->multiout.dac_nids[dac_idx] - 2;
Kailang Yangdf694da2005-12-05 19:42:22 +01007054 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
7055
7056}
7057
7058static void alc882_auto_init_multi_out(struct hda_codec *codec)
7059{
7060 struct alc_spec *spec = codec->spec;
7061 int i;
7062
7063 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007064 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007065 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01007066 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007067 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007068 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01007069 }
7070}
7071
7072static void alc882_auto_init_hp_out(struct hda_codec *codec)
7073{
7074 struct alc_spec *spec = codec->spec;
7075 hda_nid_t pin;
7076
Takashi Iwaieb06ed82006-09-20 17:10:27 +02007077 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007078 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007079 /* use dac 0 */
7080 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007081 pin = spec->autocfg.speaker_pins[0];
7082 if (pin)
7083 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01007084}
7085
7086#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
7087#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
7088
7089static void alc882_auto_init_analog_input(struct hda_codec *codec)
7090{
7091 struct alc_spec *spec = codec->spec;
7092 int i;
7093
7094 for (i = 0; i < AUTO_PIN_LAST; i++) {
7095 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai7194cae2008-03-06 16:58:17 +01007096 if (!nid)
7097 continue;
Takashi Iwai23f0c042009-02-26 13:03:58 +01007098 alc_set_input_pin(codec, nid, AUTO_PIN_FRONT_MIC /*i*/);
Takashi Iwai7194cae2008-03-06 16:58:17 +01007099 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
7100 snd_hda_codec_write(codec, nid, 0,
7101 AC_VERB_SET_AMP_GAIN_MUTE,
7102 AMP_OUT_MUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01007103 }
7104}
7105
Takashi Iwaif511b012008-08-15 16:46:42 +02007106static void alc882_auto_init_input_src(struct hda_codec *codec)
7107{
7108 struct alc_spec *spec = codec->spec;
Takashi Iwaif511b012008-08-15 16:46:42 +02007109 int c;
7110
7111 for (c = 0; c < spec->num_adc_nids; c++) {
7112 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
7113 hda_nid_t nid = spec->capsrc_nids[c];
Herton Ronaldo Krzesinskib98b7b32009-01-29 13:18:31 -02007114 unsigned int mux_idx;
7115 const struct hda_input_mux *imux;
Takashi Iwaif511b012008-08-15 16:46:42 +02007116 int conns, mute, idx, item;
7117
7118 conns = snd_hda_get_connections(codec, nid, conn_list,
7119 ARRAY_SIZE(conn_list));
7120 if (conns < 0)
7121 continue;
Herton Ronaldo Krzesinskib98b7b32009-01-29 13:18:31 -02007122 mux_idx = c >= spec->num_mux_defs ? 0 : c;
7123 imux = &spec->input_mux[mux_idx];
Takashi Iwaif511b012008-08-15 16:46:42 +02007124 for (idx = 0; idx < conns; idx++) {
7125 /* if the current connection is the selected one,
7126 * unmute it as default - otherwise mute it
7127 */
7128 mute = AMP_IN_MUTE(idx);
7129 for (item = 0; item < imux->num_items; item++) {
7130 if (imux->items[item].index == idx) {
7131 if (spec->cur_mux[c] == item)
7132 mute = AMP_IN_UNMUTE(idx);
7133 break;
7134 }
7135 }
Herton Ronaldo Krzesinskib98b7b32009-01-29 13:18:31 -02007136 /* check if we have a selector or mixer
7137 * we could check for the widget type instead, but
7138 * just check for Amp-In presence (in case of mixer
7139 * without amp-in there is something wrong, this
7140 * function shouldn't be used or capsrc nid is wrong)
7141 */
7142 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
7143 snd_hda_codec_write(codec, nid, 0,
7144 AC_VERB_SET_AMP_GAIN_MUTE,
7145 mute);
7146 else if (mute != AMP_IN_MUTE(idx))
7147 snd_hda_codec_write(codec, nid, 0,
7148 AC_VERB_SET_CONNECT_SEL,
7149 idx);
Takashi Iwaif511b012008-08-15 16:46:42 +02007150 }
7151 }
7152}
7153
Takashi Iwai776e1842007-08-29 15:07:11 +02007154/* add mic boosts if needed */
7155static int alc_auto_add_mic_boost(struct hda_codec *codec)
7156{
7157 struct alc_spec *spec = codec->spec;
7158 int err;
7159 hda_nid_t nid;
7160
7161 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01007162 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02007163 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7164 "Mic Boost",
7165 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
7166 if (err < 0)
7167 return err;
7168 }
7169 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01007170 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02007171 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7172 "Front Mic Boost",
7173 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
7174 if (err < 0)
7175 return err;
7176 }
7177 return 0;
7178}
7179
Kailang Yangdf694da2005-12-05 19:42:22 +01007180/* almost identical with ALC880 parser... */
7181static int alc882_parse_auto_config(struct hda_codec *codec)
7182{
7183 struct alc_spec *spec = codec->spec;
7184 int err = alc880_parse_auto_config(codec);
7185
7186 if (err < 0)
7187 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02007188 else if (!err)
7189 return 0; /* no config found */
7190
7191 err = alc_auto_add_mic_boost(codec);
7192 if (err < 0)
7193 return err;
7194
7195 /* hack - override the init verbs */
7196 spec->init_verbs[0] = alc882_auto_init_verbs;
7197
7198 return 1; /* config found */
Kailang Yangdf694da2005-12-05 19:42:22 +01007199}
7200
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007201/* additional initialization for auto-configuration model */
7202static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01007203{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007204 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007205 alc882_auto_init_multi_out(codec);
7206 alc882_auto_init_hp_out(codec);
7207 alc882_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02007208 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007209 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02007210 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01007211}
7212
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007213static int patch_alc883(struct hda_codec *codec); /* called in patch_alc882() */
7214
Linus Torvalds1da177e2005-04-16 15:20:36 -07007215static int patch_alc882(struct hda_codec *codec)
7216{
7217 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007218 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007219
Takashi Iwaie560d8d2005-09-09 14:21:46 +02007220 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007221 if (spec == NULL)
7222 return -ENOMEM;
7223
Linus Torvalds1da177e2005-04-16 15:20:36 -07007224 codec->spec = spec;
7225
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007226 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
7227 alc882_models,
7228 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007229
Kailang Yangdf694da2005-12-05 19:42:22 +01007230 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01007231 /* Pick up systems that don't supply PCI SSID */
7232 switch (codec->subsystem_id) {
7233 case 0x106b0c00: /* Mac Pro */
7234 board_config = ALC885_MACPRO;
7235 break;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007236 case 0x106b1000: /* iMac 24 */
Peter Korsgaardf3911c52008-09-27 09:13:45 +02007237 case 0x106b2800: /* AppleTV */
Mark Eggleston3077e442009-01-31 17:57:54 +01007238 case 0x106b3e00: /* iMac 24 Aluminium */
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007239 board_config = ALC885_IMAC24;
7240 break;
Luke Yelavich2d466382009-02-23 13:00:33 +11007241 case 0x106b00a0: /* MacBookPro3,1 - Another revision */
Takashi Iwaic7e07572008-06-26 14:42:51 +02007242 case 0x106b00a1: /* Macbook (might be wrong - PCI SSID?) */
David Woodhouse9c95c432008-09-18 13:37:13 -07007243 case 0x106b00a4: /* MacbookPro4,1 */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007244 case 0x106b2c00: /* Macbook Pro rev3 */
Takashi Iwaic7e07572008-06-26 14:42:51 +02007245 case 0x106b3600: /* Macbook 3.1 */
Luke Yelavich2a884642009-01-28 15:58:38 +11007246 case 0x106b3800: /* MacbookPro4,1 - latter revision */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007247 board_config = ALC885_MBP3;
7248 break;
Tobin Davis081d17c2007-02-15 17:46:18 +01007249 default:
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007250 /* ALC889A is handled better as ALC888-compatible */
Clive Messer669faba2008-09-30 15:49:13 +02007251 if (codec->revision_id == 0x100101 ||
7252 codec->revision_id == 0x100103) {
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007253 alc_free(codec);
7254 return patch_alc883(codec);
7255 }
Tobin Davis081d17c2007-02-15 17:46:18 +01007256 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
7257 "trying auto-probe from BIOS...\n");
7258 board_config = ALC882_AUTO;
7259 }
Kailang Yangdf694da2005-12-05 19:42:22 +01007260 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007261
Takashi Iwaif95474e2007-07-10 00:47:43 +02007262 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
7263
Kailang Yangdf694da2005-12-05 19:42:22 +01007264 if (board_config == ALC882_AUTO) {
7265 /* automatic parse from the BIOS config */
7266 err = alc882_parse_auto_config(codec);
7267 if (err < 0) {
7268 alc_free(codec);
7269 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007270 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007271 printk(KERN_INFO
7272 "hda_codec: Cannot set up configuration "
7273 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007274 board_config = ALC882_3ST_DIG;
7275 }
7276 }
7277
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09007278 err = snd_hda_attach_beep_device(codec, 0x1);
7279 if (err < 0) {
7280 alc_free(codec);
7281 return err;
7282 }
7283
Kailang Yangdf694da2005-12-05 19:42:22 +01007284 if (board_config != ALC882_AUTO)
7285 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007286
Kailang Yang2f893282008-05-27 12:14:47 +02007287 if (codec->vendor_id == 0x10ec0885) {
7288 spec->stream_name_analog = "ALC885 Analog";
7289 spec->stream_name_digital = "ALC885 Digital";
7290 } else {
7291 spec->stream_name_analog = "ALC882 Analog";
7292 spec->stream_name_digital = "ALC882 Digital";
7293 }
7294
Kailang Yangdf694da2005-12-05 19:42:22 +01007295 spec->stream_analog_playback = &alc882_pcm_analog_playback;
7296 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01007297 /* FIXME: setup DAC5 */
7298 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
7299 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007300
Kailang Yangdf694da2005-12-05 19:42:22 +01007301 spec->stream_digital_playback = &alc882_pcm_digital_playback;
7302 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007303
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007304 spec->capture_style = CAPT_MIX; /* matrix-style capture */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007305 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01007306 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01007307 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007308 /* get type */
7309 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01007310 if (wcap != AC_WID_AUD_IN) {
7311 spec->adc_nids = alc882_adc_nids_alt;
7312 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
Takashi Iwaie1406342008-02-11 18:32:32 +01007313 spec->capsrc_nids = alc882_capsrc_nids_alt;
Kailang Yangdf694da2005-12-05 19:42:22 +01007314 } else {
7315 spec->adc_nids = alc882_adc_nids;
7316 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +01007317 spec->capsrc_nids = alc882_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +01007318 }
7319 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007320 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007321 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007322
Takashi Iwai2134ea42008-01-10 16:53:55 +01007323 spec->vmaster_nid = 0x0c;
7324
Linus Torvalds1da177e2005-04-16 15:20:36 -07007325 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01007326 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007327 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02007328#ifdef CONFIG_SND_HDA_POWER_SAVE
7329 if (!spec->loopback.amplist)
7330 spec->loopback.amplist = alc882_loopbacks;
7331#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01007332 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007333
7334 return 0;
7335}
7336
7337/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007338 * ALC883 support
7339 *
7340 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
7341 * configuration. Each pin widget can choose any input DACs and a mixer.
7342 * Each ADC is connected from a mixer of all inputs. This makes possible
7343 * 6-channel independent captures.
7344 *
7345 * In addition, an independent DAC for the multi-playback (not used in this
7346 * driver yet).
7347 */
7348#define ALC883_DIGOUT_NID 0x06
7349#define ALC883_DIGIN_NID 0x0a
7350
Wu Fengguang3ab90932008-11-17 09:51:09 +01007351#define ALC1200_DIGOUT_NID 0x10
7352
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007353static hda_nid_t alc883_dac_nids[4] = {
7354 /* front, rear, clfe, rear_surr */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01007355 0x02, 0x03, 0x04, 0x05
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007356};
7357
7358static hda_nid_t alc883_adc_nids[2] = {
7359 /* ADC1-2 */
7360 0x08, 0x09,
7361};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007362
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007363static hda_nid_t alc883_adc_nids_alt[1] = {
7364 /* ADC1 */
7365 0x08,
7366};
7367
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08007368static hda_nid_t alc883_adc_nids_rev[2] = {
7369 /* ADC2-1 */
7370 0x09, 0x08
7371};
7372
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007373#define alc889_adc_nids alc880_adc_nids
7374
Takashi Iwaie1406342008-02-11 18:32:32 +01007375static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 };
7376
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08007377static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
7378
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007379#define alc889_capsrc_nids alc882_capsrc_nids
7380
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007381/* input MUX */
7382/* FIXME: should be a matrix-type input source selection */
7383
7384static struct hda_input_mux alc883_capture_source = {
7385 .num_items = 4,
7386 .items = {
7387 { "Mic", 0x0 },
7388 { "Front Mic", 0x1 },
7389 { "Line", 0x2 },
7390 { "CD", 0x4 },
7391 },
7392};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007393
Jiang zhe17bba1b2008-06-04 12:11:07 +02007394static struct hda_input_mux alc883_3stack_6ch_intel = {
7395 .num_items = 4,
7396 .items = {
7397 { "Mic", 0x1 },
7398 { "Front Mic", 0x0 },
7399 { "Line", 0x2 },
7400 { "CD", 0x4 },
7401 },
7402};
7403
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007404static struct hda_input_mux alc883_lenovo_101e_capture_source = {
7405 .num_items = 2,
7406 .items = {
7407 { "Mic", 0x1 },
7408 { "Line", 0x2 },
7409 },
7410};
7411
Kailang Yang272a5272007-05-14 11:00:38 +02007412static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
7413 .num_items = 4,
7414 .items = {
7415 { "Mic", 0x0 },
7416 { "iMic", 0x1 },
7417 { "Line", 0x2 },
7418 { "CD", 0x4 },
7419 },
7420};
7421
Jiang zhefb97dc62008-03-06 11:07:11 +01007422static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
7423 .num_items = 2,
7424 .items = {
7425 { "Mic", 0x0 },
7426 { "Int Mic", 0x1 },
7427 },
7428};
7429
Kailang Yange2757d52008-08-26 13:17:46 +02007430static struct hda_input_mux alc883_lenovo_sky_capture_source = {
7431 .num_items = 3,
7432 .items = {
7433 { "Mic", 0x0 },
7434 { "Front Mic", 0x1 },
7435 { "Line", 0x4 },
7436 },
7437};
7438
7439static struct hda_input_mux alc883_asus_eee1601_capture_source = {
7440 .num_items = 2,
7441 .items = {
7442 { "Mic", 0x0 },
7443 { "Line", 0x2 },
7444 },
7445};
7446
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007447/*
7448 * 2ch mode
7449 */
7450static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
7451 { 2, NULL }
7452};
7453
7454/*
7455 * 2ch mode
7456 */
7457static struct hda_verb alc883_3ST_ch2_init[] = {
7458 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7459 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7460 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7461 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7462 { } /* end */
7463};
7464
7465/*
Tobin Davisb2011312007-09-17 12:45:11 +02007466 * 4ch mode
7467 */
7468static struct hda_verb alc883_3ST_ch4_init[] = {
7469 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7470 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7471 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7472 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7473 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7474 { } /* end */
7475};
7476
7477/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007478 * 6ch mode
7479 */
7480static struct hda_verb alc883_3ST_ch6_init[] = {
7481 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7482 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7483 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7484 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7485 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7486 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7487 { } /* end */
7488};
7489
Tobin Davisb2011312007-09-17 12:45:11 +02007490static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007491 { 2, alc883_3ST_ch2_init },
Tobin Davisb2011312007-09-17 12:45:11 +02007492 { 4, alc883_3ST_ch4_init },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007493 { 6, alc883_3ST_ch6_init },
7494};
7495
7496/*
Jiang zhe17bba1b2008-06-04 12:11:07 +02007497 * 2ch mode
7498 */
7499static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7500 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7501 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7502 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7503 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7504 { } /* end */
7505};
7506
7507/*
7508 * 4ch mode
7509 */
7510static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7511 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7512 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7513 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7514 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7515 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7516 { } /* end */
7517};
7518
7519/*
7520 * 6ch mode
7521 */
7522static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7523 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7524 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7525 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7526 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7527 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7528 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7529 { } /* end */
7530};
7531
7532static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7533 { 2, alc883_3ST_ch2_intel_init },
7534 { 4, alc883_3ST_ch4_intel_init },
7535 { 6, alc883_3ST_ch6_intel_init },
7536};
7537
7538/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007539 * 6ch mode
7540 */
7541static struct hda_verb alc883_sixstack_ch6_init[] = {
7542 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7543 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7544 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7545 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7546 { } /* end */
7547};
7548
7549/*
7550 * 8ch mode
7551 */
7552static struct hda_verb alc883_sixstack_ch8_init[] = {
7553 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7554 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7555 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7556 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7557 { } /* end */
7558};
7559
7560static struct hda_channel_mode alc883_sixstack_modes[2] = {
7561 { 6, alc883_sixstack_ch6_init },
7562 { 8, alc883_sixstack_ch8_init },
7563};
7564
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007565static struct hda_verb alc883_medion_eapd_verbs[] = {
7566 /* eanable EAPD on medion laptop */
7567 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7568 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7569 { }
7570};
7571
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007572/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7573 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7574 */
7575
7576static struct snd_kcontrol_new alc883_base_mixer[] = {
7577 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7578 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7579 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7580 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7581 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7582 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7583 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7584 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7585 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7586 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7587 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7588 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7589 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7590 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7591 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7592 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007593 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007594 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7595 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007596 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007597 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007598 { } /* end */
7599};
7600
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007601static struct snd_kcontrol_new alc883_mitac_mixer[] = {
7602 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7603 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7604 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7605 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7606 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7607 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7608 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7609 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7610 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7611 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7612 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7613 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7614 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007615 { } /* end */
7616};
7617
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007618static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007619 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7620 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7621 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7622 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7623 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7624 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7625 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7626 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7627 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7628 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01007629 { } /* end */
7630};
7631
Jiang zhefb97dc62008-03-06 11:07:11 +01007632static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
7633 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7634 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7635 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7636 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7637 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7638 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7639 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7640 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7641 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7642 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01007643 { } /* end */
7644};
7645
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007646static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
7647 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7648 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7649 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7650 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7651 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7652 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7653 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7654 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007655 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007656 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7657 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007658 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007659 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007660 { } /* end */
7661};
7662
7663static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
7664 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7665 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7666 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7667 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7668 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7669 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7670 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7671 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7672 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7673 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7674 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7675 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7676 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7677 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007678 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007679 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7680 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007681 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007682 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007683 { } /* end */
7684};
7685
Jiang zhe17bba1b2008-06-04 12:11:07 +02007686static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
7687 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7688 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7689 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7690 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7691 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7692 HDA_OUTPUT),
7693 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7694 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7695 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7696 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7697 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7698 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7699 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7700 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7701 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7702 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
7703 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7704 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7705 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7706 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02007707 { } /* end */
7708};
7709
Takashi Iwaid1d985f2006-11-23 19:27:12 +01007710static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02007711 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007712 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007713 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007714 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007715 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7716 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007717 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7718 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007719 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7720 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7721 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7722 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7723 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7724 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007725 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007726 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7727 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007728 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007729 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007730 { } /* end */
7731};
7732
Kailang Yangccc656c2006-10-17 12:32:26 +02007733static struct snd_kcontrol_new alc883_tagra_mixer[] = {
7734 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7735 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7736 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7737 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7738 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7739 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7740 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7741 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7742 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7743 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7744 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7745 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7746 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7747 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007748 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007749 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007750 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007751};
Kailang Yangccc656c2006-10-17 12:32:26 +02007752
7753static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
7754 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7755 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7756 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7757 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7758 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7759 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007760 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007761 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02007762 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7763 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7764 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007765 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007766};
Kailang Yangccc656c2006-10-17 12:32:26 +02007767
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007768static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
7769 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7770 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01007771 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7772 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007773 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7774 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7775 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7776 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007777 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007778};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007779
Kailang Yang272a5272007-05-14 11:00:38 +02007780static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
7781 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7782 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
7783 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7784 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7785 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7786 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7787 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7788 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7789 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007790 { } /* end */
7791};
7792
7793static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
7794 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7795 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7796 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7797 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7798 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7799 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7800 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7801 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7802 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007803 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02007804};
Kailang Yang272a5272007-05-14 11:00:38 +02007805
Tobin Davis2880a862007-08-07 11:50:26 +02007806static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02007807 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7808 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007809 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007810 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7811 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02007812 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7813 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7814 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007815 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02007816};
Tobin Davis2880a862007-08-07 11:50:26 +02007817
Kailang Yange2757d52008-08-26 13:17:46 +02007818static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
7819 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7820 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7821 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
7822 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
7823 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
7824 0x0d, 1, 0x0, HDA_OUTPUT),
7825 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
7826 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
7827 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
7828 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7829 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7830 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7831 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
7832 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7833 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7834 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7835 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7836 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7837 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7838 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7839 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7840 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7841 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02007842 { } /* end */
7843};
7844
7845static struct hda_bind_ctls alc883_bind_cap_vol = {
7846 .ops = &snd_hda_bind_vol,
7847 .values = {
7848 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
7849 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7850 0
7851 },
7852};
7853
7854static struct hda_bind_ctls alc883_bind_cap_switch = {
7855 .ops = &snd_hda_bind_sw,
7856 .values = {
7857 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
7858 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7859 0
7860 },
7861};
7862
7863static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
7864 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7865 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7866 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7867 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7868 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7869 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7870 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7871 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007872 { } /* end */
7873};
7874
7875static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02007876 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
7877 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
7878 {
7879 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7880 /* .name = "Capture Source", */
7881 .name = "Input Source",
7882 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01007883 .info = alc_mux_enum_info,
7884 .get = alc_mux_enum_get,
7885 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02007886 },
7887 { } /* end */
7888};
7889
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007890static struct snd_kcontrol_new alc883_chmode_mixer[] = {
7891 {
7892 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7893 .name = "Channel Mode",
7894 .info = alc_ch_mode_info,
7895 .get = alc_ch_mode_get,
7896 .put = alc_ch_mode_put,
7897 },
7898 { } /* end */
7899};
7900
7901static struct hda_verb alc883_init_verbs[] = {
7902 /* ADC1: mute amp left and right */
Kailang Yange2757d52008-08-26 13:17:46 +02007903 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007904 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7905 /* ADC2: mute amp left and right */
7906 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7907 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7908 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7909 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7910 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7911 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7912 /* Rear mixer */
7913 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7914 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7915 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7916 /* CLFE mixer */
7917 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7918 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7919 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7920 /* Side mixer */
7921 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7922 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7923 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7924
Takashi Iwaicb53c622007-08-10 17:21:45 +02007925 /* mute analog input loopbacks */
7926 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7927 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7928 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7929 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7930 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007931
7932 /* Front Pin: output 0 (0x0c) */
7933 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7934 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7935 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7936 /* Rear Pin: output 1 (0x0d) */
7937 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7938 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7939 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7940 /* CLFE Pin: output 2 (0x0e) */
7941 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7942 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7943 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7944 /* Side Pin: output 3 (0x0f) */
7945 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7946 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7947 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7948 /* Mic (rear) pin: input vref at 80% */
7949 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7950 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7951 /* Front Mic pin: input vref at 80% */
7952 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7953 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7954 /* Line In pin: input */
7955 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7956 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7957 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7958 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7959 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7960 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7961 /* CD pin widget for input */
7962 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7963
7964 /* FIXME: use matrix-type input source selection */
7965 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7966 /* Input mixer2 */
7967 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yange2757d52008-08-26 13:17:46 +02007968 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7969 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7970 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007971 /* Input mixer3 */
7972 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yange2757d52008-08-26 13:17:46 +02007973 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7974 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7975 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007976 { }
7977};
7978
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007979/* toggle speaker-output according to the hp-jack state */
7980static void alc883_mitac_hp_automute(struct hda_codec *codec)
7981{
7982 unsigned int present;
7983
7984 present = snd_hda_codec_read(codec, 0x15, 0,
7985 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7986 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7987 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7988 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7989 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7990}
7991
7992/* auto-toggle front mic */
7993/*
7994static void alc883_mitac_mic_automute(struct hda_codec *codec)
7995{
7996 unsigned int present;
7997 unsigned char bits;
7998
7999 present = snd_hda_codec_read(codec, 0x18, 0,
8000 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8001 bits = present ? HDA_AMP_MUTE : 0;
8002 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
8003}
8004*/
8005
8006static void alc883_mitac_automute(struct hda_codec *codec)
8007{
8008 alc883_mitac_hp_automute(codec);
8009 /* alc883_mitac_mic_automute(codec); */
8010}
8011
8012static void alc883_mitac_unsol_event(struct hda_codec *codec,
8013 unsigned int res)
8014{
8015 switch (res >> 26) {
8016 case ALC880_HP_EVENT:
8017 alc883_mitac_hp_automute(codec);
8018 break;
8019 case ALC880_MIC_EVENT:
8020 /* alc883_mitac_mic_automute(codec); */
8021 break;
8022 }
8023}
8024
8025static struct hda_verb alc883_mitac_verbs[] = {
8026 /* HP */
8027 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8028 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8029 /* Subwoofer */
8030 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8031 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8032
8033 /* enable unsolicited event */
8034 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8035 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
8036
8037 { } /* end */
8038};
8039
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008040static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008041 /* HP */
8042 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8043 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8044 /* Int speaker */
8045 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
8046 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8047
8048 /* enable unsolicited event */
8049 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008050 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01008051
8052 { } /* end */
8053};
8054
Jiang zhefb97dc62008-03-06 11:07:11 +01008055static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
8056 /* HP */
8057 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8058 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8059 /* Subwoofer */
8060 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8061 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8062
8063 /* enable unsolicited event */
8064 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8065
8066 { } /* end */
8067};
8068
Kailang Yangccc656c2006-10-17 12:32:26 +02008069static struct hda_verb alc883_tagra_verbs[] = {
8070 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8071 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8072
8073 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8074 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008075
Kailang Yangccc656c2006-10-17 12:32:26 +02008076 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8077 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8078 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8079
8080 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008081 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
8082 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
8083 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
Kailang Yangccc656c2006-10-17 12:32:26 +02008084
8085 { } /* end */
8086};
8087
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008088static struct hda_verb alc883_lenovo_101e_verbs[] = {
8089 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8090 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
8091 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
8092 { } /* end */
8093};
8094
Kailang Yang272a5272007-05-14 11:00:38 +02008095static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
8096 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8097 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8098 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8099 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8100 { } /* end */
8101};
8102
8103static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
8104 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8105 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8106 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8107 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
8108 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8109 { } /* end */
8110};
8111
Kailang Yang189609a2007-08-20 11:31:23 +02008112static struct hda_verb alc883_haier_w66_verbs[] = {
8113 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8114 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8115
8116 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8117
8118 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8119 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8120 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8121 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8122 { } /* end */
8123};
8124
Kailang Yange2757d52008-08-26 13:17:46 +02008125static struct hda_verb alc888_lenovo_sky_verbs[] = {
8126 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8127 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8128 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8129 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8130 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8131 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8132 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8133 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8134 { } /* end */
8135};
8136
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008137static struct hda_verb alc888_6st_dell_verbs[] = {
8138 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8139 { }
8140};
8141
8142static void alc888_3st_hp_front_automute(struct hda_codec *codec)
8143{
8144 unsigned int present, bits;
8145
8146 present = snd_hda_codec_read(codec, 0x1b, 0,
8147 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8148 bits = present ? HDA_AMP_MUTE : 0;
8149 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8150 HDA_AMP_MUTE, bits);
8151 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8152 HDA_AMP_MUTE, bits);
8153 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
8154 HDA_AMP_MUTE, bits);
8155}
8156
8157static void alc888_3st_hp_unsol_event(struct hda_codec *codec,
8158 unsigned int res)
8159{
8160 switch (res >> 26) {
8161 case ALC880_HP_EVENT:
8162 alc888_3st_hp_front_automute(codec);
8163 break;
8164 }
8165}
8166
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008167static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008168 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01008169 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
8170 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008171 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008172 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008173};
8174
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008175/*
8176 * 2ch mode
8177 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008178static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008179 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8180 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8181 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
8182 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008183 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008184};
8185
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008186/*
8187 * 4ch mode
8188 */
8189static struct hda_verb alc888_3st_hp_4ch_init[] = {
8190 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8191 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8192 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8193 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8194 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8195 { } /* end */
8196};
8197
8198/*
8199 * 6ch mode
8200 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008201static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008202 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8203 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008204 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008205 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8206 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008207 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8208 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008209};
8210
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008211static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008212 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008213 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008214 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008215};
8216
Kailang Yang272a5272007-05-14 11:00:38 +02008217/* toggle front-jack and RCA according to the hp-jack state */
8218static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
8219{
8220 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008221
Kailang Yang272a5272007-05-14 11:00:38 +02008222 present = snd_hda_codec_read(codec, 0x1b, 0,
8223 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008224 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8225 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8226 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8227 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008228}
8229
8230/* toggle RCA according to the front-jack state */
8231static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
8232{
8233 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008234
Kailang Yang272a5272007-05-14 11:00:38 +02008235 present = snd_hda_codec_read(codec, 0x14, 0,
8236 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008237 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8238 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008239}
Takashi Iwai47fd8302007-08-10 17:11:07 +02008240
Kailang Yang272a5272007-05-14 11:00:38 +02008241static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
8242 unsigned int res)
8243{
8244 if ((res >> 26) == ALC880_HP_EVENT)
8245 alc888_lenovo_ms7195_front_automute(codec);
8246 if ((res >> 26) == ALC880_FRONT_EVENT)
8247 alc888_lenovo_ms7195_rca_automute(codec);
8248}
8249
8250static struct hda_verb alc883_medion_md2_verbs[] = {
8251 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8252 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8253
8254 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8255
8256 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8257 { } /* end */
8258};
8259
8260/* toggle speaker-output according to the hp-jack state */
8261static void alc883_medion_md2_automute(struct hda_codec *codec)
8262{
8263 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008264
Kailang Yang272a5272007-05-14 11:00:38 +02008265 present = snd_hda_codec_read(codec, 0x14, 0,
8266 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008267 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8268 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008269}
8270
8271static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
8272 unsigned int res)
8273{
8274 if ((res >> 26) == ALC880_HP_EVENT)
8275 alc883_medion_md2_automute(codec);
8276}
8277
Kailang Yangccc656c2006-10-17 12:32:26 +02008278/* toggle speaker-output according to the hp-jack state */
8279static void alc883_tagra_automute(struct hda_codec *codec)
8280{
8281 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008282 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02008283
8284 present = snd_hda_codec_read(codec, 0x14, 0,
8285 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008286 bits = present ? HDA_AMP_MUTE : 0;
8287 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
8288 HDA_AMP_MUTE, bits);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008289 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
8290 present ? 1 : 3);
Kailang Yangccc656c2006-10-17 12:32:26 +02008291}
8292
8293static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
8294{
8295 if ((res >> 26) == ALC880_HP_EVENT)
8296 alc883_tagra_automute(codec);
8297}
8298
Jiang zhe368c7a92008-03-04 11:20:33 +01008299/* toggle speaker-output according to the hp-jack state */
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008300static void alc883_clevo_m720_hp_automute(struct hda_codec *codec)
Jiang zhe368c7a92008-03-04 11:20:33 +01008301{
8302 unsigned int present;
8303 unsigned char bits;
8304
8305 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
8306 & AC_PINSENSE_PRESENCE;
8307 bits = present ? HDA_AMP_MUTE : 0;
8308 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8309 HDA_AMP_MUTE, bits);
8310}
8311
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008312static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
8313{
8314 unsigned int present;
8315
8316 present = snd_hda_codec_read(codec, 0x18, 0,
8317 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8318 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
8319 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8320}
8321
8322static void alc883_clevo_m720_automute(struct hda_codec *codec)
8323{
8324 alc883_clevo_m720_hp_automute(codec);
8325 alc883_clevo_m720_mic_automute(codec);
8326}
8327
8328static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01008329 unsigned int res)
8330{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008331 switch (res >> 26) {
8332 case ALC880_HP_EVENT:
8333 alc883_clevo_m720_hp_automute(codec);
8334 break;
8335 case ALC880_MIC_EVENT:
8336 alc883_clevo_m720_mic_automute(codec);
8337 break;
8338 }
Jiang zhe368c7a92008-03-04 11:20:33 +01008339}
8340
Jiang zhefb97dc62008-03-06 11:07:11 +01008341/* toggle speaker-output according to the hp-jack state */
8342static void alc883_2ch_fujitsu_pi2515_automute(struct hda_codec *codec)
8343{
8344 unsigned int present;
8345 unsigned char bits;
8346
8347 present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0)
8348 & AC_PINSENSE_PRESENCE;
8349 bits = present ? HDA_AMP_MUTE : 0;
8350 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8351 HDA_AMP_MUTE, bits);
8352}
8353
8354static void alc883_2ch_fujitsu_pi2515_unsol_event(struct hda_codec *codec,
8355 unsigned int res)
8356{
8357 if ((res >> 26) == ALC880_HP_EVENT)
8358 alc883_2ch_fujitsu_pi2515_automute(codec);
8359}
8360
Kailang Yang189609a2007-08-20 11:31:23 +02008361static void alc883_haier_w66_automute(struct hda_codec *codec)
8362{
8363 unsigned int present;
8364 unsigned char bits;
8365
8366 present = snd_hda_codec_read(codec, 0x1b, 0,
8367 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8368 bits = present ? 0x80 : 0;
8369 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8370 0x80, bits);
8371}
8372
8373static void alc883_haier_w66_unsol_event(struct hda_codec *codec,
8374 unsigned int res)
8375{
8376 if ((res >> 26) == ALC880_HP_EVENT)
8377 alc883_haier_w66_automute(codec);
8378}
8379
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008380static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
8381{
8382 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008383 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008384
8385 present = snd_hda_codec_read(codec, 0x14, 0,
8386 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008387 bits = present ? HDA_AMP_MUTE : 0;
8388 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8389 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008390}
8391
8392static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
8393{
8394 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008395 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008396
8397 present = snd_hda_codec_read(codec, 0x1b, 0,
8398 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008399 bits = present ? HDA_AMP_MUTE : 0;
8400 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8401 HDA_AMP_MUTE, bits);
8402 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8403 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008404}
8405
8406static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
8407 unsigned int res)
8408{
8409 if ((res >> 26) == ALC880_HP_EVENT)
8410 alc883_lenovo_101e_all_automute(codec);
8411 if ((res >> 26) == ALC880_FRONT_EVENT)
8412 alc883_lenovo_101e_ispeaker_automute(codec);
8413}
8414
Takashi Iwai676a9b52007-08-16 15:23:35 +02008415/* toggle speaker-output according to the hp-jack state */
8416static void alc883_acer_aspire_automute(struct hda_codec *codec)
8417{
8418 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008419
Takashi Iwai676a9b52007-08-16 15:23:35 +02008420 present = snd_hda_codec_read(codec, 0x14, 0,
8421 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8422 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8423 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8424 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8425 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8426}
8427
8428static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
8429 unsigned int res)
8430{
8431 if ((res >> 26) == ALC880_HP_EVENT)
8432 alc883_acer_aspire_automute(codec);
8433}
8434
Kailang Yangd1a991a2007-08-15 16:21:59 +02008435static struct hda_verb alc883_acer_eapd_verbs[] = {
8436 /* HP Pin: output 0 (0x0c) */
8437 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8438 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8439 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8440 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02008441 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8442 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008443 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008444 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
8445 /* eanable EAPD on medion laptop */
8446 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8447 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02008448 /* enable unsolicited event */
8449 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008450 { }
8451};
8452
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008453static void alc888_6st_dell_front_automute(struct hda_codec *codec)
8454{
8455 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008456
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008457 present = snd_hda_codec_read(codec, 0x1b, 0,
8458 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8459 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8460 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8461 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8462 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8463 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8464 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8465 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
8466 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8467}
8468
8469static void alc888_6st_dell_unsol_event(struct hda_codec *codec,
8470 unsigned int res)
8471{
8472 switch (res >> 26) {
8473 case ALC880_HP_EVENT:
Takashi Iwai939778a2009-02-05 15:57:55 +01008474 /* printk(KERN_DEBUG "hp_event\n"); */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008475 alc888_6st_dell_front_automute(codec);
8476 break;
8477 }
8478}
8479
Kailang Yange2757d52008-08-26 13:17:46 +02008480static void alc888_lenovo_sky_front_automute(struct hda_codec *codec)
8481{
8482 unsigned int mute;
8483 unsigned int present;
8484
8485 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
8486 present = snd_hda_codec_read(codec, 0x1b, 0,
8487 AC_VERB_GET_PIN_SENSE, 0);
8488 present = (present & 0x80000000) != 0;
8489 if (present) {
8490 /* mute internal speaker */
8491 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8492 HDA_AMP_MUTE, HDA_AMP_MUTE);
8493 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8494 HDA_AMP_MUTE, HDA_AMP_MUTE);
8495 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8496 HDA_AMP_MUTE, HDA_AMP_MUTE);
8497 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
8498 HDA_AMP_MUTE, HDA_AMP_MUTE);
8499 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
8500 HDA_AMP_MUTE, HDA_AMP_MUTE);
8501 } else {
8502 /* unmute internal speaker if necessary */
8503 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
8504 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8505 HDA_AMP_MUTE, mute);
8506 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8507 HDA_AMP_MUTE, mute);
8508 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8509 HDA_AMP_MUTE, mute);
8510 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
8511 HDA_AMP_MUTE, mute);
8512 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
8513 HDA_AMP_MUTE, mute);
8514 }
8515}
8516
8517static void alc883_lenovo_sky_unsol_event(struct hda_codec *codec,
8518 unsigned int res)
8519{
8520 if ((res >> 26) == ALC880_HP_EVENT)
8521 alc888_lenovo_sky_front_automute(codec);
8522}
8523
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008524/*
8525 * generic initialization of ADC, input mixers and output mixers
8526 */
8527static struct hda_verb alc883_auto_init_verbs[] = {
8528 /*
8529 * Unmute ADC0-2 and set the default input to mic-in
8530 */
8531 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8532 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8533 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8534 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8535
Takashi Iwaicb53c622007-08-10 17:21:45 +02008536 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008537 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008538 * Note: PASD motherboards uses the Line In 2 as the input for
8539 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008540 */
8541 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008542 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8543 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8544 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8545 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8546 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008547
8548 /*
8549 * Set up output mixers (0x0c - 0x0f)
8550 */
8551 /* set vol=0 to output mixers */
8552 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8553 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8554 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8555 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8556 /* set up input amps for analog loopback */
8557 /* Amp Indices: DAC = 0, mixer = 1 */
8558 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8559 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8560 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8561 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8562 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8563 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8564 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8565 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8566 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8567 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8568
8569 /* FIXME: use matrix-type input source selection */
8570 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8571 /* Input mixer1 */
8572 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8573 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8574 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008575 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008576 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
8577 /* Input mixer2 */
8578 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8579 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8580 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008581 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Andy Shevchenkoe3cde642007-12-03 16:50:58 +01008582 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008583
8584 { }
8585};
8586
Kailang Yange2757d52008-08-26 13:17:46 +02008587static struct hda_verb alc888_asus_m90v_verbs[] = {
8588 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8589 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8590 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8591 /* enable unsolicited event */
8592 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8593 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8594 { } /* end */
8595};
8596
8597static void alc883_nb_mic_automute(struct hda_codec *codec)
8598{
8599 unsigned int present;
8600
8601 present = snd_hda_codec_read(codec, 0x18, 0,
8602 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8603 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8604 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
8605 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8606 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
8607}
8608
8609static void alc883_M90V_speaker_automute(struct hda_codec *codec)
8610{
8611 unsigned int present;
8612 unsigned char bits;
8613
8614 present = snd_hda_codec_read(codec, 0x1b, 0,
8615 AC_VERB_GET_PIN_SENSE, 0)
8616 & AC_PINSENSE_PRESENCE;
8617 bits = present ? 0 : PIN_OUT;
8618 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8619 bits);
8620 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8621 bits);
8622 snd_hda_codec_write(codec, 0x16, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8623 bits);
8624}
8625
8626static void alc883_mode2_unsol_event(struct hda_codec *codec,
8627 unsigned int res)
8628{
8629 switch (res >> 26) {
8630 case ALC880_HP_EVENT:
8631 alc883_M90V_speaker_automute(codec);
8632 break;
8633 case ALC880_MIC_EVENT:
8634 alc883_nb_mic_automute(codec);
8635 break;
8636 }
8637}
8638
8639static void alc883_mode2_inithook(struct hda_codec *codec)
8640{
8641 alc883_M90V_speaker_automute(codec);
8642 alc883_nb_mic_automute(codec);
8643}
8644
8645static struct hda_verb alc888_asus_eee1601_verbs[] = {
8646 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8647 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8648 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8649 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8650 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8651 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
8652 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
8653 /* enable unsolicited event */
8654 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8655 { } /* end */
8656};
8657
8658static void alc883_eee1601_speaker_automute(struct hda_codec *codec)
8659{
8660 unsigned int present;
8661 unsigned char bits;
8662
8663 present = snd_hda_codec_read(codec, 0x14, 0,
8664 AC_VERB_GET_PIN_SENSE, 0)
8665 & AC_PINSENSE_PRESENCE;
8666 bits = present ? 0 : PIN_OUT;
8667 snd_hda_codec_write(codec, 0x1b, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8668 bits);
8669}
8670
8671static void alc883_eee1601_unsol_event(struct hda_codec *codec,
8672 unsigned int res)
8673{
8674 switch (res >> 26) {
8675 case ALC880_HP_EVENT:
8676 alc883_eee1601_speaker_automute(codec);
8677 break;
8678 }
8679}
8680
8681static void alc883_eee1601_inithook(struct hda_codec *codec)
8682{
8683 alc883_eee1601_speaker_automute(codec);
8684}
8685
Takashi Iwaicb53c622007-08-10 17:21:45 +02008686#ifdef CONFIG_SND_HDA_POWER_SAVE
8687#define alc883_loopbacks alc880_loopbacks
8688#endif
8689
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008690/* pcm configuration: identiacal with ALC880 */
8691#define alc883_pcm_analog_playback alc880_pcm_analog_playback
8692#define alc883_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +01008693#define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008694#define alc883_pcm_digital_playback alc880_pcm_digital_playback
8695#define alc883_pcm_digital_capture alc880_pcm_digital_capture
8696
8697/*
8698 * configuration and preset
8699 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008700static const char *alc883_models[ALC883_MODEL_LAST] = {
8701 [ALC883_3ST_2ch_DIG] = "3stack-dig",
8702 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
8703 [ALC883_3ST_6ch] = "3stack-6ch",
8704 [ALC883_6ST_DIG] = "6stack-dig",
8705 [ALC883_TARGA_DIG] = "targa-dig",
8706 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008707 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02008708 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008709 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008710 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02008711 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008712 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008713 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02008714 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
8715 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02008716 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02008717 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008718 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008719 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008720 [ALC883_MITAC] = "mitac",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008721 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01008722 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008723 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02008724 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Wu Fengguang3ab90932008-11-17 09:51:09 +01008725 [ALC1200_ASUS_P5Q] = "asus-p5q",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008726 [ALC883_AUTO] = "auto",
8727};
8728
8729static struct snd_pci_quirk alc883_cfg_tbl[] = {
8730 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008731 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01008732 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01008733 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008734 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
8735 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02008736 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008737 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
8738 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008739 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
8740 ALC888_ACER_ASPIRE_4930G),
Takashi Iwaib3bdb302009-02-18 13:16:26 +01008741 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC883_AUTO),
Takashi Iwai94683502009-02-13 09:31:20 +01008742 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC883_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008743 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
8744 ALC888_ACER_ASPIRE_4930G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01008745 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
8746 ALC888_ACER_ASPIRE_4930G),
Takashi Iwaidea0a502009-02-09 17:14:52 +01008747 /* default Acer */
8748 SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER),
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008749 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Tobin Davisfebe3372007-06-12 11:27:46 +02008750 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008751 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
8752 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01008753 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01008754 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03008755 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Kailang Yanga01c30c2008-10-15 11:14:58 +02008756 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008757 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01008758 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01008759 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02008760 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Travis Place97ec7102008-05-23 18:31:46 +02008761 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008762 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008763 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008764 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
8765 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02008766 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008767 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Tobin Davis57b14f22007-04-18 23:05:36 +02008768 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008769 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
8770 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
8771 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Jiang zhe4383fae2008-04-14 12:58:57 +02008772 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008773 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01008774 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008775 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
8776 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
8777 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
8778 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
8779 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
8780 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
8781 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
8782 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
8783 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008784 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
8785 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02008786 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01008787 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01008788 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01008789 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02008790 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008791 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008792 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008793 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
8794 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
Takashi Iwaidea0a502009-02-09 17:14:52 +01008795 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04008796 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008797 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02008798 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01008799 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02008800 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008801 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02008802 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02008803 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008804 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
8805 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02008806 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02008807 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01008808 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01008809 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02008810 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008811 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
8812 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008813 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Wu Fengguang4b558992009-01-12 09:18:58 +08008814 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC883_3ST_6ch_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008815 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008816 {}
8817};
8818
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08008819static hda_nid_t alc883_slave_dig_outs[] = {
8820 ALC1200_DIGOUT_NID, 0,
8821};
8822
Wu Fengguangb25c9da2009-02-06 15:02:27 +08008823static hda_nid_t alc1200_slave_dig_outs[] = {
8824 ALC883_DIGOUT_NID, 0,
8825};
8826
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008827static struct alc_config_preset alc883_presets[] = {
8828 [ALC883_3ST_2ch_DIG] = {
8829 .mixers = { alc883_3ST_2ch_mixer },
8830 .init_verbs = { alc883_init_verbs },
8831 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8832 .dac_nids = alc883_dac_nids,
8833 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008834 .dig_in_nid = ALC883_DIGIN_NID,
8835 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8836 .channel_mode = alc883_3ST_2ch_modes,
8837 .input_mux = &alc883_capture_source,
8838 },
8839 [ALC883_3ST_6ch_DIG] = {
8840 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8841 .init_verbs = { alc883_init_verbs },
8842 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8843 .dac_nids = alc883_dac_nids,
8844 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008845 .dig_in_nid = ALC883_DIGIN_NID,
8846 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8847 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008848 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008849 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008850 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008851 [ALC883_3ST_6ch] = {
8852 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8853 .init_verbs = { alc883_init_verbs },
8854 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8855 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008856 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8857 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008858 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008859 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008860 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02008861 [ALC883_3ST_6ch_INTEL] = {
8862 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
8863 .init_verbs = { alc883_init_verbs },
8864 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8865 .dac_nids = alc883_dac_nids,
8866 .dig_out_nid = ALC883_DIGOUT_NID,
8867 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08008868 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +02008869 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
8870 .channel_mode = alc883_3ST_6ch_intel_modes,
8871 .need_dac_fix = 1,
8872 .input_mux = &alc883_3stack_6ch_intel,
8873 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008874 [ALC883_6ST_DIG] = {
8875 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
8876 .init_verbs = { alc883_init_verbs },
8877 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8878 .dac_nids = alc883_dac_nids,
8879 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008880 .dig_in_nid = ALC883_DIGIN_NID,
8881 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8882 .channel_mode = alc883_sixstack_modes,
8883 .input_mux = &alc883_capture_source,
8884 },
Kailang Yangccc656c2006-10-17 12:32:26 +02008885 [ALC883_TARGA_DIG] = {
8886 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
8887 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8888 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8889 .dac_nids = alc883_dac_nids,
8890 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008891 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8892 .channel_mode = alc883_3ST_6ch_modes,
8893 .need_dac_fix = 1,
8894 .input_mux = &alc883_capture_source,
8895 .unsol_event = alc883_tagra_unsol_event,
8896 .init_hook = alc883_tagra_automute,
8897 },
8898 [ALC883_TARGA_2ch_DIG] = {
8899 .mixers = { alc883_tagra_2ch_mixer},
8900 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8901 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8902 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008903 .adc_nids = alc883_adc_nids_alt,
8904 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangccc656c2006-10-17 12:32:26 +02008905 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008906 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8907 .channel_mode = alc883_3ST_2ch_modes,
8908 .input_mux = &alc883_capture_source,
8909 .unsol_event = alc883_tagra_unsol_event,
8910 .init_hook = alc883_tagra_automute,
8911 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008912 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008913 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008914 /* On TravelMate laptops, GPIO 0 enables the internal speaker
8915 * and the headphone jack. Turn this on and rely on the
8916 * standard mute methods whenever the user wants to turn
8917 * these outputs off.
8918 */
8919 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
8920 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8921 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008922 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8923 .channel_mode = alc883_3ST_2ch_modes,
8924 .input_mux = &alc883_capture_source,
8925 },
Tobin Davis2880a862007-08-07 11:50:26 +02008926 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008927 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02008928 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02008929 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8930 .dac_nids = alc883_dac_nids,
8931 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02008932 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8933 .channel_mode = alc883_3ST_2ch_modes,
8934 .input_mux = &alc883_capture_source,
Takashi Iwai676a9b52007-08-16 15:23:35 +02008935 .unsol_event = alc883_acer_aspire_unsol_event,
8936 .init_hook = alc883_acer_aspire_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +02008937 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008938 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008939 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008940 alc883_chmode_mixer },
8941 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
8942 alc888_acer_aspire_4930g_verbs },
8943 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8944 .dac_nids = alc883_dac_nids,
8945 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
8946 .adc_nids = alc883_adc_nids_rev,
8947 .capsrc_nids = alc883_capsrc_nids_rev,
8948 .dig_out_nid = ALC883_DIGOUT_NID,
8949 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8950 .channel_mode = alc883_3ST_6ch_modes,
8951 .need_dac_fix = 1,
8952 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008953 ARRAY_SIZE(alc888_2_capture_sources),
8954 .input_mux = alc888_2_capture_sources,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008955 .unsol_event = alc888_acer_aspire_4930g_unsol_event,
8956 .init_hook = alc888_acer_aspire_4930g_automute,
8957 },
Tobin Davisc07584c2006-10-13 12:32:16 +02008958 [ALC883_MEDION] = {
8959 .mixers = { alc883_fivestack_mixer,
8960 alc883_chmode_mixer },
8961 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008962 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02008963 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8964 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008965 .adc_nids = alc883_adc_nids_alt,
8966 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Tobin Davisc07584c2006-10-13 12:32:16 +02008967 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8968 .channel_mode = alc883_sixstack_modes,
8969 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008970 },
Kailang Yang272a5272007-05-14 11:00:38 +02008971 [ALC883_MEDION_MD2] = {
8972 .mixers = { alc883_medion_md2_mixer},
8973 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
8974 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8975 .dac_nids = alc883_dac_nids,
8976 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008977 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8978 .channel_mode = alc883_3ST_2ch_modes,
8979 .input_mux = &alc883_capture_source,
8980 .unsol_event = alc883_medion_md2_unsol_event,
8981 .init_hook = alc883_medion_md2_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +02008982 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008983 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008984 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008985 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
8986 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8987 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008988 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8989 .channel_mode = alc883_3ST_2ch_modes,
8990 .input_mux = &alc883_capture_source,
8991 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008992 [ALC883_CLEVO_M720] = {
8993 .mixers = { alc883_clevo_m720_mixer },
8994 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01008995 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8996 .dac_nids = alc883_dac_nids,
8997 .dig_out_nid = ALC883_DIGOUT_NID,
8998 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8999 .channel_mode = alc883_3ST_2ch_modes,
9000 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009001 .unsol_event = alc883_clevo_m720_unsol_event,
9002 .init_hook = alc883_clevo_m720_automute,
Jiang zhe368c7a92008-03-04 11:20:33 +01009003 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009004 [ALC883_LENOVO_101E_2ch] = {
9005 .mixers = { alc883_lenovo_101e_2ch_mixer},
9006 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
9007 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9008 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009009 .adc_nids = alc883_adc_nids_alt,
9010 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009011 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9012 .channel_mode = alc883_3ST_2ch_modes,
9013 .input_mux = &alc883_lenovo_101e_capture_source,
9014 .unsol_event = alc883_lenovo_101e_unsol_event,
9015 .init_hook = alc883_lenovo_101e_all_automute,
9016 },
Kailang Yang272a5272007-05-14 11:00:38 +02009017 [ALC883_LENOVO_NB0763] = {
9018 .mixers = { alc883_lenovo_nb0763_mixer },
9019 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
9020 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9021 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02009022 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9023 .channel_mode = alc883_3ST_2ch_modes,
9024 .need_dac_fix = 1,
9025 .input_mux = &alc883_lenovo_nb0763_capture_source,
9026 .unsol_event = alc883_medion_md2_unsol_event,
9027 .init_hook = alc883_medion_md2_automute,
9028 },
9029 [ALC888_LENOVO_MS7195_DIG] = {
9030 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9031 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
9032 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9033 .dac_nids = alc883_dac_nids,
9034 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009035 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9036 .channel_mode = alc883_3ST_6ch_modes,
9037 .need_dac_fix = 1,
9038 .input_mux = &alc883_capture_source,
9039 .unsol_event = alc883_lenovo_ms7195_unsol_event,
9040 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02009041 },
9042 [ALC883_HAIER_W66] = {
9043 .mixers = { alc883_tagra_2ch_mixer},
9044 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
9045 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9046 .dac_nids = alc883_dac_nids,
9047 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02009048 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9049 .channel_mode = alc883_3ST_2ch_modes,
9050 .input_mux = &alc883_capture_source,
9051 .unsol_event = alc883_haier_w66_unsol_event,
9052 .init_hook = alc883_haier_w66_automute,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009053 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009054 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009055 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009056 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009057 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9058 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009059 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
9060 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009061 .need_dac_fix = 1,
9062 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009063 .unsol_event = alc888_3st_hp_unsol_event,
9064 .init_hook = alc888_3st_hp_front_automute,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009065 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009066 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01009067 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009068 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
9069 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9070 .dac_nids = alc883_dac_nids,
9071 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009072 .dig_in_nid = ALC883_DIGIN_NID,
9073 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9074 .channel_mode = alc883_sixstack_modes,
9075 .input_mux = &alc883_capture_source,
9076 .unsol_event = alc888_6st_dell_unsol_event,
9077 .init_hook = alc888_6st_dell_front_automute,
9078 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009079 [ALC883_MITAC] = {
9080 .mixers = { alc883_mitac_mixer },
9081 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
9082 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9083 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009084 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9085 .channel_mode = alc883_3ST_2ch_modes,
9086 .input_mux = &alc883_capture_source,
9087 .unsol_event = alc883_mitac_unsol_event,
9088 .init_hook = alc883_mitac_automute,
9089 },
Jiang zhefb97dc62008-03-06 11:07:11 +01009090 [ALC883_FUJITSU_PI2515] = {
9091 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
9092 .init_verbs = { alc883_init_verbs,
9093 alc883_2ch_fujitsu_pi2515_verbs},
9094 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9095 .dac_nids = alc883_dac_nids,
9096 .dig_out_nid = ALC883_DIGOUT_NID,
9097 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9098 .channel_mode = alc883_3ST_2ch_modes,
9099 .input_mux = &alc883_fujitsu_pi2515_capture_source,
9100 .unsol_event = alc883_2ch_fujitsu_pi2515_unsol_event,
9101 .init_hook = alc883_2ch_fujitsu_pi2515_automute,
9102 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009103 [ALC888_FUJITSU_XA3530] = {
9104 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
9105 .init_verbs = { alc883_init_verbs,
9106 alc888_fujitsu_xa3530_verbs },
9107 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9108 .dac_nids = alc883_dac_nids,
9109 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9110 .adc_nids = alc883_adc_nids_rev,
9111 .capsrc_nids = alc883_capsrc_nids_rev,
9112 .dig_out_nid = ALC883_DIGOUT_NID,
9113 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
9114 .channel_mode = alc888_4ST_8ch_intel_modes,
9115 .num_mux_defs =
9116 ARRAY_SIZE(alc888_2_capture_sources),
9117 .input_mux = alc888_2_capture_sources,
9118 .unsol_event = alc888_fujitsu_xa3530_unsol_event,
9119 .init_hook = alc888_fujitsu_xa3530_automute,
9120 },
Kailang Yange2757d52008-08-26 13:17:46 +02009121 [ALC888_LENOVO_SKY] = {
9122 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
9123 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
9124 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9125 .dac_nids = alc883_dac_nids,
9126 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +02009127 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9128 .channel_mode = alc883_sixstack_modes,
9129 .need_dac_fix = 1,
9130 .input_mux = &alc883_lenovo_sky_capture_source,
9131 .unsol_event = alc883_lenovo_sky_unsol_event,
9132 .init_hook = alc888_lenovo_sky_front_automute,
9133 },
9134 [ALC888_ASUS_M90V] = {
9135 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9136 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
9137 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9138 .dac_nids = alc883_dac_nids,
9139 .dig_out_nid = ALC883_DIGOUT_NID,
9140 .dig_in_nid = ALC883_DIGIN_NID,
9141 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9142 .channel_mode = alc883_3ST_6ch_modes,
9143 .need_dac_fix = 1,
9144 .input_mux = &alc883_fujitsu_pi2515_capture_source,
9145 .unsol_event = alc883_mode2_unsol_event,
9146 .init_hook = alc883_mode2_inithook,
9147 },
9148 [ALC888_ASUS_EEE1601] = {
9149 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009150 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +02009151 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
9152 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9153 .dac_nids = alc883_dac_nids,
9154 .dig_out_nid = ALC883_DIGOUT_NID,
9155 .dig_in_nid = ALC883_DIGIN_NID,
9156 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9157 .channel_mode = alc883_3ST_2ch_modes,
9158 .need_dac_fix = 1,
9159 .input_mux = &alc883_asus_eee1601_capture_source,
9160 .unsol_event = alc883_eee1601_unsol_event,
9161 .init_hook = alc883_eee1601_inithook,
9162 },
Wu Fengguang3ab90932008-11-17 09:51:09 +01009163 [ALC1200_ASUS_P5Q] = {
9164 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9165 .init_verbs = { alc883_init_verbs },
9166 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9167 .dac_nids = alc883_dac_nids,
9168 .dig_out_nid = ALC1200_DIGOUT_NID,
9169 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +08009170 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +01009171 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9172 .channel_mode = alc883_sixstack_modes,
9173 .input_mux = &alc883_capture_source,
9174 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009175};
9176
9177
9178/*
9179 * BIOS auto configuration
9180 */
9181static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
9182 hda_nid_t nid, int pin_type,
9183 int dac_idx)
9184{
9185 /* set as output */
9186 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009187 int idx;
9188
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009189 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009190 if (spec->multiout.dac_nids[dac_idx] == 0x25)
9191 idx = 4;
9192 else
9193 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009194 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
9195
9196}
9197
9198static void alc883_auto_init_multi_out(struct hda_codec *codec)
9199{
9200 struct alc_spec *spec = codec->spec;
9201 int i;
9202
9203 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009204 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009205 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009206 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009207 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009208 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009209 }
9210}
9211
9212static void alc883_auto_init_hp_out(struct hda_codec *codec)
9213{
9214 struct alc_spec *spec = codec->spec;
9215 hda_nid_t pin;
9216
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009217 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009218 if (pin) /* connect to front */
9219 /* use dac 0 */
9220 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009221 pin = spec->autocfg.speaker_pins[0];
9222 if (pin)
9223 alc883_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009224}
9225
9226#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
9227#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
9228
9229static void alc883_auto_init_analog_input(struct hda_codec *codec)
9230{
9231 struct alc_spec *spec = codec->spec;
9232 int i;
9233
9234 for (i = 0; i < AUTO_PIN_LAST; i++) {
9235 hda_nid_t nid = spec->autocfg.input_pins[i];
9236 if (alc883_is_input_pin(nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01009237 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01009238 if (nid != ALC883_PIN_CD_NID &&
9239 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009240 snd_hda_codec_write(codec, nid, 0,
9241 AC_VERB_SET_AMP_GAIN_MUTE,
9242 AMP_OUT_MUTE);
9243 }
9244 }
9245}
9246
Takashi Iwaif511b012008-08-15 16:46:42 +02009247#define alc883_auto_init_input_src alc882_auto_init_input_src
9248
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009249/* almost identical with ALC880 parser... */
9250static int alc883_parse_auto_config(struct hda_codec *codec)
9251{
9252 struct alc_spec *spec = codec->spec;
9253 int err = alc880_parse_auto_config(codec);
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009254 struct auto_pin_cfg *cfg = &spec->autocfg;
9255 int i;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009256
9257 if (err < 0)
9258 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02009259 else if (!err)
9260 return 0; /* no config found */
9261
9262 err = alc_auto_add_mic_boost(codec);
9263 if (err < 0)
9264 return err;
9265
9266 /* hack - override the init verbs */
9267 spec->init_verbs[0] = alc883_auto_init_verbs;
Takashi Iwai776e1842007-08-29 15:07:11 +02009268
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009269 /* setup input_mux for ALC889 */
9270 if (codec->vendor_id == 0x10ec0889) {
9271 /* digital-mic input pin is excluded in alc880_auto_create..()
9272 * because it's under 0x18
9273 */
9274 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
9275 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
9276 struct hda_input_mux *imux = &spec->private_imux[0];
9277 for (i = 1; i < 3; i++)
9278 memcpy(&spec->private_imux[i],
9279 &spec->private_imux[0],
9280 sizeof(spec->private_imux[0]));
9281 imux->items[imux->num_items].label = "Int DMic";
9282 imux->items[imux->num_items].index = 0x0b;
9283 imux->num_items++;
9284 spec->num_mux_defs = 3;
9285 spec->input_mux = spec->private_imux;
9286 }
9287 }
9288
Takashi Iwai776e1842007-08-29 15:07:11 +02009289 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009290}
9291
9292/* additional initialization for auto-configuration model */
9293static void alc883_auto_init(struct hda_codec *codec)
9294{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009295 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009296 alc883_auto_init_multi_out(codec);
9297 alc883_auto_init_hp_out(codec);
9298 alc883_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02009299 alc883_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009300 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02009301 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009302}
9303
9304static int patch_alc883(struct hda_codec *codec)
9305{
9306 struct alc_spec *spec;
9307 int err, board_config;
9308
9309 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
9310 if (spec == NULL)
9311 return -ENOMEM;
9312
9313 codec->spec = spec;
9314
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02009315 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
9316
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009317 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
9318 alc883_models,
9319 alc883_cfg_tbl);
9320 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009321 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
9322 "trying auto-probe from BIOS...\n");
9323 board_config = ALC883_AUTO;
9324 }
9325
9326 if (board_config == ALC883_AUTO) {
9327 /* automatic parse from the BIOS config */
9328 err = alc883_parse_auto_config(codec);
9329 if (err < 0) {
9330 alc_free(codec);
9331 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009332 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009333 printk(KERN_INFO
9334 "hda_codec: Cannot set up configuration "
9335 "from BIOS. Using base mode...\n");
9336 board_config = ALC883_3ST_2ch_DIG;
9337 }
9338 }
9339
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09009340 err = snd_hda_attach_beep_device(codec, 0x1);
9341 if (err < 0) {
9342 alc_free(codec);
9343 return err;
9344 }
9345
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009346 if (board_config != ALC883_AUTO)
9347 setup_preset(spec, &alc883_presets[board_config]);
9348
Kailang Yang2f893282008-05-27 12:14:47 +02009349 switch (codec->vendor_id) {
9350 case 0x10ec0888:
Kailang Yang44426082008-10-15 11:18:05 +02009351 if (codec->revision_id == 0x100101) {
9352 spec->stream_name_analog = "ALC1200 Analog";
9353 spec->stream_name_digital = "ALC1200 Digital";
9354 } else {
9355 spec->stream_name_analog = "ALC888 Analog";
9356 spec->stream_name_digital = "ALC888 Digital";
9357 }
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009358 if (!spec->num_adc_nids) {
9359 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
9360 spec->adc_nids = alc883_adc_nids;
9361 }
9362 if (!spec->capsrc_nids)
9363 spec->capsrc_nids = alc883_capsrc_nids;
9364 spec->capture_style = CAPT_MIX; /* matrix-style capture */
Takashi Iwai4a79ba32009-04-22 16:31:35 +02009365 spec->init_amp = ALC_INIT_DEFAULT; /* always initialize */
Kailang Yang2f893282008-05-27 12:14:47 +02009366 break;
9367 case 0x10ec0889:
9368 spec->stream_name_analog = "ALC889 Analog";
9369 spec->stream_name_digital = "ALC889 Digital";
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009370 if (!spec->num_adc_nids) {
9371 spec->num_adc_nids = ARRAY_SIZE(alc889_adc_nids);
9372 spec->adc_nids = alc889_adc_nids;
9373 }
9374 if (!spec->capsrc_nids)
9375 spec->capsrc_nids = alc889_capsrc_nids;
9376 spec->capture_style = CAPT_1MUX_MIX; /* 1mux/Nmix-style
9377 capture */
Kailang Yang2f893282008-05-27 12:14:47 +02009378 break;
9379 default:
9380 spec->stream_name_analog = "ALC883 Analog";
9381 spec->stream_name_digital = "ALC883 Digital";
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009382 if (!spec->num_adc_nids) {
9383 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
9384 spec->adc_nids = alc883_adc_nids;
9385 }
9386 if (!spec->capsrc_nids)
9387 spec->capsrc_nids = alc883_capsrc_nids;
9388 spec->capture_style = CAPT_MIX; /* matrix-style capture */
Kailang Yang2f893282008-05-27 12:14:47 +02009389 break;
9390 }
9391
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009392 spec->stream_analog_playback = &alc883_pcm_analog_playback;
9393 spec->stream_analog_capture = &alc883_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01009394 spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009395
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009396 spec->stream_digital_playback = &alc883_pcm_digital_playback;
9397 spec->stream_digital_capture = &alc883_pcm_digital_capture;
9398
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009399 if (!spec->cap_mixer)
9400 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01009401 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009402
Takashi Iwai2134ea42008-01-10 16:53:55 +01009403 spec->vmaster_nid = 0x0c;
9404
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009405 codec->patch_ops = alc_patch_ops;
9406 if (board_config == ALC883_AUTO)
9407 spec->init_hook = alc883_auto_init;
Kailang Yangf9423e72008-05-27 12:32:25 +02009408
Takashi Iwaicb53c622007-08-10 17:21:45 +02009409#ifdef CONFIG_SND_HDA_POWER_SAVE
9410 if (!spec->loopback.amplist)
9411 spec->loopback.amplist = alc883_loopbacks;
9412#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01009413 codec->proc_widget_hook = print_realtek_coef;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009414
9415 return 0;
9416}
9417
9418/*
Kailang Yangdf694da2005-12-05 19:42:22 +01009419 * ALC262 support
9420 */
9421
9422#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
9423#define ALC262_DIGIN_NID ALC880_DIGIN_NID
9424
9425#define alc262_dac_nids alc260_dac_nids
9426#define alc262_adc_nids alc882_adc_nids
9427#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +01009428#define alc262_capsrc_nids alc882_capsrc_nids
9429#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +01009430
9431#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01009432#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01009433
Kailang Yang4e555fe2008-08-26 13:05:55 +02009434static hda_nid_t alc262_dmic_adc_nids[1] = {
9435 /* ADC0 */
9436 0x09
9437};
9438
9439static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
9440
Kailang Yangdf694da2005-12-05 19:42:22 +01009441static struct snd_kcontrol_new alc262_base_mixer[] = {
9442 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9443 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9444 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9445 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9446 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9447 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9448 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9449 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009450 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009451 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9452 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009453 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009454 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
9455 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9456 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
9457 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009458 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01009459};
9460
Kailang Yangccc656c2006-10-17 12:32:26 +02009461static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
9462 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9463 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9464 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9465 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9466 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9467 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9468 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9469 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009470 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009471 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9472 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009473 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009474 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
9475 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9476 { } /* end */
9477};
9478
Takashi Iwaice875f02008-01-28 18:17:43 +01009479/* update HP, line and mono-out pins according to the master switch */
9480static void alc262_hp_master_update(struct hda_codec *codec)
9481{
9482 struct alc_spec *spec = codec->spec;
9483 int val = spec->master_sw;
9484
9485 /* HP & line-out */
9486 snd_hda_codec_write_cache(codec, 0x1b, 0,
9487 AC_VERB_SET_PIN_WIDGET_CONTROL,
9488 val ? PIN_HP : 0);
9489 snd_hda_codec_write_cache(codec, 0x15, 0,
9490 AC_VERB_SET_PIN_WIDGET_CONTROL,
9491 val ? PIN_HP : 0);
9492 /* mono (speaker) depending on the HP jack sense */
9493 val = val && !spec->jack_present;
9494 snd_hda_codec_write_cache(codec, 0x16, 0,
9495 AC_VERB_SET_PIN_WIDGET_CONTROL,
9496 val ? PIN_OUT : 0);
9497}
9498
9499static void alc262_hp_bpc_automute(struct hda_codec *codec)
9500{
9501 struct alc_spec *spec = codec->spec;
9502 unsigned int presence;
9503 presence = snd_hda_codec_read(codec, 0x1b, 0,
9504 AC_VERB_GET_PIN_SENSE, 0);
9505 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9506 alc262_hp_master_update(codec);
9507}
9508
9509static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
9510{
9511 if ((res >> 26) != ALC880_HP_EVENT)
9512 return;
9513 alc262_hp_bpc_automute(codec);
9514}
9515
9516static void alc262_hp_wildwest_automute(struct hda_codec *codec)
9517{
9518 struct alc_spec *spec = codec->spec;
9519 unsigned int presence;
9520 presence = snd_hda_codec_read(codec, 0x15, 0,
9521 AC_VERB_GET_PIN_SENSE, 0);
9522 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9523 alc262_hp_master_update(codec);
9524}
9525
9526static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
9527 unsigned int res)
9528{
9529 if ((res >> 26) != ALC880_HP_EVENT)
9530 return;
9531 alc262_hp_wildwest_automute(codec);
9532}
9533
9534static int alc262_hp_master_sw_get(struct snd_kcontrol *kcontrol,
9535 struct snd_ctl_elem_value *ucontrol)
9536{
9537 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9538 struct alc_spec *spec = codec->spec;
9539 *ucontrol->value.integer.value = spec->master_sw;
9540 return 0;
9541}
9542
9543static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
9544 struct snd_ctl_elem_value *ucontrol)
9545{
9546 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9547 struct alc_spec *spec = codec->spec;
9548 int val = !!*ucontrol->value.integer.value;
9549
9550 if (val == spec->master_sw)
9551 return 0;
9552 spec->master_sw = val;
9553 alc262_hp_master_update(codec);
9554 return 1;
9555}
9556
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009557static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01009558 {
9559 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9560 .name = "Master Playback Switch",
9561 .info = snd_ctl_boolean_mono_info,
9562 .get = alc262_hp_master_sw_get,
9563 .put = alc262_hp_master_sw_put,
9564 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009565 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9566 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9567 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009568 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9569 HDA_OUTPUT),
9570 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9571 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009572 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9573 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009574 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009575 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9576 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009577 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009578 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9579 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9580 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9581 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009582 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
9583 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
9584 { } /* end */
9585};
9586
Kailang Yangcd7509a2007-01-26 18:33:17 +01009587static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01009588 {
9589 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9590 .name = "Master Playback Switch",
9591 .info = snd_ctl_boolean_mono_info,
9592 .get = alc262_hp_master_sw_get,
9593 .put = alc262_hp_master_sw_put,
9594 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01009595 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9596 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9597 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9598 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009599 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9600 HDA_OUTPUT),
9601 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9602 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009603 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
9604 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009605 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009606 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9607 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9608 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9609 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009610 { } /* end */
9611};
9612
9613static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
9614 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9615 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009616 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009617 { } /* end */
9618};
9619
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009620/* mute/unmute internal speaker according to the hp jack and mute state */
9621static void alc262_hp_t5735_automute(struct hda_codec *codec, int force)
9622{
9623 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009624
9625 if (force || !spec->sense_updated) {
9626 unsigned int present;
9627 present = snd_hda_codec_read(codec, 0x15, 0,
9628 AC_VERB_GET_PIN_SENSE, 0);
Takashi Iwai4bb26132008-01-28 18:12:42 +01009629 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009630 spec->sense_updated = 1;
9631 }
Takashi Iwai4bb26132008-01-28 18:12:42 +01009632 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, HDA_AMP_MUTE,
9633 spec->jack_present ? HDA_AMP_MUTE : 0);
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009634}
9635
9636static void alc262_hp_t5735_unsol_event(struct hda_codec *codec,
9637 unsigned int res)
9638{
9639 if ((res >> 26) != ALC880_HP_EVENT)
9640 return;
9641 alc262_hp_t5735_automute(codec, 1);
9642}
9643
9644static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
9645{
9646 alc262_hp_t5735_automute(codec, 1);
9647}
9648
9649static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +01009650 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9651 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009652 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9653 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9654 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9655 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9656 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9657 { } /* end */
9658};
9659
9660static struct hda_verb alc262_hp_t5735_verbs[] = {
9661 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9662 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9663
9664 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9665 { }
9666};
9667
Kailang Yang8c427222008-01-10 13:03:59 +01009668static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +01009669 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9670 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01009671 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
9672 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +01009673 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9674 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9675 { } /* end */
9676};
9677
9678static struct hda_verb alc262_hp_rp5700_verbs[] = {
9679 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9680 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9681 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9682 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9683 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9684 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9685 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9686 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9687 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9688 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9689 {}
9690};
9691
9692static struct hda_input_mux alc262_hp_rp5700_capture_source = {
9693 .num_items = 1,
9694 .items = {
9695 { "Line", 0x1 },
9696 },
9697};
9698
Takashi Iwai0724ea22007-08-23 00:31:43 +02009699/* bind hp and internal speaker mute (with plug check) */
9700static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
9701 struct snd_ctl_elem_value *ucontrol)
9702{
9703 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9704 long *valp = ucontrol->value.integer.value;
9705 int change;
9706
9707 /* change hp mute */
9708 change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
9709 HDA_AMP_MUTE,
9710 valp[0] ? 0 : HDA_AMP_MUTE);
9711 change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
9712 HDA_AMP_MUTE,
9713 valp[1] ? 0 : HDA_AMP_MUTE);
9714 if (change) {
9715 /* change speaker according to HP jack state */
9716 struct alc_spec *spec = codec->spec;
9717 unsigned int mute;
9718 if (spec->jack_present)
9719 mute = HDA_AMP_MUTE;
9720 else
9721 mute = snd_hda_codec_amp_read(codec, 0x15, 0,
9722 HDA_OUTPUT, 0);
9723 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9724 HDA_AMP_MUTE, mute);
9725 }
9726 return change;
9727}
Takashi Iwai5b319542007-07-26 11:49:22 +02009728
Kailang Yang272a5272007-05-14 11:00:38 +02009729static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +02009730 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9731 {
9732 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9733 .name = "Master Playback Switch",
9734 .info = snd_hda_mixer_amp_switch_info,
9735 .get = snd_hda_mixer_amp_switch_get,
9736 .put = alc262_sony_master_sw_put,
9737 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
9738 },
Kailang Yang272a5272007-05-14 11:00:38 +02009739 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9740 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9741 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9742 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9743 { } /* end */
9744};
9745
Kailang Yang83c34212007-07-05 11:43:05 +02009746static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
9747 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9748 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9749 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9750 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9751 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9752 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9753 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9754 { } /* end */
9755};
Kailang Yang272a5272007-05-14 11:00:38 +02009756
Tony Vroonba340e82009-02-02 19:01:30 +00009757static struct snd_kcontrol_new alc262_tyan_mixer[] = {
9758 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9759 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
9760 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
9761 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
9762 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9763 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9764 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9765 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9766 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9767 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9768 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9769 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9770 { } /* end */
9771};
9772
9773static struct hda_verb alc262_tyan_verbs[] = {
9774 /* Headphone automute */
9775 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9776 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9777 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9778
9779 /* P11 AUX_IN, white 4-pin connector */
9780 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9781 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
9782 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
9783 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
9784
9785 {}
9786};
9787
9788/* unsolicited event for HP jack sensing */
9789static void alc262_tyan_automute(struct hda_codec *codec)
9790{
9791 unsigned int mute;
9792 unsigned int present;
9793
9794 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9795 present = snd_hda_codec_read(codec, 0x1b, 0,
9796 AC_VERB_GET_PIN_SENSE, 0);
9797 present = (present & 0x80000000) != 0;
9798 if (present) {
9799 /* mute line output on ATX panel */
9800 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9801 HDA_AMP_MUTE, HDA_AMP_MUTE);
9802 } else {
9803 /* unmute line output if necessary */
9804 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
9805 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9806 HDA_AMP_MUTE, mute);
9807 }
9808}
9809
9810static void alc262_tyan_unsol_event(struct hda_codec *codec,
9811 unsigned int res)
9812{
9813 if ((res >> 26) != ALC880_HP_EVENT)
9814 return;
9815 alc262_tyan_automute(codec);
9816}
9817
Kailang Yangdf694da2005-12-05 19:42:22 +01009818#define alc262_capture_mixer alc882_capture_mixer
9819#define alc262_capture_alt_mixer alc882_capture_alt_mixer
9820
9821/*
9822 * generic initialization of ADC, input mixers and output mixers
9823 */
9824static struct hda_verb alc262_init_verbs[] = {
9825 /*
9826 * Unmute ADC0-2 and set the default input to mic-in
9827 */
9828 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9829 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9830 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9831 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9832 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9833 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9834
Takashi Iwaicb53c622007-08-10 17:21:45 +02009835 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01009836 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009837 * Note: PASD motherboards uses the Line In 2 as the input for
9838 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01009839 */
9840 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009841 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9842 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9843 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9844 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9845 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009846
9847 /*
9848 * Set up output mixers (0x0c - 0x0e)
9849 */
9850 /* set vol=0 to output mixers */
9851 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9852 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9853 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9854 /* set up input amps for analog loopback */
9855 /* Amp Indices: DAC = 0, mixer = 1 */
9856 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9857 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9858 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9859 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9860 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9861 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9862
9863 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9864 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9865 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9866 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9867 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9868 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9869
9870 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9871 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9872 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9873 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9874 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +02009875
Kailang Yangdf694da2005-12-05 19:42:22 +01009876 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9877 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +02009878
Kailang Yangdf694da2005-12-05 19:42:22 +01009879 /* FIXME: use matrix-type input source selection */
9880 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9881 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9882 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9883 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9884 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9885 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9886 /* Input mixer2 */
9887 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9888 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9889 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9890 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9891 /* Input mixer3 */
9892 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9893 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9894 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009895 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +01009896
9897 { }
9898};
9899
Kailang Yang4e555fe2008-08-26 13:05:55 +02009900static struct hda_verb alc262_eapd_verbs[] = {
9901 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
9902 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
9903 { }
9904};
9905
Kailang Yangccc656c2006-10-17 12:32:26 +02009906static struct hda_verb alc262_hippo_unsol_verbs[] = {
9907 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9908 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9909 {}
9910};
9911
9912static struct hda_verb alc262_hippo1_unsol_verbs[] = {
9913 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9914 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9915 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9916
9917 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9918 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9919 {}
9920};
9921
Kailang Yang272a5272007-05-14 11:00:38 +02009922static struct hda_verb alc262_sony_unsol_verbs[] = {
9923 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9924 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9925 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
9926
9927 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9928 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +09009929 {}
Kailang Yang272a5272007-05-14 11:00:38 +02009930};
9931
Kailang Yang4e555fe2008-08-26 13:05:55 +02009932static struct hda_input_mux alc262_dmic_capture_source = {
9933 .num_items = 2,
9934 .items = {
9935 { "Int DMic", 0x9 },
9936 { "Mic", 0x0 },
9937 },
9938};
9939
9940static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
9941 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9942 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9943 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9944 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9945 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +02009946 { } /* end */
9947};
9948
9949static struct hda_verb alc262_toshiba_s06_verbs[] = {
9950 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9951 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9952 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9953 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9954 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
9955 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9956 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
9957 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9958 {}
9959};
9960
9961static void alc262_dmic_automute(struct hda_codec *codec)
9962{
9963 unsigned int present;
9964
9965 present = snd_hda_codec_read(codec, 0x18, 0,
9966 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9967 snd_hda_codec_write(codec, 0x22, 0,
9968 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x09);
9969}
9970
9971/* toggle speaker-output according to the hp-jack state */
9972static void alc262_toshiba_s06_speaker_automute(struct hda_codec *codec)
9973{
9974 unsigned int present;
9975 unsigned char bits;
9976
9977 present = snd_hda_codec_read(codec, 0x15, 0,
9978 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9979 bits = present ? 0 : PIN_OUT;
9980 snd_hda_codec_write(codec, 0x14, 0,
9981 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
9982}
9983
9984
9985
9986/* unsolicited event for HP jack sensing */
9987static void alc262_toshiba_s06_unsol_event(struct hda_codec *codec,
9988 unsigned int res)
9989{
9990 if ((res >> 26) == ALC880_HP_EVENT)
9991 alc262_toshiba_s06_speaker_automute(codec);
9992 if ((res >> 26) == ALC880_MIC_EVENT)
9993 alc262_dmic_automute(codec);
9994
9995}
9996
9997static void alc262_toshiba_s06_init_hook(struct hda_codec *codec)
9998{
9999 alc262_toshiba_s06_speaker_automute(codec);
10000 alc262_dmic_automute(codec);
10001}
10002
Kailang Yangccc656c2006-10-17 12:32:26 +020010003/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai5b319542007-07-26 11:49:22 +020010004static void alc262_hippo_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +020010005{
10006 struct alc_spec *spec = codec->spec;
10007 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +020010008 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +020010009
Takashi Iwai5b319542007-07-26 11:49:22 +020010010 /* need to execute and sync at first */
10011 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
10012 present = snd_hda_codec_read(codec, 0x15, 0,
10013 AC_VERB_GET_PIN_SENSE, 0);
10014 spec->jack_present = (present & 0x80000000) != 0;
Kailang Yangccc656c2006-10-17 12:32:26 +020010015 if (spec->jack_present) {
10016 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +020010017 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10018 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +020010019 } else {
10020 /* unmute internal speaker if necessary */
10021 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +020010022 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10023 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +020010024 }
10025}
10026
10027/* unsolicited event for HP jack sensing */
10028static void alc262_hippo_unsol_event(struct hda_codec *codec,
10029 unsigned int res)
10030{
10031 if ((res >> 26) != ALC880_HP_EVENT)
10032 return;
Takashi Iwai5b319542007-07-26 11:49:22 +020010033 alc262_hippo_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +020010034}
10035
Takashi Iwai5b319542007-07-26 11:49:22 +020010036static void alc262_hippo1_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +020010037{
Kailang Yangccc656c2006-10-17 12:32:26 +020010038 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +020010039 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +020010040
Takashi Iwai5b319542007-07-26 11:49:22 +020010041 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10042 present = snd_hda_codec_read(codec, 0x1b, 0,
10043 AC_VERB_GET_PIN_SENSE, 0);
10044 present = (present & 0x80000000) != 0;
10045 if (present) {
Kailang Yangccc656c2006-10-17 12:32:26 +020010046 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +020010047 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10048 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +020010049 } else {
10050 /* unmute internal speaker if necessary */
10051 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +020010052 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10053 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +020010054 }
10055}
10056
10057/* unsolicited event for HP jack sensing */
10058static void alc262_hippo1_unsol_event(struct hda_codec *codec,
10059 unsigned int res)
10060{
10061 if ((res >> 26) != ALC880_HP_EVENT)
10062 return;
Takashi Iwai5b319542007-07-26 11:49:22 +020010063 alc262_hippo1_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +020010064}
10065
Takashi Iwai834be882006-03-01 14:16:17 +010010066/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010067 * nec model
10068 * 0x15 = headphone
10069 * 0x16 = internal speaker
10070 * 0x18 = external mic
10071 */
10072
10073static struct snd_kcontrol_new alc262_nec_mixer[] = {
10074 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
10075 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
10076
10077 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10078 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10079 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10080
10081 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10082 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10083 { } /* end */
10084};
10085
10086static struct hda_verb alc262_nec_verbs[] = {
10087 /* Unmute Speaker */
10088 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10089
10090 /* Headphone */
10091 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10092 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10093
10094 /* External mic to headphone */
10095 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10096 /* External mic to speaker */
10097 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10098 {}
10099};
10100
10101/*
Takashi Iwai834be882006-03-01 14:16:17 +010010102 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010010103 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
10104 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010010105 */
10106
10107#define ALC_HP_EVENT 0x37
10108
10109static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
10110 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10111 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010010112 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10113 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010010114 {}
10115};
10116
Jiang zhe0e31daf2008-03-20 12:12:39 +010010117static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
10118 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10119 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10120 {}
10121};
10122
Takashi Iwai834be882006-03-01 14:16:17 +010010123static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010124 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010010125 .items = {
10126 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010127 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010010128 { "CD", 0x4 },
10129 },
10130};
10131
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010132static struct hda_input_mux alc262_HP_capture_source = {
10133 .num_items = 5,
10134 .items = {
10135 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020010136 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010137 { "Line", 0x2 },
10138 { "CD", 0x4 },
10139 { "AUX IN", 0x6 },
10140 },
10141};
10142
zhejiangaccbe492007-08-31 12:36:05 +020010143static struct hda_input_mux alc262_HP_D7000_capture_source = {
10144 .num_items = 4,
10145 .items = {
10146 { "Mic", 0x0 },
10147 { "Front Mic", 0x2 },
10148 { "Line", 0x1 },
10149 { "CD", 0x4 },
10150 },
10151};
10152
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010153/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010010154static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
10155{
10156 struct alc_spec *spec = codec->spec;
10157 unsigned int mute;
10158
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010159 if (force || !spec->sense_updated) {
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010160 unsigned int present;
Takashi Iwai834be882006-03-01 14:16:17 +010010161 /* need to execute and sync at first */
10162 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010163 /* check laptop HP jack */
10164 present = snd_hda_codec_read(codec, 0x14, 0,
10165 AC_VERB_GET_PIN_SENSE, 0);
10166 /* need to execute and sync at first */
10167 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10168 /* check docking HP jack */
10169 present |= snd_hda_codec_read(codec, 0x1b, 0,
10170 AC_VERB_GET_PIN_SENSE, 0);
10171 if (present & AC_PINSENSE_PRESENCE)
10172 spec->jack_present = 1;
10173 else
10174 spec->jack_present = 0;
Takashi Iwai834be882006-03-01 14:16:17 +010010175 spec->sense_updated = 1;
10176 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010177 /* unmute internal speaker only if both HPs are unplugged and
10178 * master switch is on
10179 */
10180 if (spec->jack_present)
10181 mute = HDA_AMP_MUTE;
10182 else
Takashi Iwai834be882006-03-01 14:16:17 +010010183 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010184 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10185 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010010186}
10187
10188/* unsolicited event for HP jack sensing */
10189static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
10190 unsigned int res)
10191{
10192 if ((res >> 26) != ALC_HP_EVENT)
10193 return;
10194 alc262_fujitsu_automute(codec, 1);
10195}
10196
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010197static void alc262_fujitsu_init_hook(struct hda_codec *codec)
10198{
10199 alc262_fujitsu_automute(codec, 1);
10200}
10201
Takashi Iwai834be882006-03-01 14:16:17 +010010202/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020010203static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
10204 .ops = &snd_hda_bind_vol,
10205 .values = {
10206 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
10207 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
10208 0
10209 },
10210};
Takashi Iwai834be882006-03-01 14:16:17 +010010211
Jiang zhe0e31daf2008-03-20 12:12:39 +010010212/* mute/unmute internal speaker according to the hp jack and mute state */
10213static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
10214{
10215 struct alc_spec *spec = codec->spec;
10216 unsigned int mute;
10217
10218 if (force || !spec->sense_updated) {
10219 unsigned int present_int_hp;
10220 /* need to execute and sync at first */
10221 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10222 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
10223 AC_VERB_GET_PIN_SENSE, 0);
10224 spec->jack_present = (present_int_hp & 0x80000000) != 0;
10225 spec->sense_updated = 1;
10226 }
10227 if (spec->jack_present) {
10228 /* mute internal speaker */
10229 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10230 HDA_AMP_MUTE, HDA_AMP_MUTE);
10231 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10232 HDA_AMP_MUTE, HDA_AMP_MUTE);
10233 } else {
10234 /* unmute internal speaker if necessary */
10235 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
10236 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10237 HDA_AMP_MUTE, mute);
10238 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10239 HDA_AMP_MUTE, mute);
10240 }
10241}
10242
10243/* unsolicited event for HP jack sensing */
10244static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
10245 unsigned int res)
10246{
10247 if ((res >> 26) != ALC_HP_EVENT)
10248 return;
10249 alc262_lenovo_3000_automute(codec, 1);
10250}
10251
Takashi Iwai834be882006-03-01 14:16:17 +010010252/* bind hp and internal speaker mute (with plug check) */
10253static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
10254 struct snd_ctl_elem_value *ucontrol)
10255{
10256 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10257 long *valp = ucontrol->value.integer.value;
10258 int change;
10259
Tony Vroon5d9fab22008-03-14 17:09:18 +010010260 change = snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10261 HDA_AMP_MUTE,
10262 valp ? 0 : HDA_AMP_MUTE);
10263 change |= snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
10264 HDA_AMP_MUTE,
10265 valp ? 0 : HDA_AMP_MUTE);
10266
Takashi Iwai82beb8f2007-08-10 17:09:26 +020010267 if (change)
10268 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010010269 return change;
10270}
10271
10272static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020010273 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010010274 {
10275 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10276 .name = "Master Playback Switch",
10277 .info = snd_hda_mixer_amp_switch_info,
10278 .get = snd_hda_mixer_amp_switch_get,
10279 .put = alc262_fujitsu_master_sw_put,
10280 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10281 },
10282 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10283 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10284 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10285 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10286 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010287 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10288 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10289 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010010290 { } /* end */
10291};
10292
Jiang zhe0e31daf2008-03-20 12:12:39 +010010293/* bind hp and internal speaker mute (with plug check) */
10294static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
10295 struct snd_ctl_elem_value *ucontrol)
10296{
10297 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10298 long *valp = ucontrol->value.integer.value;
10299 int change;
10300
10301 change = snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
10302 HDA_AMP_MUTE,
10303 valp ? 0 : HDA_AMP_MUTE);
10304
10305 if (change)
10306 alc262_lenovo_3000_automute(codec, 0);
10307 return change;
10308}
10309
10310static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
10311 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10312 {
10313 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10314 .name = "Master Playback Switch",
10315 .info = snd_hda_mixer_amp_switch_info,
10316 .get = snd_hda_mixer_amp_switch_get,
10317 .put = alc262_lenovo_3000_master_sw_put,
10318 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
10319 },
10320 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10321 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10322 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10323 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10324 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10325 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10326 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10327 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10328 { } /* end */
10329};
10330
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010331static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
10332 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10333 {
10334 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10335 .name = "Master Playback Switch",
10336 .info = snd_hda_mixer_amp_switch_info,
10337 .get = snd_hda_mixer_amp_switch_get,
10338 .put = alc262_sony_master_sw_put,
10339 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
10340 },
10341 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10342 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10343 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10344 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10345 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10346 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10347 { } /* end */
10348};
10349
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010350/* additional init verbs for Benq laptops */
10351static struct hda_verb alc262_EAPD_verbs[] = {
10352 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10353 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
10354 {}
10355};
10356
Kailang Yang83c34212007-07-05 11:43:05 +020010357static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
10358 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10359 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10360
10361 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10362 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
10363 {}
10364};
10365
Tobin Davisf651b502007-10-26 12:40:47 +020010366/* Samsung Q1 Ultra Vista model setup */
10367static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010368 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10369 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010370 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10371 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10372 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010373 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010374 { } /* end */
10375};
10376
10377static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010378 /* output mixer */
10379 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10380 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10381 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10382 /* speaker */
10383 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10384 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10385 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10386 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10387 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020010388 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010389 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10390 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10391 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10392 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10393 /* internal mic */
10394 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10395 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10396 /* ADC, choose mic */
10397 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10398 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10399 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10400 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10401 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10402 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10403 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10404 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10405 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
10406 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020010407 {}
10408};
10409
Tobin Davisf651b502007-10-26 12:40:47 +020010410/* mute/unmute internal speaker according to the hp jack and mute state */
10411static void alc262_ultra_automute(struct hda_codec *codec)
10412{
10413 struct alc_spec *spec = codec->spec;
10414 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020010415
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010416 mute = 0;
10417 /* auto-mute only when HP is used as HP */
10418 if (!spec->cur_mux[0]) {
10419 unsigned int present;
10420 /* need to execute and sync at first */
10421 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
10422 present = snd_hda_codec_read(codec, 0x15, 0,
10423 AC_VERB_GET_PIN_SENSE, 0);
10424 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
10425 if (spec->jack_present)
10426 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020010427 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010428 /* mute/unmute internal speaker */
10429 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10430 HDA_AMP_MUTE, mute);
10431 /* mute/unmute HP */
10432 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10433 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020010434}
10435
10436/* unsolicited event for HP jack sensing */
10437static void alc262_ultra_unsol_event(struct hda_codec *codec,
10438 unsigned int res)
10439{
10440 if ((res >> 26) != ALC880_HP_EVENT)
10441 return;
10442 alc262_ultra_automute(codec);
10443}
10444
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010445static struct hda_input_mux alc262_ultra_capture_source = {
10446 .num_items = 2,
10447 .items = {
10448 { "Mic", 0x1 },
10449 { "Headphone", 0x7 },
10450 },
10451};
10452
10453static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
10454 struct snd_ctl_elem_value *ucontrol)
10455{
10456 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10457 struct alc_spec *spec = codec->spec;
10458 int ret;
10459
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010460 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010461 if (!ret)
10462 return 0;
10463 /* reprogram the HP pin as mic or HP according to the input source */
10464 snd_hda_codec_write_cache(codec, 0x15, 0,
10465 AC_VERB_SET_PIN_WIDGET_CONTROL,
10466 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
10467 alc262_ultra_automute(codec); /* mute/unmute HP */
10468 return ret;
10469}
10470
10471static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
10472 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10473 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10474 {
10475 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10476 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010477 .info = alc_mux_enum_info,
10478 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010479 .put = alc262_ultra_mux_enum_put,
10480 },
10481 { } /* end */
10482};
10483
Kailang Yangdf694da2005-12-05 19:42:22 +010010484/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010485static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
10486 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010010487{
10488 hda_nid_t nid;
10489 int err;
10490
10491 spec->multiout.num_dacs = 1; /* only use one dac */
10492 spec->multiout.dac_nids = spec->private_dac_nids;
10493 spec->multiout.dac_nids[0] = 2;
10494
10495 nid = cfg->line_out_pins[0];
10496 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010497 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10498 "Front Playback Volume",
10499 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
10500 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010501 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010502 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10503 "Front Playback Switch",
10504 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
10505 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010506 return err;
10507 }
10508
Takashi Iwai82bc9552006-03-21 11:24:42 +010010509 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010510 if (nid) {
10511 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010512 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10513 "Speaker Playback Volume",
10514 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10515 HDA_OUTPUT));
10516 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010517 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010518 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10519 "Speaker Playback Switch",
10520 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10521 HDA_OUTPUT));
10522 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010523 return err;
10524 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010525 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10526 "Speaker Playback Switch",
10527 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10528 HDA_OUTPUT));
10529 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010530 return err;
10531 }
10532 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +020010533 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010534 if (nid) {
10535 /* spec->multiout.hp_nid = 2; */
10536 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010537 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10538 "Headphone Playback Volume",
10539 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10540 HDA_OUTPUT));
10541 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010542 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010543 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10544 "Headphone Playback Switch",
10545 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10546 HDA_OUTPUT));
10547 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010548 return err;
10549 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010550 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10551 "Headphone Playback Switch",
10552 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10553 HDA_OUTPUT));
10554 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010555 return err;
10556 }
10557 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010558 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010010559}
10560
10561/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010562#define alc262_auto_create_analog_input_ctls \
10563 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010010564
10565/*
10566 * generic initialization of ADC, input mixers and output mixers
10567 */
10568static struct hda_verb alc262_volume_init_verbs[] = {
10569 /*
10570 * Unmute ADC0-2 and set the default input to mic-in
10571 */
10572 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10573 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10574 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10575 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10576 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10577 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10578
Takashi Iwaicb53c622007-08-10 17:21:45 +020010579 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010580 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010581 * Note: PASD motherboards uses the Line In 2 as the input for
10582 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010583 */
10584 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010585 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10586 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10587 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10588 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10589 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010590
10591 /*
10592 * Set up output mixers (0x0c - 0x0f)
10593 */
10594 /* set vol=0 to output mixers */
10595 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10596 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10597 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020010598
Kailang Yangdf694da2005-12-05 19:42:22 +010010599 /* set up input amps for analog loopback */
10600 /* Amp Indices: DAC = 0, mixer = 1 */
10601 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10602 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10603 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10604 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10605 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10606 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10607
10608 /* FIXME: use matrix-type input source selection */
10609 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10610 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10611 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10612 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10613 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10614 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10615 /* Input mixer2 */
10616 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10617 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10618 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10619 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10620 /* Input mixer3 */
10621 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10622 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10623 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10624 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10625
10626 { }
10627};
10628
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010629static struct hda_verb alc262_HP_BPC_init_verbs[] = {
10630 /*
10631 * Unmute ADC0-2 and set the default input to mic-in
10632 */
10633 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10634 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10635 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10636 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10637 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10638 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10639
Takashi Iwaicb53c622007-08-10 17:21:45 +020010640 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010641 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010642 * Note: PASD motherboards uses the Line In 2 as the input for
10643 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010644 */
10645 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010646 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10647 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10648 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10649 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10650 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10651 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10652 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020010653
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010654 /*
10655 * Set up output mixers (0x0c - 0x0e)
10656 */
10657 /* set vol=0 to output mixers */
10658 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10659 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10660 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10661
10662 /* set up input amps for analog loopback */
10663 /* Amp Indices: DAC = 0, mixer = 1 */
10664 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10665 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10666 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10667 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10668 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10669 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10670
Takashi Iwaice875f02008-01-28 18:17:43 +010010671 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010672 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10673 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10674
10675 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10676 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10677
10678 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10679 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10680
10681 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10682 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10683 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10684 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10685 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10686
10687 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10688 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10689 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10690 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10691 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10692 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10693
10694
10695 /* FIXME: use matrix-type input source selection */
10696 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10697 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10698 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10699 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10700 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10701 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10702 /* Input mixer2 */
10703 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10704 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10705 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10706 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10707 /* Input mixer3 */
10708 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10709 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10710 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10711 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10712
Takashi Iwaice875f02008-01-28 18:17:43 +010010713 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10714
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010715 { }
10716};
10717
Kailang Yangcd7509a2007-01-26 18:33:17 +010010718static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
10719 /*
10720 * Unmute ADC0-2 and set the default input to mic-in
10721 */
10722 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10723 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10724 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10725 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10726 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10727 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10728
Takashi Iwaicb53c622007-08-10 17:21:45 +020010729 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010010730 * mixer widget
10731 * Note: PASD motherboards uses the Line In 2 as the input for front
10732 * panel mic (mic 2)
10733 */
10734 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010735 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10736 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10737 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10738 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10739 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10740 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10741 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10742 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010010743 /*
10744 * Set up output mixers (0x0c - 0x0e)
10745 */
10746 /* set vol=0 to output mixers */
10747 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10748 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10749 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10750
10751 /* set up input amps for analog loopback */
10752 /* Amp Indices: DAC = 0, mixer = 1 */
10753 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10754 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10755 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10756 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10757 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10758 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10759
10760
10761 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
10762 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
10763 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
10764 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
10765 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10766 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
10767 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
10768
10769 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10770 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10771
10772 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10773 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
10774
10775 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
10776 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10777 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10778 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10779 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10780 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10781
10782 /* FIXME: use matrix-type input source selection */
10783 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10784 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10785 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
10786 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
10787 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
10788 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
10789 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
10790 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10791 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
10792 /* Input mixer2 */
10793 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10794 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10795 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10796 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10797 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10798 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10799 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10800 /* Input mixer3 */
10801 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10802 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10803 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10804 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10805 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10806 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10807 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10808
Takashi Iwaice875f02008-01-28 18:17:43 +010010809 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10810
Kailang Yangcd7509a2007-01-26 18:33:17 +010010811 { }
10812};
10813
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010814static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
10815
10816 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
10817 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10818 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
10819
10820 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
10821 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10822 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10823 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10824
10825 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
10826 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10827 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10828 {}
10829};
10830
10831
Takashi Iwaicb53c622007-08-10 17:21:45 +020010832#ifdef CONFIG_SND_HDA_POWER_SAVE
10833#define alc262_loopbacks alc880_loopbacks
10834#endif
10835
Kailang Yangdf694da2005-12-05 19:42:22 +010010836/* pcm configuration: identiacal with ALC880 */
10837#define alc262_pcm_analog_playback alc880_pcm_analog_playback
10838#define alc262_pcm_analog_capture alc880_pcm_analog_capture
10839#define alc262_pcm_digital_playback alc880_pcm_digital_playback
10840#define alc262_pcm_digital_capture alc880_pcm_digital_capture
10841
10842/*
10843 * BIOS auto configuration
10844 */
10845static int alc262_parse_auto_config(struct hda_codec *codec)
10846{
10847 struct alc_spec *spec = codec->spec;
10848 int err;
10849 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
10850
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010851 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10852 alc262_ignore);
10853 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010854 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010855 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010010856 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010857 spec->multiout.max_channels = 2;
10858 spec->no_analog = 1;
10859 goto dig_only;
10860 }
Kailang Yangdf694da2005-12-05 19:42:22 +010010861 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010862 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010863 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
10864 if (err < 0)
10865 return err;
10866 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
10867 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010868 return err;
10869
10870 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10871
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010872 dig_only:
Takashi Iwai0852d7a2009-02-11 11:35:15 +010010873 if (spec->autocfg.dig_outs) {
Kailang Yangdf694da2005-12-05 19:42:22 +010010874 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
Takashi Iwai0852d7a2009-02-11 11:35:15 +010010875 spec->dig_out_type = spec->autocfg.dig_out_type[0];
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010876 }
Kailang Yangdf694da2005-12-05 19:42:22 +010010877 if (spec->autocfg.dig_in_pin)
10878 spec->dig_in_nid = ALC262_DIGIN_NID;
10879
Takashi Iwai603c4012008-07-30 15:01:44 +020010880 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010010881 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010010882
Takashi Iwaid88897e2008-10-31 15:01:37 +010010883 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020010884 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020010885 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010886
Takashi Iwai776e1842007-08-29 15:07:11 +020010887 err = alc_auto_add_mic_boost(codec);
10888 if (err < 0)
10889 return err;
10890
Takashi Iwai4a79ba32009-04-22 16:31:35 +020010891 alc_ssid_check(codec, 0x15, 0x14, 0x1b);
10892
Kailang Yangdf694da2005-12-05 19:42:22 +010010893 return 1;
10894}
10895
10896#define alc262_auto_init_multi_out alc882_auto_init_multi_out
10897#define alc262_auto_init_hp_out alc882_auto_init_hp_out
10898#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020010899#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010010900
10901
10902/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010903static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010010904{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010905 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010010906 alc262_auto_init_multi_out(codec);
10907 alc262_auto_init_hp_out(codec);
10908 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020010909 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010910 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020010911 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010010912}
10913
10914/*
10915 * configuration and preset
10916 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010917static const char *alc262_models[ALC262_MODEL_LAST] = {
10918 [ALC262_BASIC] = "basic",
10919 [ALC262_HIPPO] = "hippo",
10920 [ALC262_HIPPO_1] = "hippo_1",
10921 [ALC262_FUJITSU] = "fujitsu",
10922 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010010923 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010010924 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010010925 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010926 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020010927 [ALC262_BENQ_T31] = "benq-t31",
10928 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020010929 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010930 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020010931 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010010932 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010933 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000010934 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010935 [ALC262_AUTO] = "auto",
10936};
10937
10938static struct snd_pci_quirk alc262_cfg_tbl[] = {
10939 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010940 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010010941 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
10942 ALC262_HP_BPC),
10943 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
10944 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010010945 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
10946 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010947 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010948 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010949 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010950 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010951 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010952 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010953 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010954 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010955 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
10956 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
10957 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010958 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
10959 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010010960 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010961 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010962 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010963 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010010964 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwaif872a912009-02-26 00:57:01 +010010965 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
10966 ALC262_SONY_ASSAMD),
Akio Idehara36ca6e12008-06-09 22:57:40 +090010967 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010968 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020010969 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010970 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010010971 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000010972 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010010973 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
10974 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110010975 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010010976 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010977 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020010978 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010979 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010010980 {}
10981};
10982
10983static struct alc_config_preset alc262_presets[] = {
10984 [ALC262_BASIC] = {
10985 .mixers = { alc262_base_mixer },
10986 .init_verbs = { alc262_init_verbs },
10987 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10988 .dac_nids = alc262_dac_nids,
10989 .hp_nid = 0x03,
10990 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10991 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010010992 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010010993 },
Kailang Yangccc656c2006-10-17 12:32:26 +020010994 [ALC262_HIPPO] = {
10995 .mixers = { alc262_base_mixer },
10996 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
10997 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10998 .dac_nids = alc262_dac_nids,
10999 .hp_nid = 0x03,
11000 .dig_out_nid = ALC262_DIGOUT_NID,
11001 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11002 .channel_mode = alc262_modes,
11003 .input_mux = &alc262_capture_source,
11004 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020011005 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020011006 },
11007 [ALC262_HIPPO_1] = {
11008 .mixers = { alc262_hippo1_mixer },
11009 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
11010 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11011 .dac_nids = alc262_dac_nids,
11012 .hp_nid = 0x02,
11013 .dig_out_nid = ALC262_DIGOUT_NID,
11014 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11015 .channel_mode = alc262_modes,
11016 .input_mux = &alc262_capture_source,
11017 .unsol_event = alc262_hippo1_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020011018 .init_hook = alc262_hippo1_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020011019 },
Takashi Iwai834be882006-03-01 14:16:17 +010011020 [ALC262_FUJITSU] = {
11021 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011022 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11023 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010011024 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11025 .dac_nids = alc262_dac_nids,
11026 .hp_nid = 0x03,
11027 .dig_out_nid = ALC262_DIGOUT_NID,
11028 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11029 .channel_mode = alc262_modes,
11030 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011031 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011032 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010011033 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011034 [ALC262_HP_BPC] = {
11035 .mixers = { alc262_HP_BPC_mixer },
11036 .init_verbs = { alc262_HP_BPC_init_verbs },
11037 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11038 .dac_nids = alc262_dac_nids,
11039 .hp_nid = 0x03,
11040 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11041 .channel_mode = alc262_modes,
11042 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011043 .unsol_event = alc262_hp_bpc_unsol_event,
11044 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011045 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011046 [ALC262_HP_BPC_D7000_WF] = {
11047 .mixers = { alc262_HP_BPC_WildWest_mixer },
11048 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11049 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11050 .dac_nids = alc262_dac_nids,
11051 .hp_nid = 0x03,
11052 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11053 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011054 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011055 .unsol_event = alc262_hp_wildwest_unsol_event,
11056 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011057 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011058 [ALC262_HP_BPC_D7000_WL] = {
11059 .mixers = { alc262_HP_BPC_WildWest_mixer,
11060 alc262_HP_BPC_WildWest_option_mixer },
11061 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11062 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11063 .dac_nids = alc262_dac_nids,
11064 .hp_nid = 0x03,
11065 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11066 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011067 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011068 .unsol_event = alc262_hp_wildwest_unsol_event,
11069 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011070 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011071 [ALC262_HP_TC_T5735] = {
11072 .mixers = { alc262_hp_t5735_mixer },
11073 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
11074 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11075 .dac_nids = alc262_dac_nids,
11076 .hp_nid = 0x03,
11077 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11078 .channel_mode = alc262_modes,
11079 .input_mux = &alc262_capture_source,
11080 .unsol_event = alc262_hp_t5735_unsol_event,
11081 .init_hook = alc262_hp_t5735_init_hook,
Kailang Yang8c427222008-01-10 13:03:59 +010011082 },
11083 [ALC262_HP_RP5700] = {
11084 .mixers = { alc262_hp_rp5700_mixer },
11085 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
11086 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11087 .dac_nids = alc262_dac_nids,
11088 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11089 .channel_mode = alc262_modes,
11090 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011091 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011092 [ALC262_BENQ_ED8] = {
11093 .mixers = { alc262_base_mixer },
11094 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
11095 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11096 .dac_nids = alc262_dac_nids,
11097 .hp_nid = 0x03,
11098 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11099 .channel_mode = alc262_modes,
11100 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011101 },
Kailang Yang272a5272007-05-14 11:00:38 +020011102 [ALC262_SONY_ASSAMD] = {
11103 .mixers = { alc262_sony_mixer },
11104 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
11105 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11106 .dac_nids = alc262_dac_nids,
11107 .hp_nid = 0x02,
11108 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11109 .channel_mode = alc262_modes,
11110 .input_mux = &alc262_capture_source,
11111 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020011112 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020011113 },
11114 [ALC262_BENQ_T31] = {
11115 .mixers = { alc262_benq_t31_mixer },
11116 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
11117 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11118 .dac_nids = alc262_dac_nids,
11119 .hp_nid = 0x03,
11120 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11121 .channel_mode = alc262_modes,
11122 .input_mux = &alc262_capture_source,
11123 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020011124 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020011125 },
Tobin Davisf651b502007-10-26 12:40:47 +020011126 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011127 .mixers = { alc262_ultra_mixer },
11128 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011129 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020011130 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11131 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020011132 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11133 .channel_mode = alc262_modes,
11134 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011135 .adc_nids = alc262_adc_nids, /* ADC0 */
11136 .capsrc_nids = alc262_capsrc_nids,
11137 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020011138 .unsol_event = alc262_ultra_unsol_event,
11139 .init_hook = alc262_ultra_automute,
11140 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010011141 [ALC262_LENOVO_3000] = {
11142 .mixers = { alc262_lenovo_3000_mixer },
11143 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11144 alc262_lenovo_3000_unsol_verbs },
11145 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11146 .dac_nids = alc262_dac_nids,
11147 .hp_nid = 0x03,
11148 .dig_out_nid = ALC262_DIGOUT_NID,
11149 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11150 .channel_mode = alc262_modes,
11151 .input_mux = &alc262_fujitsu_capture_source,
11152 .unsol_event = alc262_lenovo_3000_unsol_event,
11153 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011154 [ALC262_NEC] = {
11155 .mixers = { alc262_nec_mixer },
11156 .init_verbs = { alc262_nec_verbs },
11157 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11158 .dac_nids = alc262_dac_nids,
11159 .hp_nid = 0x03,
11160 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11161 .channel_mode = alc262_modes,
11162 .input_mux = &alc262_capture_source,
11163 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020011164 [ALC262_TOSHIBA_S06] = {
11165 .mixers = { alc262_toshiba_s06_mixer },
11166 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
11167 alc262_eapd_verbs },
11168 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11169 .capsrc_nids = alc262_dmic_capsrc_nids,
11170 .dac_nids = alc262_dac_nids,
11171 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
11172 .dig_out_nid = ALC262_DIGOUT_NID,
11173 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11174 .channel_mode = alc262_modes,
11175 .input_mux = &alc262_dmic_capture_source,
11176 .unsol_event = alc262_toshiba_s06_unsol_event,
11177 .init_hook = alc262_toshiba_s06_init_hook,
11178 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011179 [ALC262_TOSHIBA_RX1] = {
11180 .mixers = { alc262_toshiba_rx1_mixer },
11181 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
11182 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11183 .dac_nids = alc262_dac_nids,
11184 .hp_nid = 0x03,
11185 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11186 .channel_mode = alc262_modes,
11187 .input_mux = &alc262_capture_source,
11188 .unsol_event = alc262_hippo_unsol_event,
11189 .init_hook = alc262_hippo_automute,
11190 },
Tony Vroonba340e82009-02-02 19:01:30 +000011191 [ALC262_TYAN] = {
11192 .mixers = { alc262_tyan_mixer },
11193 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
11194 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11195 .dac_nids = alc262_dac_nids,
11196 .hp_nid = 0x02,
11197 .dig_out_nid = ALC262_DIGOUT_NID,
11198 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11199 .channel_mode = alc262_modes,
11200 .input_mux = &alc262_capture_source,
11201 .unsol_event = alc262_tyan_unsol_event,
11202 .init_hook = alc262_tyan_automute,
11203 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011204};
11205
11206static int patch_alc262(struct hda_codec *codec)
11207{
11208 struct alc_spec *spec;
11209 int board_config;
11210 int err;
11211
Robert P. J. Daydc041e02006-12-19 14:44:15 +010011212 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010011213 if (spec == NULL)
11214 return -ENOMEM;
11215
11216 codec->spec = spec;
11217#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011218 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
11219 * under-run
11220 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011221 {
11222 int tmp;
11223 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11224 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
11225 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11226 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
11227 }
11228#endif
11229
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020011230 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
11231
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011232 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
11233 alc262_models,
11234 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010011235
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011236 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011237 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
11238 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011239 board_config = ALC262_AUTO;
11240 }
11241
11242 if (board_config == ALC262_AUTO) {
11243 /* automatic parse from the BIOS config */
11244 err = alc262_parse_auto_config(codec);
11245 if (err < 0) {
11246 alc_free(codec);
11247 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011248 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011249 printk(KERN_INFO
11250 "hda_codec: Cannot set up configuration "
11251 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011252 board_config = ALC262_BASIC;
11253 }
11254 }
11255
Takashi Iwai07eba612009-02-19 08:06:35 +010011256 if (!spec->no_analog) {
11257 err = snd_hda_attach_beep_device(codec, 0x1);
11258 if (err < 0) {
11259 alc_free(codec);
11260 return err;
11261 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090011262 }
11263
Kailang Yangdf694da2005-12-05 19:42:22 +010011264 if (board_config != ALC262_AUTO)
11265 setup_preset(spec, &alc262_presets[board_config]);
11266
11267 spec->stream_name_analog = "ALC262 Analog";
11268 spec->stream_analog_playback = &alc262_pcm_analog_playback;
11269 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020011270
Kailang Yangdf694da2005-12-05 19:42:22 +010011271 spec->stream_name_digital = "ALC262 Digital";
11272 spec->stream_digital_playback = &alc262_pcm_digital_playback;
11273 spec->stream_digital_capture = &alc262_pcm_digital_capture;
11274
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011275 spec->capture_style = CAPT_MIX;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011276 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011277 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +010011278 unsigned int wcap = get_wcaps(codec, 0x07);
11279
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011280 /* get type */
11281 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +010011282 if (wcap != AC_WID_AUD_IN) {
11283 spec->adc_nids = alc262_adc_nids_alt;
11284 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwai88c71a92008-02-14 17:27:17 +010011285 spec->capsrc_nids = alc262_capsrc_nids_alt;
Kailang Yangdf694da2005-12-05 19:42:22 +010011286 } else {
11287 spec->adc_nids = alc262_adc_nids;
11288 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
Takashi Iwai88c71a92008-02-14 17:27:17 +010011289 spec->capsrc_nids = alc262_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010011290 }
11291 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011292 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011293 set_capture_mixer(spec);
Takashi Iwai07eba612009-02-19 08:06:35 +010011294 if (!spec->no_analog)
11295 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010011296
Takashi Iwai2134ea42008-01-10 16:53:55 +010011297 spec->vmaster_nid = 0x0c;
11298
Kailang Yangdf694da2005-12-05 19:42:22 +010011299 codec->patch_ops = alc_patch_ops;
11300 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011301 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011302#ifdef CONFIG_SND_HDA_POWER_SAVE
11303 if (!spec->loopback.amplist)
11304 spec->loopback.amplist = alc262_loopbacks;
11305#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010011306 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020011307
Kailang Yangdf694da2005-12-05 19:42:22 +010011308 return 0;
11309}
11310
Kailang Yangdf694da2005-12-05 19:42:22 +010011311/*
Kailang Yanga361d842007-06-05 12:30:55 +020011312 * ALC268 channel source setting (2 channel)
11313 */
11314#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
11315#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020011316
Kailang Yanga361d842007-06-05 12:30:55 +020011317static hda_nid_t alc268_dac_nids[2] = {
11318 /* front, hp */
11319 0x02, 0x03
11320};
11321
11322static hda_nid_t alc268_adc_nids[2] = {
11323 /* ADC0-1 */
11324 0x08, 0x07
11325};
11326
11327static hda_nid_t alc268_adc_nids_alt[1] = {
11328 /* ADC0 */
11329 0x08
11330};
11331
Takashi Iwaie1406342008-02-11 18:32:32 +010011332static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
11333
Kailang Yanga361d842007-06-05 12:30:55 +020011334static struct snd_kcontrol_new alc268_base_mixer[] = {
11335 /* output mixer control */
11336 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11337 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11338 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11339 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011340 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11341 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11342 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020011343 { }
11344};
11345
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011346/* bind Beep switches of both NID 0x0f and 0x10 */
11347static struct hda_bind_ctls alc268_bind_beep_sw = {
11348 .ops = &snd_hda_bind_sw,
11349 .values = {
11350 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
11351 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
11352 0
11353 },
11354};
11355
11356static struct snd_kcontrol_new alc268_beep_mixer[] = {
11357 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
11358 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
11359 { }
11360};
11361
Kailang Yangd1a991a2007-08-15 16:21:59 +020011362static struct hda_verb alc268_eapd_verbs[] = {
11363 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11364 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11365 { }
11366};
11367
Takashi Iwaid2738092007-08-16 14:59:45 +020011368/* Toshiba specific */
11369#define alc268_toshiba_automute alc262_hippo_automute
11370
11371static struct hda_verb alc268_toshiba_verbs[] = {
11372 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11373 { } /* end */
11374};
11375
Kailang Yang8ef355d2008-08-26 13:10:22 +020011376static struct hda_input_mux alc268_acer_lc_capture_source = {
11377 .num_items = 2,
11378 .items = {
11379 { "i-Mic", 0x6 },
11380 { "E-Mic", 0x0 },
11381 },
11382};
11383
Takashi Iwaid2738092007-08-16 14:59:45 +020011384/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020011385/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020011386static struct hda_bind_ctls alc268_acer_bind_master_vol = {
11387 .ops = &snd_hda_bind_vol,
11388 .values = {
11389 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
11390 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
11391 0
11392 },
11393};
11394
Takashi Iwai889c4392007-08-23 18:56:52 +020011395/* mute/unmute internal speaker according to the hp jack and mute state */
11396static void alc268_acer_automute(struct hda_codec *codec, int force)
11397{
11398 struct alc_spec *spec = codec->spec;
11399 unsigned int mute;
11400
11401 if (force || !spec->sense_updated) {
11402 unsigned int present;
11403 present = snd_hda_codec_read(codec, 0x14, 0,
11404 AC_VERB_GET_PIN_SENSE, 0);
11405 spec->jack_present = (present & 0x80000000) != 0;
11406 spec->sense_updated = 1;
11407 }
11408 if (spec->jack_present)
11409 mute = HDA_AMP_MUTE; /* mute internal speaker */
11410 else /* unmute internal speaker if necessary */
11411 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
11412 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11413 HDA_AMP_MUTE, mute);
11414}
11415
11416
11417/* bind hp and internal speaker mute (with plug check) */
11418static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
11419 struct snd_ctl_elem_value *ucontrol)
11420{
11421 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11422 long *valp = ucontrol->value.integer.value;
11423 int change;
11424
11425 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
11426 HDA_AMP_MUTE,
11427 valp[0] ? 0 : HDA_AMP_MUTE);
11428 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
11429 HDA_AMP_MUTE,
11430 valp[1] ? 0 : HDA_AMP_MUTE);
11431 if (change)
11432 alc268_acer_automute(codec, 0);
11433 return change;
11434}
Takashi Iwaid2738092007-08-16 14:59:45 +020011435
Kailang Yang8ef355d2008-08-26 13:10:22 +020011436static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
11437 /* output mixer control */
11438 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11439 {
11440 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11441 .name = "Master Playback Switch",
11442 .info = snd_hda_mixer_amp_switch_info,
11443 .get = snd_hda_mixer_amp_switch_get,
11444 .put = alc268_acer_master_sw_put,
11445 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11446 },
11447 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
11448 { }
11449};
11450
Takashi Iwaid2738092007-08-16 14:59:45 +020011451static struct snd_kcontrol_new alc268_acer_mixer[] = {
11452 /* output mixer control */
11453 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11454 {
11455 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11456 .name = "Master Playback Switch",
11457 .info = snd_hda_mixer_amp_switch_info,
11458 .get = snd_hda_mixer_amp_switch_get,
11459 .put = alc268_acer_master_sw_put,
11460 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11461 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011462 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11463 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11464 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020011465 { }
11466};
11467
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011468static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
11469 /* output mixer control */
11470 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11471 {
11472 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11473 .name = "Master Playback Switch",
11474 .info = snd_hda_mixer_amp_switch_info,
11475 .get = snd_hda_mixer_amp_switch_get,
11476 .put = alc268_acer_master_sw_put,
11477 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11478 },
11479 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11480 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11481 { }
11482};
11483
Kailang Yang8ef355d2008-08-26 13:10:22 +020011484static struct hda_verb alc268_acer_aspire_one_verbs[] = {
11485 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11486 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11487 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11488 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11489 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
11490 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
11491 { }
11492};
11493
Takashi Iwaid2738092007-08-16 14:59:45 +020011494static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011495 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
11496 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020011497 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11498 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011499 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11500 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020011501 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11502 { }
11503};
11504
11505/* unsolicited event for HP jack sensing */
11506static void alc268_toshiba_unsol_event(struct hda_codec *codec,
11507 unsigned int res)
11508{
Takashi Iwai889c4392007-08-23 18:56:52 +020011509 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020011510 return;
11511 alc268_toshiba_automute(codec);
11512}
11513
11514static void alc268_acer_unsol_event(struct hda_codec *codec,
11515 unsigned int res)
11516{
Takashi Iwai889c4392007-08-23 18:56:52 +020011517 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020011518 return;
11519 alc268_acer_automute(codec, 1);
11520}
11521
Takashi Iwai889c4392007-08-23 18:56:52 +020011522static void alc268_acer_init_hook(struct hda_codec *codec)
11523{
11524 alc268_acer_automute(codec, 1);
11525}
11526
Kailang Yang8ef355d2008-08-26 13:10:22 +020011527/* toggle speaker-output according to the hp-jack state */
11528static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
11529{
11530 unsigned int present;
11531 unsigned char bits;
11532
11533 present = snd_hda_codec_read(codec, 0x15, 0,
11534 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11535 bits = present ? AMP_IN_MUTE(0) : 0;
11536 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
11537 AMP_IN_MUTE(0), bits);
11538 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
11539 AMP_IN_MUTE(0), bits);
11540}
11541
11542
11543static void alc268_acer_mic_automute(struct hda_codec *codec)
11544{
11545 unsigned int present;
11546
11547 present = snd_hda_codec_read(codec, 0x18, 0,
11548 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11549 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_CONNECT_SEL,
11550 present ? 0x0 : 0x6);
11551}
11552
11553static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
11554 unsigned int res)
11555{
11556 if ((res >> 26) == ALC880_HP_EVENT)
11557 alc268_aspire_one_speaker_automute(codec);
11558 if ((res >> 26) == ALC880_MIC_EVENT)
11559 alc268_acer_mic_automute(codec);
11560}
11561
11562static void alc268_acer_lc_init_hook(struct hda_codec *codec)
11563{
11564 alc268_aspire_one_speaker_automute(codec);
11565 alc268_acer_mic_automute(codec);
11566}
11567
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011568static struct snd_kcontrol_new alc268_dell_mixer[] = {
11569 /* output mixer control */
11570 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11571 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11572 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11573 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11574 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11575 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11576 { }
11577};
11578
11579static struct hda_verb alc268_dell_verbs[] = {
11580 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11581 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11582 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11583 { }
11584};
11585
11586/* mute/unmute internal speaker according to the hp jack and mute state */
11587static void alc268_dell_automute(struct hda_codec *codec)
11588{
11589 unsigned int present;
11590 unsigned int mute;
11591
11592 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0);
11593 if (present & 0x80000000)
11594 mute = HDA_AMP_MUTE;
11595 else
11596 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
11597 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11598 HDA_AMP_MUTE, mute);
11599}
11600
11601static void alc268_dell_unsol_event(struct hda_codec *codec,
11602 unsigned int res)
11603{
11604 if ((res >> 26) != ALC880_HP_EVENT)
11605 return;
11606 alc268_dell_automute(codec);
11607}
11608
11609#define alc268_dell_init_hook alc268_dell_automute
11610
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011611static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
11612 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11613 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11614 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11615 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11616 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11617 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
11618 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
11619 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11620 { }
11621};
11622
11623static struct hda_verb alc267_quanta_il1_verbs[] = {
11624 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11625 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
11626 { }
11627};
11628
11629static void alc267_quanta_il1_hp_automute(struct hda_codec *codec)
11630{
11631 unsigned int present;
11632
11633 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
11634 & AC_PINSENSE_PRESENCE;
11635 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
11636 present ? 0 : PIN_OUT);
11637}
11638
11639static void alc267_quanta_il1_mic_automute(struct hda_codec *codec)
11640{
11641 unsigned int present;
11642
11643 present = snd_hda_codec_read(codec, 0x18, 0,
11644 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11645 snd_hda_codec_write(codec, 0x23, 0,
11646 AC_VERB_SET_CONNECT_SEL,
11647 present ? 0x00 : 0x01);
11648}
11649
11650static void alc267_quanta_il1_automute(struct hda_codec *codec)
11651{
11652 alc267_quanta_il1_hp_automute(codec);
11653 alc267_quanta_il1_mic_automute(codec);
11654}
11655
11656static void alc267_quanta_il1_unsol_event(struct hda_codec *codec,
11657 unsigned int res)
11658{
11659 switch (res >> 26) {
11660 case ALC880_HP_EVENT:
11661 alc267_quanta_il1_hp_automute(codec);
11662 break;
11663 case ALC880_MIC_EVENT:
11664 alc267_quanta_il1_mic_automute(codec);
11665 break;
11666 }
11667}
11668
Kailang Yanga361d842007-06-05 12:30:55 +020011669/*
11670 * generic initialization of ADC, input mixers and output mixers
11671 */
11672static struct hda_verb alc268_base_init_verbs[] = {
11673 /* Unmute DAC0-1 and set vol = 0 */
11674 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011675 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011676
11677 /*
11678 * Set up output mixers (0x0c - 0x0e)
11679 */
11680 /* set vol=0 to output mixers */
11681 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020011682 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
11683
11684 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11685 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11686
11687 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11688 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11689 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11690 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11691 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11692 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11693 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11694 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11695
11696 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11697 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11698 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11699 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011700 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011701
11702 /* set PCBEEP vol = 0, mute connections */
11703 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11704 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11705 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020011706
Jiang Zhea9b3aa82007-12-20 13:13:13 +010011707 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020011708
Jiang Zhea9b3aa82007-12-20 13:13:13 +010011709 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
11710 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11711 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
11712 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011713
Kailang Yanga361d842007-06-05 12:30:55 +020011714 { }
11715};
11716
11717/*
11718 * generic initialization of ADC, input mixers and output mixers
11719 */
11720static struct hda_verb alc268_volume_init_verbs[] = {
11721 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010011722 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11723 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011724
11725 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11726 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11727 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11728 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11729 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11730
Kailang Yanga361d842007-06-05 12:30:55 +020011731 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020011732 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11733 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11734
11735 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011736 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011737
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011738 /* set PCBEEP vol = 0, mute connections */
11739 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11740 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11741 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020011742
11743 { }
11744};
11745
Kailang Yanga361d842007-06-05 12:30:55 +020011746static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
11747 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11748 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11749 {
11750 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11751 /* The multiple "Capture Source" controls confuse alsamixer
11752 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020011753 */
11754 /* .name = "Capture Source", */
11755 .name = "Input Source",
11756 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011757 .info = alc_mux_enum_info,
11758 .get = alc_mux_enum_get,
11759 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020011760 },
11761 { } /* end */
11762};
11763
11764static struct snd_kcontrol_new alc268_capture_mixer[] = {
11765 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11766 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11767 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
11768 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
11769 {
11770 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11771 /* The multiple "Capture Source" controls confuse alsamixer
11772 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020011773 */
11774 /* .name = "Capture Source", */
11775 .name = "Input Source",
11776 .count = 2,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011777 .info = alc_mux_enum_info,
11778 .get = alc_mux_enum_get,
11779 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020011780 },
11781 { } /* end */
11782};
11783
11784static struct hda_input_mux alc268_capture_source = {
11785 .num_items = 4,
11786 .items = {
11787 { "Mic", 0x0 },
11788 { "Front Mic", 0x1 },
11789 { "Line", 0x2 },
11790 { "CD", 0x3 },
11791 },
11792};
11793
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011794static struct hda_input_mux alc268_acer_capture_source = {
11795 .num_items = 3,
11796 .items = {
11797 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011798 { "Internal Mic", 0x1 },
11799 { "Line", 0x2 },
11800 },
11801};
11802
11803static struct hda_input_mux alc268_acer_dmic_capture_source = {
11804 .num_items = 3,
11805 .items = {
11806 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011807 { "Internal Mic", 0x6 },
11808 { "Line", 0x2 },
11809 },
11810};
11811
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011812#ifdef CONFIG_SND_DEBUG
11813static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011814 /* Volume widgets */
11815 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11816 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11817 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
11818 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
11819 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
11820 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
11821 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
11822 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
11823 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
11824 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
11825 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
11826 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
11827 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010011828 /* The below appears problematic on some hardwares */
11829 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011830 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11831 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
11832 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
11833 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
11834
11835 /* Modes for retasking pin widgets */
11836 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
11837 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
11838 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
11839 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
11840
11841 /* Controls for GPIO pins, assuming they are configured as outputs */
11842 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
11843 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
11844 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
11845 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
11846
11847 /* Switches to allow the digital SPDIF output pin to be enabled.
11848 * The ALC268 does not have an SPDIF input.
11849 */
11850 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
11851
11852 /* A switch allowing EAPD to be enabled. Some laptops seem to use
11853 * this output to turn on an external amplifier.
11854 */
11855 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
11856 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
11857
11858 { } /* end */
11859};
11860#endif
11861
Kailang Yanga361d842007-06-05 12:30:55 +020011862/* create input playback/capture controls for the given pin */
11863static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
11864 const char *ctlname, int idx)
11865{
11866 char name[32];
11867 int err;
11868
11869 sprintf(name, "%s Playback Volume", ctlname);
11870 if (nid == 0x14) {
11871 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11872 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
11873 HDA_OUTPUT));
11874 if (err < 0)
11875 return err;
11876 } else if (nid == 0x15) {
11877 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11878 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
11879 HDA_OUTPUT));
11880 if (err < 0)
11881 return err;
11882 } else
11883 return -1;
11884 sprintf(name, "%s Playback Switch", ctlname);
11885 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
11886 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
11887 if (err < 0)
11888 return err;
11889 return 0;
11890}
11891
11892/* add playback controls from the parsed DAC table */
11893static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
11894 const struct auto_pin_cfg *cfg)
11895{
11896 hda_nid_t nid;
11897 int err;
11898
11899 spec->multiout.num_dacs = 2; /* only use one dac */
11900 spec->multiout.dac_nids = spec->private_dac_nids;
11901 spec->multiout.dac_nids[0] = 2;
11902 spec->multiout.dac_nids[1] = 3;
11903
11904 nid = cfg->line_out_pins[0];
11905 if (nid)
Kailang Yangea1fb292008-08-26 12:58:38 +020011906 alc268_new_analog_output(spec, nid, "Front", 0);
Kailang Yanga361d842007-06-05 12:30:55 +020011907
11908 nid = cfg->speaker_pins[0];
11909 if (nid == 0x1d) {
11910 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11911 "Speaker Playback Volume",
11912 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
11913 if (err < 0)
11914 return err;
11915 }
11916 nid = cfg->hp_pins[0];
11917 if (nid)
11918 alc268_new_analog_output(spec, nid, "Headphone", 0);
11919
11920 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
11921 if (nid == 0x16) {
11922 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11923 "Mono Playback Switch",
11924 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
11925 if (err < 0)
11926 return err;
11927 }
Kailang Yangea1fb292008-08-26 12:58:38 +020011928 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020011929}
11930
11931/* create playback/capture controls for input pins */
11932static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
11933 const struct auto_pin_cfg *cfg)
11934{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011935 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020011936 int i, idx1;
11937
11938 for (i = 0; i < AUTO_PIN_LAST; i++) {
11939 switch(cfg->input_pins[i]) {
11940 case 0x18:
11941 idx1 = 0; /* Mic 1 */
11942 break;
11943 case 0x19:
11944 idx1 = 1; /* Mic 2 */
11945 break;
11946 case 0x1a:
11947 idx1 = 2; /* Line In */
11948 break;
Kailang Yangea1fb292008-08-26 12:58:38 +020011949 case 0x1c:
Kailang Yanga361d842007-06-05 12:30:55 +020011950 idx1 = 3; /* CD */
11951 break;
Takashi Iwai7194cae2008-03-06 16:58:17 +010011952 case 0x12:
11953 case 0x13:
11954 idx1 = 6; /* digital mics */
11955 break;
Kailang Yanga361d842007-06-05 12:30:55 +020011956 default:
11957 continue;
11958 }
11959 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
11960 imux->items[imux->num_items].index = idx1;
Kailang Yangea1fb292008-08-26 12:58:38 +020011961 imux->num_items++;
Kailang Yanga361d842007-06-05 12:30:55 +020011962 }
11963 return 0;
11964}
11965
11966static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
11967{
11968 struct alc_spec *spec = codec->spec;
11969 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
11970 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
11971 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
11972 unsigned int dac_vol1, dac_vol2;
11973
11974 if (speaker_nid) {
11975 snd_hda_codec_write(codec, speaker_nid, 0,
11976 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
11977 snd_hda_codec_write(codec, 0x0f, 0,
11978 AC_VERB_SET_AMP_GAIN_MUTE,
11979 AMP_IN_UNMUTE(1));
11980 snd_hda_codec_write(codec, 0x10, 0,
11981 AC_VERB_SET_AMP_GAIN_MUTE,
11982 AMP_IN_UNMUTE(1));
11983 } else {
11984 snd_hda_codec_write(codec, 0x0f, 0,
11985 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
11986 snd_hda_codec_write(codec, 0x10, 0,
11987 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
11988 }
11989
11990 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020011991 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020011992 dac_vol2 = AMP_OUT_ZERO;
11993 else if (line_nid == 0x15)
11994 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020011995 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020011996 dac_vol2 = AMP_OUT_ZERO;
11997 else if (hp_nid == 0x15)
11998 dac_vol1 = AMP_OUT_ZERO;
11999 if (line_nid != 0x16 || hp_nid != 0x16 ||
12000 spec->autocfg.line_out_pins[1] != 0x16 ||
12001 spec->autocfg.line_out_pins[2] != 0x16)
12002 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
12003
12004 snd_hda_codec_write(codec, 0x02, 0,
12005 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
12006 snd_hda_codec_write(codec, 0x03, 0,
12007 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
12008}
12009
12010/* pcm configuration: identiacal with ALC880 */
12011#define alc268_pcm_analog_playback alc880_pcm_analog_playback
12012#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010012013#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020012014#define alc268_pcm_digital_playback alc880_pcm_digital_playback
12015
12016/*
12017 * BIOS auto configuration
12018 */
12019static int alc268_parse_auto_config(struct hda_codec *codec)
12020{
12021 struct alc_spec *spec = codec->spec;
12022 int err;
12023 static hda_nid_t alc268_ignore[] = { 0 };
12024
12025 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12026 alc268_ignore);
12027 if (err < 0)
12028 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012029 if (!spec->autocfg.line_outs) {
12030 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
12031 spec->multiout.max_channels = 2;
12032 spec->no_analog = 1;
12033 goto dig_only;
12034 }
Kailang Yanga361d842007-06-05 12:30:55 +020012035 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012036 }
Kailang Yanga361d842007-06-05 12:30:55 +020012037 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
12038 if (err < 0)
12039 return err;
12040 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
12041 if (err < 0)
12042 return err;
12043
12044 spec->multiout.max_channels = 2;
12045
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012046 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020012047 /* digital only support output */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012048 if (spec->autocfg.dig_outs) {
Kailang Yanga361d842007-06-05 12:30:55 +020012049 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012050 spec->dig_out_type = spec->autocfg.dig_out_type[0];
12051 }
Takashi Iwai603c4012008-07-30 15:01:44 +020012052 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012053 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020012054
Takashi Iwai892981f2009-03-02 08:04:35 +010012055 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012056 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012057
Takashi Iwaid88897e2008-10-31 15:01:37 +010012058 add_verb(spec, alc268_volume_init_verbs);
Kailang Yanga361d842007-06-05 12:30:55 +020012059 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012060 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020012061
Takashi Iwai776e1842007-08-29 15:07:11 +020012062 err = alc_auto_add_mic_boost(codec);
12063 if (err < 0)
12064 return err;
12065
Kailang Yanga361d842007-06-05 12:30:55 +020012066 return 1;
12067}
12068
12069#define alc268_auto_init_multi_out alc882_auto_init_multi_out
12070#define alc268_auto_init_hp_out alc882_auto_init_hp_out
12071#define alc268_auto_init_analog_input alc882_auto_init_analog_input
12072
12073/* init callback for auto-configuration model -- overriding the default init */
12074static void alc268_auto_init(struct hda_codec *codec)
12075{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012076 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020012077 alc268_auto_init_multi_out(codec);
12078 alc268_auto_init_hp_out(codec);
12079 alc268_auto_init_mono_speaker_out(codec);
12080 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012081 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012082 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020012083}
12084
12085/*
12086 * configuration and preset
12087 */
12088static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012089 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020012090 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012091 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020012092 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012093 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020012094 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012095 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012096 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012097#ifdef CONFIG_SND_DEBUG
12098 [ALC268_TEST] = "test",
12099#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012100 [ALC268_AUTO] = "auto",
12101};
12102
12103static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020012104 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012105 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010012106 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012107 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010012108 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020012109 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
12110 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012111 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Takashi Iwai57d13922009-01-08 15:52:09 +010012112 SND_PCI_QUIRK(0x1028, 0x02b0, "Dell Inspiron Mini9", ALC268_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012113 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
Kailang Yanga361d842007-06-05 12:30:55 +020012114 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Kailang Yangd1a991a2007-08-15 16:21:59 +020012115 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
Takashi Iwai8e7f00f2007-09-07 10:58:58 +020012116 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
Travis Place2346d0c2008-09-01 08:24:00 +020012117 SND_PCI_QUIRK(0x1179, 0xff64, "TOSHIBA L305", ALC268_TOSHIBA),
Tony Vroon378bd6a2008-06-04 12:08:30 +020012118 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020012119 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012120 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012121 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Kailang Yanga361d842007-06-05 12:30:55 +020012122 {}
12123};
12124
12125static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012126 [ALC267_QUANTA_IL1] = {
Takashi Iwai22971e32009-02-10 11:56:44 +010012127 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012128 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12129 alc267_quanta_il1_verbs },
12130 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12131 .dac_nids = alc268_dac_nids,
12132 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12133 .adc_nids = alc268_adc_nids_alt,
12134 .hp_nid = 0x03,
12135 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12136 .channel_mode = alc268_modes,
12137 .input_mux = &alc268_capture_source,
12138 .unsol_event = alc267_quanta_il1_unsol_event,
12139 .init_hook = alc267_quanta_il1_automute,
12140 },
Kailang Yanga361d842007-06-05 12:30:55 +020012141 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012142 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12143 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020012144 .init_verbs = { alc268_base_init_verbs },
12145 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12146 .dac_nids = alc268_dac_nids,
12147 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12148 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012149 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020012150 .hp_nid = 0x03,
12151 .dig_out_nid = ALC268_DIGOUT_NID,
12152 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12153 .channel_mode = alc268_modes,
12154 .input_mux = &alc268_capture_source,
12155 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012156 [ALC268_TOSHIBA] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012157 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12158 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012159 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12160 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012161 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12162 .dac_nids = alc268_dac_nids,
12163 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12164 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012165 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012166 .hp_nid = 0x03,
12167 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12168 .channel_mode = alc268_modes,
12169 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012170 .unsol_event = alc268_toshiba_unsol_event,
12171 .init_hook = alc268_toshiba_automute,
12172 },
12173 [ALC268_ACER] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012174 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
12175 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012176 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12177 alc268_acer_verbs },
12178 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12179 .dac_nids = alc268_dac_nids,
12180 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12181 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012182 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020012183 .hp_nid = 0x02,
12184 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12185 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012186 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012187 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020012188 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012189 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012190 [ALC268_ACER_DMIC] = {
12191 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
12192 alc268_beep_mixer },
12193 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12194 alc268_acer_verbs },
12195 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12196 .dac_nids = alc268_dac_nids,
12197 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12198 .adc_nids = alc268_adc_nids_alt,
12199 .capsrc_nids = alc268_capsrc_nids,
12200 .hp_nid = 0x02,
12201 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12202 .channel_mode = alc268_modes,
12203 .input_mux = &alc268_acer_dmic_capture_source,
12204 .unsol_event = alc268_acer_unsol_event,
12205 .init_hook = alc268_acer_init_hook,
12206 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012207 [ALC268_ACER_ASPIRE_ONE] = {
12208 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010012209 alc268_beep_mixer,
12210 alc268_capture_alt_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012211 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12212 alc268_acer_aspire_one_verbs },
12213 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12214 .dac_nids = alc268_dac_nids,
12215 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12216 .adc_nids = alc268_adc_nids_alt,
12217 .capsrc_nids = alc268_capsrc_nids,
12218 .hp_nid = 0x03,
12219 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12220 .channel_mode = alc268_modes,
12221 .input_mux = &alc268_acer_lc_capture_source,
12222 .unsol_event = alc268_acer_lc_unsol_event,
12223 .init_hook = alc268_acer_lc_init_hook,
12224 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012225 [ALC268_DELL] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012226 .mixers = { alc268_dell_mixer, alc268_beep_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012227 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12228 alc268_dell_verbs },
12229 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12230 .dac_nids = alc268_dac_nids,
12231 .hp_nid = 0x02,
12232 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12233 .channel_mode = alc268_modes,
12234 .unsol_event = alc268_dell_unsol_event,
12235 .init_hook = alc268_dell_init_hook,
12236 .input_mux = &alc268_capture_source,
12237 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012238 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012239 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12240 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012241 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12242 alc268_toshiba_verbs },
12243 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12244 .dac_nids = alc268_dac_nids,
12245 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12246 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012247 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012248 .hp_nid = 0x03,
12249 .dig_out_nid = ALC268_DIGOUT_NID,
12250 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12251 .channel_mode = alc268_modes,
12252 .input_mux = &alc268_capture_source,
12253 .unsol_event = alc268_toshiba_unsol_event,
12254 .init_hook = alc268_toshiba_automute
12255 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012256#ifdef CONFIG_SND_DEBUG
12257 [ALC268_TEST] = {
12258 .mixers = { alc268_test_mixer, alc268_capture_mixer },
12259 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12260 alc268_volume_init_verbs },
12261 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12262 .dac_nids = alc268_dac_nids,
12263 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12264 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012265 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012266 .hp_nid = 0x03,
12267 .dig_out_nid = ALC268_DIGOUT_NID,
12268 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12269 .channel_mode = alc268_modes,
12270 .input_mux = &alc268_capture_source,
12271 },
12272#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012273};
12274
12275static int patch_alc268(struct hda_codec *codec)
12276{
12277 struct alc_spec *spec;
12278 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010012279 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020012280
12281 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
12282 if (spec == NULL)
12283 return -ENOMEM;
12284
12285 codec->spec = spec;
12286
12287 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
12288 alc268_models,
12289 alc268_cfg_tbl);
12290
12291 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
12292 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
12293 "trying auto-probe from BIOS...\n");
12294 board_config = ALC268_AUTO;
12295 }
12296
12297 if (board_config == ALC268_AUTO) {
12298 /* automatic parse from the BIOS config */
12299 err = alc268_parse_auto_config(codec);
12300 if (err < 0) {
12301 alc_free(codec);
12302 return err;
12303 } else if (!err) {
12304 printk(KERN_INFO
12305 "hda_codec: Cannot set up configuration "
12306 "from BIOS. Using base mode...\n");
12307 board_config = ALC268_3ST;
12308 }
12309 }
12310
12311 if (board_config != ALC268_AUTO)
12312 setup_preset(spec, &alc268_presets[board_config]);
12313
Kailang Yang2f893282008-05-27 12:14:47 +020012314 if (codec->vendor_id == 0x10ec0267) {
12315 spec->stream_name_analog = "ALC267 Analog";
12316 spec->stream_name_digital = "ALC267 Digital";
12317 } else {
12318 spec->stream_name_analog = "ALC268 Analog";
12319 spec->stream_name_digital = "ALC268 Digital";
12320 }
12321
Kailang Yanga361d842007-06-05 12:30:55 +020012322 spec->stream_analog_playback = &alc268_pcm_analog_playback;
12323 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010012324 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020012325
Kailang Yanga361d842007-06-05 12:30:55 +020012326 spec->stream_digital_playback = &alc268_pcm_digital_playback;
12327
Takashi Iwai22971e32009-02-10 11:56:44 +010012328 has_beep = 0;
12329 for (i = 0; i < spec->num_mixers; i++) {
12330 if (spec->mixers[i] == alc268_beep_mixer) {
12331 has_beep = 1;
12332 break;
12333 }
12334 }
12335
12336 if (has_beep) {
12337 err = snd_hda_attach_beep_device(codec, 0x1);
12338 if (err < 0) {
12339 alc_free(codec);
12340 return err;
12341 }
12342 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
12343 /* override the amp caps for beep generator */
12344 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012345 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
12346 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
12347 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
12348 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010012349 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012350
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012351 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012352 /* check whether NID 0x07 is valid */
12353 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010012354 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020012355
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012356 /* get type */
12357 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwai67ebcb02008-02-19 15:03:57 +010012358 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012359 spec->adc_nids = alc268_adc_nids_alt;
12360 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012361 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012362 } else {
12363 spec->adc_nids = alc268_adc_nids;
12364 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012365 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020012366 }
Takashi Iwaie1406342008-02-11 18:32:32 +010012367 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai85860c02008-02-19 15:00:15 +010012368 /* set default input source */
12369 for (i = 0; i < spec->num_adc_nids; i++)
12370 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
12371 0, AC_VERB_SET_CONNECT_SEL,
12372 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020012373 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010012374
12375 spec->vmaster_nid = 0x02;
12376
Kailang Yanga361d842007-06-05 12:30:55 +020012377 codec->patch_ops = alc_patch_ops;
12378 if (board_config == ALC268_AUTO)
12379 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020012380
Takashi Iwaidaead532008-11-28 12:55:36 +010012381 codec->proc_widget_hook = print_realtek_coef;
12382
Kailang Yanga361d842007-06-05 12:30:55 +020012383 return 0;
12384}
12385
12386/*
Kailang Yangf6a92242007-12-13 16:52:54 +010012387 * ALC269 channel source setting (2 channel)
12388 */
12389#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
12390
12391#define alc269_dac_nids alc260_dac_nids
12392
12393static hda_nid_t alc269_adc_nids[1] = {
12394 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020012395 0x08,
12396};
12397
Takashi Iwaie01bf502008-08-21 16:25:07 +020012398static hda_nid_t alc269_capsrc_nids[1] = {
12399 0x23,
12400};
12401
12402/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
12403 * not a mux!
12404 */
12405
Kailang Yangf53281e2008-07-18 12:36:43 +020012406static struct hda_input_mux alc269_eeepc_dmic_capture_source = {
12407 .num_items = 2,
12408 .items = {
12409 { "i-Mic", 0x5 },
12410 { "e-Mic", 0x0 },
12411 },
12412};
12413
12414static struct hda_input_mux alc269_eeepc_amic_capture_source = {
12415 .num_items = 2,
12416 .items = {
12417 { "i-Mic", 0x1 },
12418 { "e-Mic", 0x0 },
12419 },
Kailang Yangf6a92242007-12-13 16:52:54 +010012420};
12421
12422#define alc269_modes alc260_modes
12423#define alc269_capture_source alc880_lg_lw_capture_source
12424
12425static struct snd_kcontrol_new alc269_base_mixer[] = {
12426 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12427 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12428 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12429 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12430 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12431 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12432 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12433 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12434 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12435 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12436 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12437 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
12438 { } /* end */
12439};
12440
Kailang Yang60db6b52008-08-26 13:13:00 +020012441static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
12442 /* output mixer control */
12443 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12444 {
12445 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12446 .name = "Master Playback Switch",
12447 .info = snd_hda_mixer_amp_switch_info,
12448 .get = snd_hda_mixer_amp_switch_get,
12449 .put = alc268_acer_master_sw_put,
12450 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12451 },
12452 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12453 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12454 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12455 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12456 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12457 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020012458 { }
12459};
12460
Tony Vroon64154832008-11-06 15:08:49 +000012461static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
12462 /* output mixer control */
12463 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12464 {
12465 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12466 .name = "Master Playback Switch",
12467 .info = snd_hda_mixer_amp_switch_info,
12468 .get = snd_hda_mixer_amp_switch_get,
12469 .put = alc268_acer_master_sw_put,
12470 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12471 },
12472 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12473 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12474 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12475 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12476 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12477 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12478 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
12479 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
12480 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000012481 { }
12482};
12483
Kailang Yangf53281e2008-07-18 12:36:43 +020012484/* bind volumes of both NID 0x0c and 0x0d */
12485static struct hda_bind_ctls alc269_epc_bind_vol = {
12486 .ops = &snd_hda_bind_vol,
12487 .values = {
12488 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
12489 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
12490 0
12491 },
12492};
12493
12494static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
12495 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12496 HDA_BIND_VOL("LineOut Playback Volume", &alc269_epc_bind_vol),
12497 HDA_CODEC_MUTE("LineOut Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12498 { } /* end */
12499};
12500
Kailang Yangf6a92242007-12-13 16:52:54 +010012501/* capture mixer elements */
Kailang Yangf53281e2008-07-18 12:36:43 +020012502static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
12503 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12504 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012505 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12506 { } /* end */
12507};
12508
12509/* FSC amilo */
12510static struct snd_kcontrol_new alc269_fujitsu_mixer[] = {
12511 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12512 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12513 HDA_BIND_VOL("PCM Playback Volume", &alc269_epc_bind_vol),
Kailang Yangf53281e2008-07-18 12:36:43 +020012514 { } /* end */
12515};
12516
Kailang Yang60db6b52008-08-26 13:13:00 +020012517static struct hda_verb alc269_quanta_fl1_verbs[] = {
12518 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12519 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12520 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12521 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12522 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12523 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12524 { }
12525};
12526
Tony Vroon64154832008-11-06 15:08:49 +000012527static struct hda_verb alc269_lifebook_verbs[] = {
12528 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12529 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
12530 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12531 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12532 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12533 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12534 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12535 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12536 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12537 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12538 { }
12539};
12540
Kailang Yang60db6b52008-08-26 13:13:00 +020012541/* toggle speaker-output according to the hp-jack state */
12542static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
12543{
12544 unsigned int present;
12545 unsigned char bits;
12546
12547 present = snd_hda_codec_read(codec, 0x15, 0,
12548 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12549 bits = present ? AMP_IN_MUTE(0) : 0;
12550 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12551 AMP_IN_MUTE(0), bits);
12552 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12553 AMP_IN_MUTE(0), bits);
12554
12555 snd_hda_codec_write(codec, 0x20, 0,
12556 AC_VERB_SET_COEF_INDEX, 0x0c);
12557 snd_hda_codec_write(codec, 0x20, 0,
12558 AC_VERB_SET_PROC_COEF, 0x680);
12559
12560 snd_hda_codec_write(codec, 0x20, 0,
12561 AC_VERB_SET_COEF_INDEX, 0x0c);
12562 snd_hda_codec_write(codec, 0x20, 0,
12563 AC_VERB_SET_PROC_COEF, 0x480);
12564}
12565
Tony Vroon64154832008-11-06 15:08:49 +000012566/* toggle speaker-output according to the hp-jacks state */
12567static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
12568{
12569 unsigned int present;
12570 unsigned char bits;
12571
12572 /* Check laptop headphone socket */
12573 present = snd_hda_codec_read(codec, 0x15, 0,
12574 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12575
12576 /* Check port replicator headphone socket */
12577 present |= snd_hda_codec_read(codec, 0x1a, 0,
12578 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12579
12580 bits = present ? AMP_IN_MUTE(0) : 0;
12581 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12582 AMP_IN_MUTE(0), bits);
12583 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12584 AMP_IN_MUTE(0), bits);
12585
12586 snd_hda_codec_write(codec, 0x20, 0,
12587 AC_VERB_SET_COEF_INDEX, 0x0c);
12588 snd_hda_codec_write(codec, 0x20, 0,
12589 AC_VERB_SET_PROC_COEF, 0x680);
12590
12591 snd_hda_codec_write(codec, 0x20, 0,
12592 AC_VERB_SET_COEF_INDEX, 0x0c);
12593 snd_hda_codec_write(codec, 0x20, 0,
12594 AC_VERB_SET_PROC_COEF, 0x480);
12595}
12596
Kailang Yang60db6b52008-08-26 13:13:00 +020012597static void alc269_quanta_fl1_mic_automute(struct hda_codec *codec)
12598{
12599 unsigned int present;
12600
12601 present = snd_hda_codec_read(codec, 0x18, 0,
12602 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12603 snd_hda_codec_write(codec, 0x23, 0,
12604 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x1);
12605}
12606
Tony Vroon64154832008-11-06 15:08:49 +000012607static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
12608{
12609 unsigned int present_laptop;
12610 unsigned int present_dock;
12611
12612 present_laptop = snd_hda_codec_read(codec, 0x18, 0,
12613 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12614
12615 present_dock = snd_hda_codec_read(codec, 0x1b, 0,
12616 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12617
12618 /* Laptop mic port overrides dock mic port, design decision */
12619 if (present_dock)
12620 snd_hda_codec_write(codec, 0x23, 0,
12621 AC_VERB_SET_CONNECT_SEL, 0x3);
12622 if (present_laptop)
12623 snd_hda_codec_write(codec, 0x23, 0,
12624 AC_VERB_SET_CONNECT_SEL, 0x0);
12625 if (!present_dock && !present_laptop)
12626 snd_hda_codec_write(codec, 0x23, 0,
12627 AC_VERB_SET_CONNECT_SEL, 0x1);
12628}
12629
Kailang Yang60db6b52008-08-26 13:13:00 +020012630static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
12631 unsigned int res)
12632{
12633 if ((res >> 26) == ALC880_HP_EVENT)
12634 alc269_quanta_fl1_speaker_automute(codec);
12635 if ((res >> 26) == ALC880_MIC_EVENT)
12636 alc269_quanta_fl1_mic_automute(codec);
12637}
12638
Tony Vroon64154832008-11-06 15:08:49 +000012639static void alc269_lifebook_unsol_event(struct hda_codec *codec,
12640 unsigned int res)
12641{
12642 if ((res >> 26) == ALC880_HP_EVENT)
12643 alc269_lifebook_speaker_automute(codec);
12644 if ((res >> 26) == ALC880_MIC_EVENT)
12645 alc269_lifebook_mic_autoswitch(codec);
12646}
12647
Kailang Yang60db6b52008-08-26 13:13:00 +020012648static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
12649{
12650 alc269_quanta_fl1_speaker_automute(codec);
12651 alc269_quanta_fl1_mic_automute(codec);
12652}
12653
Tony Vroon64154832008-11-06 15:08:49 +000012654static void alc269_lifebook_init_hook(struct hda_codec *codec)
12655{
12656 alc269_lifebook_speaker_automute(codec);
12657 alc269_lifebook_mic_autoswitch(codec);
12658}
12659
Kailang Yang60db6b52008-08-26 13:13:00 +020012660static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
12661 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12662 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
12663 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12664 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
12665 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12666 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12667 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12668 {}
12669};
12670
12671static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
12672 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12673 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
12674 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12675 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
12676 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12677 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12678 {}
12679};
12680
12681/* toggle speaker-output according to the hp-jack state */
12682static void alc269_speaker_automute(struct hda_codec *codec)
12683{
12684 unsigned int present;
12685 unsigned char bits;
12686
12687 present = snd_hda_codec_read(codec, 0x15, 0,
12688 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12689 bits = present ? AMP_IN_MUTE(0) : 0;
12690 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12691 AMP_IN_MUTE(0), bits);
12692 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12693 AMP_IN_MUTE(0), bits);
12694}
12695
12696static void alc269_eeepc_dmic_automute(struct hda_codec *codec)
12697{
12698 unsigned int present;
12699
12700 present = snd_hda_codec_read(codec, 0x18, 0,
12701 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12702 snd_hda_codec_write(codec, 0x23, 0,
12703 AC_VERB_SET_CONNECT_SEL, (present ? 0 : 5));
12704}
12705
12706static void alc269_eeepc_amic_automute(struct hda_codec *codec)
12707{
12708 unsigned int present;
12709
12710 present = snd_hda_codec_read(codec, 0x18, 0,
12711 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12712 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12713 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
12714 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12715 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
12716}
12717
12718/* unsolicited event for HP jack sensing */
12719static void alc269_eeepc_dmic_unsol_event(struct hda_codec *codec,
12720 unsigned int res)
12721{
12722 if ((res >> 26) == ALC880_HP_EVENT)
12723 alc269_speaker_automute(codec);
12724
12725 if ((res >> 26) == ALC880_MIC_EVENT)
12726 alc269_eeepc_dmic_automute(codec);
12727}
12728
12729static void alc269_eeepc_dmic_inithook(struct hda_codec *codec)
12730{
12731 alc269_speaker_automute(codec);
12732 alc269_eeepc_dmic_automute(codec);
12733}
12734
12735/* unsolicited event for HP jack sensing */
12736static void alc269_eeepc_amic_unsol_event(struct hda_codec *codec,
12737 unsigned int res)
12738{
12739 if ((res >> 26) == ALC880_HP_EVENT)
12740 alc269_speaker_automute(codec);
12741
12742 if ((res >> 26) == ALC880_MIC_EVENT)
12743 alc269_eeepc_amic_automute(codec);
12744}
12745
12746static void alc269_eeepc_amic_inithook(struct hda_codec *codec)
12747{
12748 alc269_speaker_automute(codec);
12749 alc269_eeepc_amic_automute(codec);
12750}
12751
Kailang Yangf6a92242007-12-13 16:52:54 +010012752/*
12753 * generic initialization of ADC, input mixers and output mixers
12754 */
12755static struct hda_verb alc269_init_verbs[] = {
12756 /*
12757 * Unmute ADC0 and set the default input to mic-in
12758 */
Kailang Yang60db6b52008-08-26 13:13:00 +020012759 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010012760
12761 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
12762 * analog-loopback mixer widget
12763 * Note: PASD motherboards uses the Line In 2 as the input for
12764 * front panel mic (mic 2)
12765 */
12766 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
12767 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12768 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12769 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12770 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12771 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12772
12773 /*
12774 * Set up output mixers (0x0c - 0x0e)
12775 */
12776 /* set vol=0 to output mixers */
12777 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12778 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12779
12780 /* set up input amps for analog loopback */
12781 /* Amp Indices: DAC = 0, mixer = 1 */
12782 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12783 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12784 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12785 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12786 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12787 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12788
12789 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12790 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12791 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12792 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12793 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12794 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12795 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12796
12797 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12798 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12799 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12800 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12801 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12802 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12803 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12804
12805 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
12806 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12807
12808 /* FIXME: use matrix-type input source selection */
12809 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
12810 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang60db6b52008-08-26 13:13:00 +020012811 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12812 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangf6a92242007-12-13 16:52:54 +010012813 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12814 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12815
12816 /* set EAPD */
12817 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12818 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12819 { }
12820};
12821
12822/* add playback controls from the parsed DAC table */
12823static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
12824 const struct auto_pin_cfg *cfg)
12825{
12826 hda_nid_t nid;
12827 int err;
12828
12829 spec->multiout.num_dacs = 1; /* only use one dac */
12830 spec->multiout.dac_nids = spec->private_dac_nids;
12831 spec->multiout.dac_nids[0] = 2;
12832
12833 nid = cfg->line_out_pins[0];
12834 if (nid) {
12835 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12836 "Front Playback Volume",
12837 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
12838 if (err < 0)
12839 return err;
12840 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12841 "Front Playback Switch",
12842 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
12843 if (err < 0)
12844 return err;
12845 }
12846
12847 nid = cfg->speaker_pins[0];
12848 if (nid) {
12849 if (!cfg->line_out_pins[0]) {
12850 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12851 "Speaker Playback Volume",
12852 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12853 HDA_OUTPUT));
12854 if (err < 0)
12855 return err;
12856 }
12857 if (nid == 0x16) {
12858 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12859 "Speaker Playback Switch",
12860 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12861 HDA_OUTPUT));
12862 if (err < 0)
12863 return err;
12864 } else {
12865 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12866 "Speaker Playback Switch",
12867 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12868 HDA_OUTPUT));
12869 if (err < 0)
12870 return err;
12871 }
12872 }
12873 nid = cfg->hp_pins[0];
12874 if (nid) {
12875 /* spec->multiout.hp_nid = 2; */
12876 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
12877 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12878 "Headphone Playback Volume",
12879 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12880 HDA_OUTPUT));
12881 if (err < 0)
12882 return err;
12883 }
12884 if (nid == 0x16) {
12885 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12886 "Headphone Playback Switch",
12887 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12888 HDA_OUTPUT));
12889 if (err < 0)
12890 return err;
12891 } else {
12892 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12893 "Headphone Playback Switch",
12894 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12895 HDA_OUTPUT));
12896 if (err < 0)
12897 return err;
12898 }
12899 }
12900 return 0;
12901}
12902
Takashi Iwaiee956e02008-10-31 17:16:31 +010012903static int alc269_auto_create_analog_input_ctls(struct alc_spec *spec,
12904 const struct auto_pin_cfg *cfg)
12905{
12906 int err;
12907
12908 err = alc880_auto_create_analog_input_ctls(spec, cfg);
12909 if (err < 0)
12910 return err;
12911 /* digital-mic input pin is excluded in alc880_auto_create..()
12912 * because it's under 0x18
12913 */
12914 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
12915 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012916 struct hda_input_mux *imux = &spec->private_imux[0];
Takashi Iwaiee956e02008-10-31 17:16:31 +010012917 imux->items[imux->num_items].label = "Int Mic";
12918 imux->items[imux->num_items].index = 0x05;
12919 imux->num_items++;
12920 }
12921 return 0;
12922}
Kailang Yangf6a92242007-12-13 16:52:54 +010012923
12924#ifdef CONFIG_SND_HDA_POWER_SAVE
12925#define alc269_loopbacks alc880_loopbacks
12926#endif
12927
12928/* pcm configuration: identiacal with ALC880 */
12929#define alc269_pcm_analog_playback alc880_pcm_analog_playback
12930#define alc269_pcm_analog_capture alc880_pcm_analog_capture
12931#define alc269_pcm_digital_playback alc880_pcm_digital_playback
12932#define alc269_pcm_digital_capture alc880_pcm_digital_capture
12933
Takashi Iwaif03d3112009-03-05 14:18:16 +010012934static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
12935 .substreams = 1,
12936 .channels_min = 2,
12937 .channels_max = 8,
12938 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
12939 /* NID is set in alc_build_pcms */
12940 .ops = {
12941 .open = alc880_playback_pcm_open,
12942 .prepare = alc880_playback_pcm_prepare,
12943 .cleanup = alc880_playback_pcm_cleanup
12944 },
12945};
12946
12947static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
12948 .substreams = 1,
12949 .channels_min = 2,
12950 .channels_max = 2,
12951 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
12952 /* NID is set in alc_build_pcms */
12953};
12954
Kailang Yangf6a92242007-12-13 16:52:54 +010012955/*
12956 * BIOS auto configuration
12957 */
12958static int alc269_parse_auto_config(struct hda_codec *codec)
12959{
12960 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010012961 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010012962 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
12963
12964 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12965 alc269_ignore);
12966 if (err < 0)
12967 return err;
12968
12969 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
12970 if (err < 0)
12971 return err;
12972 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
12973 if (err < 0)
12974 return err;
12975
12976 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12977
Takashi Iwai0852d7a2009-02-11 11:35:15 +010012978 if (spec->autocfg.dig_outs)
Kailang Yangf6a92242007-12-13 16:52:54 +010012979 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
12980
Takashi Iwai603c4012008-07-30 15:01:44 +020012981 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012982 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010012983
Takashi Iwaid88897e2008-10-31 15:01:37 +010012984 add_verb(spec, alc269_init_verbs);
Kailang Yangf6a92242007-12-13 16:52:54 +010012985 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012986 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie01bf502008-08-21 16:25:07 +020012987 /* set default input source */
12988 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
12989 0, AC_VERB_SET_CONNECT_SEL,
12990 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010012991
12992 err = alc_auto_add_mic_boost(codec);
12993 if (err < 0)
12994 return err;
12995
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012996 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012997 set_capture_mixer(spec);
Kailang Yangf53281e2008-07-18 12:36:43 +020012998
Kailang Yangf6a92242007-12-13 16:52:54 +010012999 return 1;
13000}
13001
13002#define alc269_auto_init_multi_out alc882_auto_init_multi_out
13003#define alc269_auto_init_hp_out alc882_auto_init_hp_out
13004#define alc269_auto_init_analog_input alc882_auto_init_analog_input
13005
13006
13007/* init callback for auto-configuration model -- overriding the default init */
13008static void alc269_auto_init(struct hda_codec *codec)
13009{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013010 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010013011 alc269_auto_init_multi_out(codec);
13012 alc269_auto_init_hp_out(codec);
13013 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013014 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013015 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010013016}
13017
13018/*
13019 * configuration and preset
13020 */
13021static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013022 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020013023 [ALC269_QUANTA_FL1] = "quanta",
13024 [ALC269_ASUS_EEEPC_P703] = "eeepc-p703",
Takashi Iwai26f5df22008-11-03 17:39:46 +010013025 [ALC269_ASUS_EEEPC_P901] = "eeepc-p901",
Tony Vroon64154832008-11-06 15:08:49 +000013026 [ALC269_FUJITSU] = "fujitsu",
13027 [ALC269_LIFEBOOK] = "lifebook"
Kailang Yangf6a92242007-12-13 16:52:54 +010013028};
13029
13030static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013031 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020013032 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
13033 ALC269_ASUS_EEEPC_P703),
Kailang Yang622e84c2009-04-21 07:39:04 +020013034 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_ASUS_EEEPC_P703),
13035 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_ASUS_EEEPC_P703),
13036 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_ASUS_EEEPC_P703),
13037 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_ASUS_EEEPC_P703),
13038 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_ASUS_EEEPC_P703),
13039 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_ASUS_EEEPC_P703),
Kailang Yangf53281e2008-07-18 12:36:43 +020013040 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
13041 ALC269_ASUS_EEEPC_P901),
Kailang Yang60db6b52008-08-26 13:13:00 +020013042 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
13043 ALC269_ASUS_EEEPC_P901),
Kailang Yang622e84c2009-04-21 07:39:04 +020013044 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_ASUS_EEEPC_P901),
Takashi Iwai26f5df22008-11-03 17:39:46 +010013045 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
Tony Vroon64154832008-11-06 15:08:49 +000013046 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yangf6a92242007-12-13 16:52:54 +010013047 {}
13048};
13049
13050static struct alc_config_preset alc269_presets[] = {
13051 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013052 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010013053 .init_verbs = { alc269_init_verbs },
13054 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13055 .dac_nids = alc269_dac_nids,
13056 .hp_nid = 0x03,
13057 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13058 .channel_mode = alc269_modes,
13059 .input_mux = &alc269_capture_source,
13060 },
Kailang Yang60db6b52008-08-26 13:13:00 +020013061 [ALC269_QUANTA_FL1] = {
13062 .mixers = { alc269_quanta_fl1_mixer },
13063 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
13064 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13065 .dac_nids = alc269_dac_nids,
13066 .hp_nid = 0x03,
13067 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13068 .channel_mode = alc269_modes,
13069 .input_mux = &alc269_capture_source,
13070 .unsol_event = alc269_quanta_fl1_unsol_event,
13071 .init_hook = alc269_quanta_fl1_init_hook,
13072 },
Kailang Yangf53281e2008-07-18 12:36:43 +020013073 [ALC269_ASUS_EEEPC_P703] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013074 .mixers = { alc269_eeepc_mixer },
13075 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013076 .init_verbs = { alc269_init_verbs,
13077 alc269_eeepc_amic_init_verbs },
13078 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13079 .dac_nids = alc269_dac_nids,
13080 .hp_nid = 0x03,
13081 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13082 .channel_mode = alc269_modes,
13083 .input_mux = &alc269_eeepc_amic_capture_source,
13084 .unsol_event = alc269_eeepc_amic_unsol_event,
13085 .init_hook = alc269_eeepc_amic_inithook,
13086 },
13087 [ALC269_ASUS_EEEPC_P901] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013088 .mixers = { alc269_eeepc_mixer },
13089 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013090 .init_verbs = { alc269_init_verbs,
13091 alc269_eeepc_dmic_init_verbs },
13092 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13093 .dac_nids = alc269_dac_nids,
13094 .hp_nid = 0x03,
13095 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13096 .channel_mode = alc269_modes,
13097 .input_mux = &alc269_eeepc_dmic_capture_source,
13098 .unsol_event = alc269_eeepc_dmic_unsol_event,
13099 .init_hook = alc269_eeepc_dmic_inithook,
13100 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013101 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013102 .mixers = { alc269_fujitsu_mixer },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013103 .cap_mixer = alc269_epc_capture_mixer,
13104 .init_verbs = { alc269_init_verbs,
13105 alc269_eeepc_dmic_init_verbs },
13106 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13107 .dac_nids = alc269_dac_nids,
13108 .hp_nid = 0x03,
13109 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13110 .channel_mode = alc269_modes,
13111 .input_mux = &alc269_eeepc_dmic_capture_source,
13112 .unsol_event = alc269_eeepc_dmic_unsol_event,
13113 .init_hook = alc269_eeepc_dmic_inithook,
13114 },
Tony Vroon64154832008-11-06 15:08:49 +000013115 [ALC269_LIFEBOOK] = {
13116 .mixers = { alc269_lifebook_mixer },
13117 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
13118 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13119 .dac_nids = alc269_dac_nids,
13120 .hp_nid = 0x03,
13121 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13122 .channel_mode = alc269_modes,
13123 .input_mux = &alc269_capture_source,
13124 .unsol_event = alc269_lifebook_unsol_event,
13125 .init_hook = alc269_lifebook_init_hook,
13126 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013127};
13128
13129static int patch_alc269(struct hda_codec *codec)
13130{
13131 struct alc_spec *spec;
13132 int board_config;
13133 int err;
13134
13135 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13136 if (spec == NULL)
13137 return -ENOMEM;
13138
13139 codec->spec = spec;
13140
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020013141 alc_fix_pll_init(codec, 0x20, 0x04, 15);
13142
Kailang Yangf6a92242007-12-13 16:52:54 +010013143 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
13144 alc269_models,
13145 alc269_cfg_tbl);
13146
13147 if (board_config < 0) {
13148 printk(KERN_INFO "hda_codec: Unknown model for ALC269, "
13149 "trying auto-probe from BIOS...\n");
13150 board_config = ALC269_AUTO;
13151 }
13152
13153 if (board_config == ALC269_AUTO) {
13154 /* automatic parse from the BIOS config */
13155 err = alc269_parse_auto_config(codec);
13156 if (err < 0) {
13157 alc_free(codec);
13158 return err;
13159 } else if (!err) {
13160 printk(KERN_INFO
13161 "hda_codec: Cannot set up configuration "
13162 "from BIOS. Using base mode...\n");
13163 board_config = ALC269_BASIC;
13164 }
13165 }
13166
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090013167 err = snd_hda_attach_beep_device(codec, 0x1);
13168 if (err < 0) {
13169 alc_free(codec);
13170 return err;
13171 }
13172
Kailang Yangf6a92242007-12-13 16:52:54 +010013173 if (board_config != ALC269_AUTO)
13174 setup_preset(spec, &alc269_presets[board_config]);
13175
13176 spec->stream_name_analog = "ALC269 Analog";
Takashi Iwaif03d3112009-03-05 14:18:16 +010013177 if (codec->subsystem_id == 0x17aa3bf8) {
13178 /* Due to a hardware problem on Lenovo Ideadpad, we need to
13179 * fix the sample rate of analog I/O to 44.1kHz
13180 */
13181 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
13182 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
13183 } else {
13184 spec->stream_analog_playback = &alc269_pcm_analog_playback;
13185 spec->stream_analog_capture = &alc269_pcm_analog_capture;
13186 }
Kailang Yangf6a92242007-12-13 16:52:54 +010013187 spec->stream_name_digital = "ALC269 Digital";
13188 spec->stream_digital_playback = &alc269_pcm_digital_playback;
13189 spec->stream_digital_capture = &alc269_pcm_digital_capture;
13190
13191 spec->adc_nids = alc269_adc_nids;
13192 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
Takashi Iwaie01bf502008-08-21 16:25:07 +020013193 spec->capsrc_nids = alc269_capsrc_nids;
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013194 if (!spec->cap_mixer)
13195 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013196 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010013197
13198 codec->patch_ops = alc_patch_ops;
13199 if (board_config == ALC269_AUTO)
13200 spec->init_hook = alc269_auto_init;
13201#ifdef CONFIG_SND_HDA_POWER_SAVE
13202 if (!spec->loopback.amplist)
13203 spec->loopback.amplist = alc269_loopbacks;
13204#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010013205 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010013206
13207 return 0;
13208}
13209
13210/*
Kailang Yangdf694da2005-12-05 19:42:22 +010013211 * ALC861 channel source setting (2/6 channel selection for 3-stack)
13212 */
13213
13214/*
13215 * set the path ways for 2 channel output
13216 * need to set the codec line out and mic 1 pin widgets to inputs
13217 */
13218static struct hda_verb alc861_threestack_ch2_init[] = {
13219 /* set pin widget 1Ah (line in) for input */
13220 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013221 /* set pin widget 18h (mic1/2) for input, for mic also enable
13222 * the vref
13223 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013224 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13225
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013226 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13227#if 0
13228 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13229 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13230#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013231 { } /* end */
13232};
13233/*
13234 * 6ch mode
13235 * need to set the codec line out and mic 1 pin widgets to outputs
13236 */
13237static struct hda_verb alc861_threestack_ch6_init[] = {
13238 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13239 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13240 /* set pin widget 18h (mic1) for output (CLFE)*/
13241 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13242
13243 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013244 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013245
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013246 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13247#if 0
13248 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13249 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13250#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013251 { } /* end */
13252};
13253
13254static struct hda_channel_mode alc861_threestack_modes[2] = {
13255 { 2, alc861_threestack_ch2_init },
13256 { 6, alc861_threestack_ch6_init },
13257};
Takashi Iwai22309c32006-08-09 16:57:28 +020013258/* Set mic1 as input and unmute the mixer */
13259static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
13260 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13261 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13262 { } /* end */
13263};
13264/* Set mic1 as output and mute mixer */
13265static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
13266 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13267 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13268 { } /* end */
13269};
13270
13271static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
13272 { 2, alc861_uniwill_m31_ch2_init },
13273 { 4, alc861_uniwill_m31_ch4_init },
13274};
Kailang Yangdf694da2005-12-05 19:42:22 +010013275
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013276/* Set mic1 and line-in as input and unmute the mixer */
13277static struct hda_verb alc861_asus_ch2_init[] = {
13278 /* set pin widget 1Ah (line in) for input */
13279 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013280 /* set pin widget 18h (mic1/2) for input, for mic also enable
13281 * the vref
13282 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013283 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13284
13285 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13286#if 0
13287 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13288 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13289#endif
13290 { } /* end */
13291};
13292/* Set mic1 nad line-in as output and mute mixer */
13293static struct hda_verb alc861_asus_ch6_init[] = {
13294 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13295 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13296 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13297 /* set pin widget 18h (mic1) for output (CLFE)*/
13298 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13299 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13300 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
13301 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
13302
13303 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13304#if 0
13305 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13306 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13307#endif
13308 { } /* end */
13309};
13310
13311static struct hda_channel_mode alc861_asus_modes[2] = {
13312 { 2, alc861_asus_ch2_init },
13313 { 6, alc861_asus_ch6_init },
13314};
13315
Kailang Yangdf694da2005-12-05 19:42:22 +010013316/* patch-ALC861 */
13317
13318static struct snd_kcontrol_new alc861_base_mixer[] = {
13319 /* output mixer control */
13320 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13321 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13322 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13323 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13324 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13325
13326 /*Input mixer control */
13327 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13328 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13329 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13330 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13331 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13332 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13333 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13334 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13335 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13336 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013337
Kailang Yangdf694da2005-12-05 19:42:22 +010013338 { } /* end */
13339};
13340
13341static struct snd_kcontrol_new alc861_3ST_mixer[] = {
13342 /* output mixer control */
13343 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13344 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13345 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13346 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13347 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13348
13349 /* Input mixer control */
13350 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13351 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13352 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13353 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13354 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13355 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13356 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13357 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13358 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13359 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013360
Kailang Yangdf694da2005-12-05 19:42:22 +010013361 {
13362 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13363 .name = "Channel Mode",
13364 .info = alc_ch_mode_info,
13365 .get = alc_ch_mode_get,
13366 .put = alc_ch_mode_put,
13367 .private_value = ARRAY_SIZE(alc861_threestack_modes),
13368 },
13369 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013370};
13371
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013372static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013373 /* output mixer control */
13374 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13375 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13376 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020013377
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013378 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013379};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013380
Takashi Iwai22309c32006-08-09 16:57:28 +020013381static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
13382 /* output mixer control */
13383 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13384 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13385 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13386 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13387 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13388
13389 /* Input mixer control */
13390 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13391 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13392 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13393 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13394 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13395 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13396 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13397 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13398 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13399 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013400
Takashi Iwai22309c32006-08-09 16:57:28 +020013401 {
13402 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13403 .name = "Channel Mode",
13404 .info = alc_ch_mode_info,
13405 .get = alc_ch_mode_get,
13406 .put = alc_ch_mode_put,
13407 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
13408 },
13409 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013410};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013411
13412static struct snd_kcontrol_new alc861_asus_mixer[] = {
13413 /* output mixer control */
13414 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13415 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13416 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13417 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13418 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13419
13420 /* Input mixer control */
13421 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13422 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13423 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13424 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13425 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13426 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13427 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13428 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13429 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013430 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
13431
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013432 {
13433 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13434 .name = "Channel Mode",
13435 .info = alc_ch_mode_info,
13436 .get = alc_ch_mode_get,
13437 .put = alc_ch_mode_put,
13438 .private_value = ARRAY_SIZE(alc861_asus_modes),
13439 },
13440 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013441};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013442
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013443/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013444static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013445 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13446 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013447 { }
13448};
13449
Kailang Yangdf694da2005-12-05 19:42:22 +010013450/*
13451 * generic initialization of ADC, input mixers and output mixers
13452 */
13453static struct hda_verb alc861_base_init_verbs[] = {
13454 /*
13455 * Unmute ADC0 and set the default input to mic-in
13456 */
13457 /* port-A for surround (rear panel) */
13458 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13459 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
13460 /* port-B for mic-in (rear panel) with vref */
13461 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13462 /* port-C for line-in (rear panel) */
13463 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13464 /* port-D for Front */
13465 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13466 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13467 /* port-E for HP out (front panel) */
13468 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13469 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013470 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013471 /* port-F for mic-in (front panel) with vref */
13472 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13473 /* port-G for CLFE (rear panel) */
13474 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13475 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13476 /* port-H for side (rear panel) */
13477 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13478 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
13479 /* CD-in */
13480 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13481 /* route front mic to ADC1*/
13482 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13483 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013484
Kailang Yangdf694da2005-12-05 19:42:22 +010013485 /* Unmute DAC0~3 & spdif out*/
13486 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13487 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13488 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13489 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13490 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013491
Kailang Yangdf694da2005-12-05 19:42:22 +010013492 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13493 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13494 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13495 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13496 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013497
Kailang Yangdf694da2005-12-05 19:42:22 +010013498 /* Unmute Stereo Mixer 15 */
13499 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13500 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13501 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013502 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013503
13504 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13505 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13506 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13507 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13508 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13509 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13510 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13511 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013512 /* hp used DAC 3 (Front) */
13513 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013514 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13515
13516 { }
13517};
13518
13519static struct hda_verb alc861_threestack_init_verbs[] = {
13520 /*
13521 * Unmute ADC0 and set the default input to mic-in
13522 */
13523 /* port-A for surround (rear panel) */
13524 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13525 /* port-B for mic-in (rear panel) with vref */
13526 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13527 /* port-C for line-in (rear panel) */
13528 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13529 /* port-D for Front */
13530 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13531 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13532 /* port-E for HP out (front panel) */
13533 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13534 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013535 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013536 /* port-F for mic-in (front panel) with vref */
13537 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13538 /* port-G for CLFE (rear panel) */
13539 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13540 /* port-H for side (rear panel) */
13541 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13542 /* CD-in */
13543 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13544 /* route front mic to ADC1*/
13545 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13546 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13547 /* Unmute DAC0~3 & spdif out*/
13548 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13549 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13550 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13551 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13552 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013553
Kailang Yangdf694da2005-12-05 19:42:22 +010013554 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13555 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13556 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13557 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13558 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013559
Kailang Yangdf694da2005-12-05 19:42:22 +010013560 /* Unmute Stereo Mixer 15 */
13561 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13562 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13563 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013564 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013565
13566 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13567 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13568 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13569 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13570 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13571 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13572 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13573 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013574 /* hp used DAC 3 (Front) */
13575 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013576 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13577 { }
13578};
Takashi Iwai22309c32006-08-09 16:57:28 +020013579
13580static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
13581 /*
13582 * Unmute ADC0 and set the default input to mic-in
13583 */
13584 /* port-A for surround (rear panel) */
13585 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13586 /* port-B for mic-in (rear panel) with vref */
13587 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13588 /* port-C for line-in (rear panel) */
13589 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13590 /* port-D for Front */
13591 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13592 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13593 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013594 /* this has to be set to VREF80 */
13595 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013596 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013597 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013598 /* port-F for mic-in (front panel) with vref */
13599 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13600 /* port-G for CLFE (rear panel) */
13601 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13602 /* port-H for side (rear panel) */
13603 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13604 /* CD-in */
13605 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13606 /* route front mic to ADC1*/
13607 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13608 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13609 /* Unmute DAC0~3 & spdif out*/
13610 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13611 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13612 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13613 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13614 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013615
Takashi Iwai22309c32006-08-09 16:57:28 +020013616 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13617 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13618 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13619 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13620 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013621
Takashi Iwai22309c32006-08-09 16:57:28 +020013622 /* Unmute Stereo Mixer 15 */
13623 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13624 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13625 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013626 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020013627
13628 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13629 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13630 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13631 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13632 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13633 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13634 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13635 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013636 /* hp used DAC 3 (Front) */
13637 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020013638 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13639 { }
13640};
13641
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013642static struct hda_verb alc861_asus_init_verbs[] = {
13643 /*
13644 * Unmute ADC0 and set the default input to mic-in
13645 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013646 /* port-A for surround (rear panel)
13647 * according to codec#0 this is the HP jack
13648 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013649 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
13650 /* route front PCM to HP */
13651 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
13652 /* port-B for mic-in (rear panel) with vref */
13653 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13654 /* port-C for line-in (rear panel) */
13655 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13656 /* port-D for Front */
13657 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13658 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13659 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013660 /* this has to be set to VREF80 */
13661 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013662 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013663 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013664 /* port-F for mic-in (front panel) with vref */
13665 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13666 /* port-G for CLFE (rear panel) */
13667 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13668 /* port-H for side (rear panel) */
13669 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13670 /* CD-in */
13671 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13672 /* route front mic to ADC1*/
13673 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13674 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13675 /* Unmute DAC0~3 & spdif out*/
13676 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13677 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13678 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13679 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13680 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13681 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13682 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13683 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13684 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13685 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013686
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013687 /* Unmute Stereo Mixer 15 */
13688 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13689 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13690 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013691 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013692
13693 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13694 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13695 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13696 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13697 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13698 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13699 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13700 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013701 /* hp used DAC 3 (Front) */
13702 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013703 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13704 { }
13705};
13706
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013707/* additional init verbs for ASUS laptops */
13708static struct hda_verb alc861_asus_laptop_init_verbs[] = {
13709 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
13710 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
13711 { }
13712};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013713
Kailang Yangdf694da2005-12-05 19:42:22 +010013714/*
13715 * generic initialization of ADC, input mixers and output mixers
13716 */
13717static struct hda_verb alc861_auto_init_verbs[] = {
13718 /*
13719 * Unmute ADC0 and set the default input to mic-in
13720 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013721 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010013722 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013723
Kailang Yangdf694da2005-12-05 19:42:22 +010013724 /* Unmute DAC0~3 & spdif out*/
13725 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13726 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13727 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13728 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13729 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013730
Kailang Yangdf694da2005-12-05 19:42:22 +010013731 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13732 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13733 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13734 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13735 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013736
Kailang Yangdf694da2005-12-05 19:42:22 +010013737 /* Unmute Stereo Mixer 15 */
13738 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13739 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13740 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13741 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
13742
13743 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13744 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13745 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13746 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13747 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13748 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13749 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13750 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13751
13752 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13753 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013754 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13755 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013756 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13757 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013758 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13759 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013760
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013761 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013762
13763 { }
13764};
13765
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013766static struct hda_verb alc861_toshiba_init_verbs[] = {
13767 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013768
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013769 { }
13770};
13771
13772/* toggle speaker-output according to the hp-jack state */
13773static void alc861_toshiba_automute(struct hda_codec *codec)
13774{
13775 unsigned int present;
13776
13777 present = snd_hda_codec_read(codec, 0x0f, 0,
13778 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013779 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
13780 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
13781 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
13782 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013783}
13784
13785static void alc861_toshiba_unsol_event(struct hda_codec *codec,
13786 unsigned int res)
13787{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013788 if ((res >> 26) == ALC880_HP_EVENT)
13789 alc861_toshiba_automute(codec);
13790}
13791
Kailang Yangdf694da2005-12-05 19:42:22 +010013792/* pcm configuration: identiacal with ALC880 */
13793#define alc861_pcm_analog_playback alc880_pcm_analog_playback
13794#define alc861_pcm_analog_capture alc880_pcm_analog_capture
13795#define alc861_pcm_digital_playback alc880_pcm_digital_playback
13796#define alc861_pcm_digital_capture alc880_pcm_digital_capture
13797
13798
13799#define ALC861_DIGOUT_NID 0x07
13800
13801static struct hda_channel_mode alc861_8ch_modes[1] = {
13802 { 8, NULL }
13803};
13804
13805static hda_nid_t alc861_dac_nids[4] = {
13806 /* front, surround, clfe, side */
13807 0x03, 0x06, 0x05, 0x04
13808};
13809
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013810static hda_nid_t alc660_dac_nids[3] = {
13811 /* front, clfe, surround */
13812 0x03, 0x05, 0x06
13813};
13814
Kailang Yangdf694da2005-12-05 19:42:22 +010013815static hda_nid_t alc861_adc_nids[1] = {
13816 /* ADC0-2 */
13817 0x08,
13818};
13819
13820static struct hda_input_mux alc861_capture_source = {
13821 .num_items = 5,
13822 .items = {
13823 { "Mic", 0x0 },
13824 { "Front Mic", 0x3 },
13825 { "Line", 0x1 },
13826 { "CD", 0x4 },
13827 { "Mixer", 0x5 },
13828 },
13829};
13830
13831/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013832static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
13833 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010013834{
13835 int i;
13836 hda_nid_t nid;
13837
13838 spec->multiout.dac_nids = spec->private_dac_nids;
13839 for (i = 0; i < cfg->line_outs; i++) {
13840 nid = cfg->line_out_pins[i];
13841 if (nid) {
13842 if (i >= ARRAY_SIZE(alc861_dac_nids))
13843 continue;
13844 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
13845 }
13846 }
13847 spec->multiout.num_dacs = cfg->line_outs;
13848 return 0;
13849}
13850
13851/* add playback controls from the parsed DAC table */
13852static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
13853 const struct auto_pin_cfg *cfg)
13854{
13855 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013856 static const char *chname[4] = {
13857 "Front", "Surround", NULL /*CLFE*/, "Side"
13858 };
Kailang Yangdf694da2005-12-05 19:42:22 +010013859 hda_nid_t nid;
13860 int i, idx, err;
13861
13862 for (i = 0; i < cfg->line_outs; i++) {
13863 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013864 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010013865 continue;
13866 if (nid == 0x05) {
13867 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013868 err = add_control(spec, ALC_CTL_BIND_MUTE,
13869 "Center Playback Switch",
13870 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
13871 HDA_OUTPUT));
13872 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013873 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013874 err = add_control(spec, ALC_CTL_BIND_MUTE,
13875 "LFE Playback Switch",
13876 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13877 HDA_OUTPUT));
13878 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013879 return err;
13880 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013881 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
13882 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +010013883 if (nid == alc861_dac_nids[idx])
13884 break;
13885 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013886 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
13887 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13888 HDA_OUTPUT));
13889 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013890 return err;
13891 }
13892 }
13893 return 0;
13894}
13895
13896static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
13897{
13898 int err;
13899 hda_nid_t nid;
13900
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013901 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010013902 return 0;
13903
13904 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
13905 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013906 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13907 "Headphone Playback Switch",
13908 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
13909 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013910 return err;
13911 spec->multiout.hp_nid = nid;
13912 }
13913 return 0;
13914}
13915
13916/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013917static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
13918 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010013919{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013920 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010013921 int i, err, idx, idx1;
13922
13923 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013924 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010013925 case 0x0c:
13926 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013927 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013928 break;
13929 case 0x0f:
13930 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013931 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013932 break;
13933 case 0x0d:
13934 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013935 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013936 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013937 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010013938 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013939 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013940 break;
13941 case 0x11:
13942 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013943 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010013944 break;
13945 default:
13946 continue;
13947 }
13948
Takashi Iwai4a471b72005-12-07 13:56:29 +010013949 err = new_analog_input(spec, cfg->input_pins[i],
13950 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010013951 if (err < 0)
13952 return err;
13953
Takashi Iwai4a471b72005-12-07 13:56:29 +010013954 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010013955 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013956 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010013957 }
13958 return 0;
13959}
13960
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013961static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
13962 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +010013963 int pin_type, int dac_idx)
13964{
Jacek Luczak564c5be2008-05-03 18:41:23 +020013965 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
13966 pin_type);
13967 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13968 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +010013969}
13970
13971static void alc861_auto_init_multi_out(struct hda_codec *codec)
13972{
13973 struct alc_spec *spec = codec->spec;
13974 int i;
13975
13976 for (i = 0; i < spec->autocfg.line_outs; i++) {
13977 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013978 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010013979 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013980 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013981 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010013982 }
13983}
13984
13985static void alc861_auto_init_hp_out(struct hda_codec *codec)
13986{
13987 struct alc_spec *spec = codec->spec;
13988 hda_nid_t pin;
13989
Takashi Iwaieb06ed82006-09-20 17:10:27 +020013990 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010013991 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013992 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
13993 spec->multiout.dac_nids[0]);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013994 pin = spec->autocfg.speaker_pins[0];
13995 if (pin)
13996 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010013997}
13998
13999static void alc861_auto_init_analog_input(struct hda_codec *codec)
14000{
14001 struct alc_spec *spec = codec->spec;
14002 int i;
14003
14004 for (i = 0; i < AUTO_PIN_LAST; i++) {
14005 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai23f0c042009-02-26 13:03:58 +010014006 if (nid >= 0x0c && nid <= 0x11)
14007 alc_set_input_pin(codec, nid, i);
Kailang Yangdf694da2005-12-05 19:42:22 +010014008 }
14009}
14010
14011/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014012/* return 1 if successful, 0 if the proper config is not found,
14013 * or a negative error code
14014 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014015static int alc861_parse_auto_config(struct hda_codec *codec)
14016{
14017 struct alc_spec *spec = codec->spec;
14018 int err;
14019 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
14020
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014021 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14022 alc861_ignore);
14023 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014024 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014025 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014026 return 0; /* can't find valid BIOS pin config */
14027
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014028 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
14029 if (err < 0)
14030 return err;
14031 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
14032 if (err < 0)
14033 return err;
14034 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
14035 if (err < 0)
14036 return err;
14037 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
14038 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014039 return err;
14040
14041 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14042
Takashi Iwai0852d7a2009-02-11 11:35:15 +010014043 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014044 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
14045
Takashi Iwai603c4012008-07-30 15:01:44 +020014046 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014047 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010014048
Takashi Iwaid88897e2008-10-31 15:01:37 +010014049 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010014050
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020014051 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014052 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010014053
14054 spec->adc_nids = alc861_adc_nids;
14055 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014056 set_capture_mixer(spec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014057
Takashi Iwai4a79ba32009-04-22 16:31:35 +020014058 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b);
14059
Kailang Yangdf694da2005-12-05 19:42:22 +010014060 return 1;
14061}
14062
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014063/* additional initialization for auto-configuration model */
14064static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010014065{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014066 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014067 alc861_auto_init_multi_out(codec);
14068 alc861_auto_init_hp_out(codec);
14069 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014070 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014071 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014072}
14073
Takashi Iwaicb53c622007-08-10 17:21:45 +020014074#ifdef CONFIG_SND_HDA_POWER_SAVE
14075static struct hda_amp_list alc861_loopbacks[] = {
14076 { 0x15, HDA_INPUT, 0 },
14077 { 0x15, HDA_INPUT, 1 },
14078 { 0x15, HDA_INPUT, 2 },
14079 { 0x15, HDA_INPUT, 3 },
14080 { } /* end */
14081};
14082#endif
14083
Kailang Yangdf694da2005-12-05 19:42:22 +010014084
14085/*
14086 * configuration and preset
14087 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014088static const char *alc861_models[ALC861_MODEL_LAST] = {
14089 [ALC861_3ST] = "3stack",
14090 [ALC660_3ST] = "3stack-660",
14091 [ALC861_3ST_DIG] = "3stack-dig",
14092 [ALC861_6ST_DIG] = "6stack-dig",
14093 [ALC861_UNIWILL_M31] = "uniwill-m31",
14094 [ALC861_TOSHIBA] = "toshiba",
14095 [ALC861_ASUS] = "asus",
14096 [ALC861_ASUS_LAPTOP] = "asus-laptop",
14097 [ALC861_AUTO] = "auto",
14098};
14099
14100static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010014101 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014102 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14103 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14104 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014105 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020014106 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010014107 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020014108 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
14109 * Any other models that need this preset?
14110 */
14111 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020014112 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
14113 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014114 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
14115 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
14116 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
14117 /* FIXME: the below seems conflict */
14118 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
14119 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
14120 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010014121 {}
14122};
14123
14124static struct alc_config_preset alc861_presets[] = {
14125 [ALC861_3ST] = {
14126 .mixers = { alc861_3ST_mixer },
14127 .init_verbs = { alc861_threestack_init_verbs },
14128 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14129 .dac_nids = alc861_dac_nids,
14130 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14131 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014132 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014133 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14134 .adc_nids = alc861_adc_nids,
14135 .input_mux = &alc861_capture_source,
14136 },
14137 [ALC861_3ST_DIG] = {
14138 .mixers = { alc861_base_mixer },
14139 .init_verbs = { alc861_threestack_init_verbs },
14140 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14141 .dac_nids = alc861_dac_nids,
14142 .dig_out_nid = ALC861_DIGOUT_NID,
14143 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14144 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014145 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014146 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14147 .adc_nids = alc861_adc_nids,
14148 .input_mux = &alc861_capture_source,
14149 },
14150 [ALC861_6ST_DIG] = {
14151 .mixers = { alc861_base_mixer },
14152 .init_verbs = { alc861_base_init_verbs },
14153 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14154 .dac_nids = alc861_dac_nids,
14155 .dig_out_nid = ALC861_DIGOUT_NID,
14156 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
14157 .channel_mode = alc861_8ch_modes,
14158 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14159 .adc_nids = alc861_adc_nids,
14160 .input_mux = &alc861_capture_source,
14161 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014162 [ALC660_3ST] = {
14163 .mixers = { alc861_3ST_mixer },
14164 .init_verbs = { alc861_threestack_init_verbs },
14165 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
14166 .dac_nids = alc660_dac_nids,
14167 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14168 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014169 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014170 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14171 .adc_nids = alc861_adc_nids,
14172 .input_mux = &alc861_capture_source,
14173 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014174 [ALC861_UNIWILL_M31] = {
14175 .mixers = { alc861_uniwill_m31_mixer },
14176 .init_verbs = { alc861_uniwill_m31_init_verbs },
14177 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14178 .dac_nids = alc861_dac_nids,
14179 .dig_out_nid = ALC861_DIGOUT_NID,
14180 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
14181 .channel_mode = alc861_uniwill_m31_modes,
14182 .need_dac_fix = 1,
14183 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14184 .adc_nids = alc861_adc_nids,
14185 .input_mux = &alc861_capture_source,
14186 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014187 [ALC861_TOSHIBA] = {
14188 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014189 .init_verbs = { alc861_base_init_verbs,
14190 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014191 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14192 .dac_nids = alc861_dac_nids,
14193 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14194 .channel_mode = alc883_3ST_2ch_modes,
14195 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14196 .adc_nids = alc861_adc_nids,
14197 .input_mux = &alc861_capture_source,
14198 .unsol_event = alc861_toshiba_unsol_event,
14199 .init_hook = alc861_toshiba_automute,
14200 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014201 [ALC861_ASUS] = {
14202 .mixers = { alc861_asus_mixer },
14203 .init_verbs = { alc861_asus_init_verbs },
14204 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14205 .dac_nids = alc861_dac_nids,
14206 .dig_out_nid = ALC861_DIGOUT_NID,
14207 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
14208 .channel_mode = alc861_asus_modes,
14209 .need_dac_fix = 1,
14210 .hp_nid = 0x06,
14211 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14212 .adc_nids = alc861_adc_nids,
14213 .input_mux = &alc861_capture_source,
14214 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014215 [ALC861_ASUS_LAPTOP] = {
14216 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
14217 .init_verbs = { alc861_asus_init_verbs,
14218 alc861_asus_laptop_init_verbs },
14219 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14220 .dac_nids = alc861_dac_nids,
14221 .dig_out_nid = ALC861_DIGOUT_NID,
14222 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14223 .channel_mode = alc883_3ST_2ch_modes,
14224 .need_dac_fix = 1,
14225 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14226 .adc_nids = alc861_adc_nids,
14227 .input_mux = &alc861_capture_source,
14228 },
14229};
Kailang Yangdf694da2005-12-05 19:42:22 +010014230
14231
14232static int patch_alc861(struct hda_codec *codec)
14233{
14234 struct alc_spec *spec;
14235 int board_config;
14236 int err;
14237
Robert P. J. Daydc041e02006-12-19 14:44:15 +010014238 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010014239 if (spec == NULL)
14240 return -ENOMEM;
14241
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014242 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014243
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014244 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
14245 alc861_models,
14246 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014247
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014248 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014249 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
14250 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010014251 board_config = ALC861_AUTO;
14252 }
14253
14254 if (board_config == ALC861_AUTO) {
14255 /* automatic parse from the BIOS config */
14256 err = alc861_parse_auto_config(codec);
14257 if (err < 0) {
14258 alc_free(codec);
14259 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014260 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014261 printk(KERN_INFO
14262 "hda_codec: Cannot set up configuration "
14263 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010014264 board_config = ALC861_3ST_DIG;
14265 }
14266 }
14267
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014268 err = snd_hda_attach_beep_device(codec, 0x23);
14269 if (err < 0) {
14270 alc_free(codec);
14271 return err;
14272 }
14273
Kailang Yangdf694da2005-12-05 19:42:22 +010014274 if (board_config != ALC861_AUTO)
14275 setup_preset(spec, &alc861_presets[board_config]);
14276
14277 spec->stream_name_analog = "ALC861 Analog";
14278 spec->stream_analog_playback = &alc861_pcm_analog_playback;
14279 spec->stream_analog_capture = &alc861_pcm_analog_capture;
14280
14281 spec->stream_name_digital = "ALC861 Digital";
14282 spec->stream_digital_playback = &alc861_pcm_digital_playback;
14283 spec->stream_digital_capture = &alc861_pcm_digital_capture;
14284
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014285 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
14286
Takashi Iwai2134ea42008-01-10 16:53:55 +010014287 spec->vmaster_nid = 0x03;
14288
Kailang Yangdf694da2005-12-05 19:42:22 +010014289 codec->patch_ops = alc_patch_ops;
14290 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014291 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014292#ifdef CONFIG_SND_HDA_POWER_SAVE
14293 if (!spec->loopback.amplist)
14294 spec->loopback.amplist = alc861_loopbacks;
14295#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010014296 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020014297
Kailang Yangdf694da2005-12-05 19:42:22 +010014298 return 0;
14299}
14300
14301/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014302 * ALC861-VD support
14303 *
14304 * Based on ALC882
14305 *
14306 * In addition, an independent DAC
14307 */
14308#define ALC861VD_DIGOUT_NID 0x06
14309
14310static hda_nid_t alc861vd_dac_nids[4] = {
14311 /* front, surr, clfe, side surr */
14312 0x02, 0x03, 0x04, 0x05
14313};
14314
14315/* dac_nids for ALC660vd are in a different order - according to
14316 * Realtek's driver.
14317 * This should probably tesult in a different mixer for 6stack models
14318 * of ALC660vd codecs, but for now there is only 3stack mixer
14319 * - and it is the same as in 861vd.
14320 * adc_nids in ALC660vd are (is) the same as in 861vd
14321 */
14322static hda_nid_t alc660vd_dac_nids[3] = {
14323 /* front, rear, clfe, rear_surr */
14324 0x02, 0x04, 0x03
14325};
14326
14327static hda_nid_t alc861vd_adc_nids[1] = {
14328 /* ADC0 */
14329 0x09,
14330};
14331
Takashi Iwaie1406342008-02-11 18:32:32 +010014332static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
14333
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014334/* input MUX */
14335/* FIXME: should be a matrix-type input source selection */
14336static struct hda_input_mux alc861vd_capture_source = {
14337 .num_items = 4,
14338 .items = {
14339 { "Mic", 0x0 },
14340 { "Front Mic", 0x1 },
14341 { "Line", 0x2 },
14342 { "CD", 0x4 },
14343 },
14344};
14345
Kailang Yang272a5272007-05-14 11:00:38 +020014346static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010014347 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020014348 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010014349 { "Ext Mic", 0x0 },
14350 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020014351 },
14352};
14353
Kailang Yangd1a991a2007-08-15 16:21:59 +020014354static struct hda_input_mux alc861vd_hp_capture_source = {
14355 .num_items = 2,
14356 .items = {
14357 { "Front Mic", 0x0 },
14358 { "ATAPI Mic", 0x1 },
14359 },
14360};
14361
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014362/*
14363 * 2ch mode
14364 */
14365static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
14366 { 2, NULL }
14367};
14368
14369/*
14370 * 6ch mode
14371 */
14372static struct hda_verb alc861vd_6stack_ch6_init[] = {
14373 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14374 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14375 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14376 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14377 { } /* end */
14378};
14379
14380/*
14381 * 8ch mode
14382 */
14383static struct hda_verb alc861vd_6stack_ch8_init[] = {
14384 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14385 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14386 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14387 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14388 { } /* end */
14389};
14390
14391static struct hda_channel_mode alc861vd_6stack_modes[2] = {
14392 { 6, alc861vd_6stack_ch6_init },
14393 { 8, alc861vd_6stack_ch8_init },
14394};
14395
14396static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
14397 {
14398 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14399 .name = "Channel Mode",
14400 .info = alc_ch_mode_info,
14401 .get = alc_ch_mode_get,
14402 .put = alc_ch_mode_put,
14403 },
14404 { } /* end */
14405};
14406
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014407/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
14408 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
14409 */
14410static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
14411 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14412 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14413
14414 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14415 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
14416
14417 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
14418 HDA_OUTPUT),
14419 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
14420 HDA_OUTPUT),
14421 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
14422 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
14423
14424 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
14425 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
14426
14427 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14428
14429 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14430 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14431 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14432
14433 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14434 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14435 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14436
14437 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14438 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14439
14440 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14441 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14442
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014443 { } /* end */
14444};
14445
14446static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
14447 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14448 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14449
14450 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14451
14452 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14453 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14454 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14455
14456 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14457 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14458 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14459
14460 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14461 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14462
14463 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14464 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14465
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014466 { } /* end */
14467};
14468
Kailang Yangbdd148a2007-05-08 15:19:08 +020014469static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
14470 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14471 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
14472 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14473
14474 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14475
14476 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14477 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14478 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14479
14480 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14481 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14482 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14483
14484 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14485 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14486
14487 { } /* end */
14488};
14489
Tobin Davisb419f342008-03-07 11:57:51 +010014490/* Pin assignment: Speaker=0x14, HP = 0x15,
14491 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020014492 */
14493static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010014494 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14495 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014496 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14497 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010014498 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
14499 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14500 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14501 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
14502 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14503 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014504 { } /* end */
14505};
14506
Kailang Yangd1a991a2007-08-15 16:21:59 +020014507/* Pin assignment: Speaker=0x14, Line-out = 0x15,
14508 * Front Mic=0x18, ATAPI Mic = 0x19,
14509 */
14510static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
14511 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14512 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14513 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14514 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
14515 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14516 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14517 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14518 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020014519
Kailang Yangd1a991a2007-08-15 16:21:59 +020014520 { } /* end */
14521};
14522
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014523/*
14524 * generic initialization of ADC, input mixers and output mixers
14525 */
14526static struct hda_verb alc861vd_volume_init_verbs[] = {
14527 /*
14528 * Unmute ADC0 and set the default input to mic-in
14529 */
14530 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14531 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14532
14533 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
14534 * the analog-loopback mixer widget
14535 */
14536 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020014537 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14538 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14539 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14540 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14541 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014542
14543 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020014544 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14545 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14546 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014547 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014548
14549 /*
14550 * Set up output mixers (0x02 - 0x05)
14551 */
14552 /* set vol=0 to output mixers */
14553 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14554 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14555 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14556 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14557
14558 /* set up input amps for analog loopback */
14559 /* Amp Indices: DAC = 0, mixer = 1 */
14560 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14561 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14562 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14563 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14564 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14565 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14566 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14567 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14568
14569 { }
14570};
14571
14572/*
14573 * 3-stack pin configuration:
14574 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
14575 */
14576static struct hda_verb alc861vd_3stack_init_verbs[] = {
14577 /*
14578 * Set pin mode and muting
14579 */
14580 /* set front pin widgets 0x14 for output */
14581 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14582 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14583 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14584
14585 /* Mic (rear) pin: input vref at 80% */
14586 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14587 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14588 /* Front Mic pin: input vref at 80% */
14589 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14590 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14591 /* Line In pin: input */
14592 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14593 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14594 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14595 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14596 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14597 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14598 /* CD pin widget for input */
14599 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14600
14601 { }
14602};
14603
14604/*
14605 * 6-stack pin configuration:
14606 */
14607static struct hda_verb alc861vd_6stack_init_verbs[] = {
14608 /*
14609 * Set pin mode and muting
14610 */
14611 /* set front pin widgets 0x14 for output */
14612 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14613 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14614 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14615
14616 /* Rear Pin: output 1 (0x0d) */
14617 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14618 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14619 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14620 /* CLFE Pin: output 2 (0x0e) */
14621 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14622 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14623 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
14624 /* Side Pin: output 3 (0x0f) */
14625 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14626 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14627 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
14628
14629 /* Mic (rear) pin: input vref at 80% */
14630 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14631 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14632 /* Front Mic pin: input vref at 80% */
14633 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14634 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14635 /* Line In pin: input */
14636 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14637 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14638 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14639 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14640 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14641 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14642 /* CD pin widget for input */
14643 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14644
14645 { }
14646};
14647
Kailang Yangbdd148a2007-05-08 15:19:08 +020014648static struct hda_verb alc861vd_eapd_verbs[] = {
14649 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14650 { }
14651};
14652
Kailang Yangf9423e72008-05-27 12:32:25 +020014653static struct hda_verb alc660vd_eapd_verbs[] = {
14654 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14655 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
14656 { }
14657};
14658
Kailang Yangbdd148a2007-05-08 15:19:08 +020014659static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
14660 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14661 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14662 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
14663 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020014664 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020014665 {}
14666};
14667
14668/* toggle speaker-output according to the hp-jack state */
14669static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
14670{
14671 unsigned int present;
14672 unsigned char bits;
14673
14674 present = snd_hda_codec_read(codec, 0x1b, 0,
14675 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014676 bits = present ? HDA_AMP_MUTE : 0;
14677 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14678 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014679}
14680
14681static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
14682{
14683 unsigned int present;
14684 unsigned char bits;
14685
14686 present = snd_hda_codec_read(codec, 0x18, 0,
14687 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014688 bits = present ? HDA_AMP_MUTE : 0;
14689 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
14690 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014691}
14692
14693static void alc861vd_lenovo_automute(struct hda_codec *codec)
14694{
14695 alc861vd_lenovo_hp_automute(codec);
14696 alc861vd_lenovo_mic_automute(codec);
14697}
14698
14699static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
14700 unsigned int res)
14701{
14702 switch (res >> 26) {
14703 case ALC880_HP_EVENT:
14704 alc861vd_lenovo_hp_automute(codec);
14705 break;
14706 case ALC880_MIC_EVENT:
14707 alc861vd_lenovo_mic_automute(codec);
14708 break;
14709 }
14710}
14711
Kailang Yang272a5272007-05-14 11:00:38 +020014712static struct hda_verb alc861vd_dallas_verbs[] = {
14713 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14714 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14715 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14716 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14717
14718 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14719 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14720 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14721 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14722 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14723 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14724 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14725 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014726
Kailang Yang272a5272007-05-14 11:00:38 +020014727 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14728 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14729 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14730 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14731 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14732 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14733 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14734 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14735
14736 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14737 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14738 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14739 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14740 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14741 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14742 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14743 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14744
14745 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14746 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14747 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14748 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
14749
14750 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014751 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020014752 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14753
14754 { } /* end */
14755};
14756
14757/* toggle speaker-output according to the hp-jack state */
14758static void alc861vd_dallas_automute(struct hda_codec *codec)
14759{
14760 unsigned int present;
14761
14762 present = snd_hda_codec_read(codec, 0x15, 0,
14763 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014764 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14765 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +020014766}
14767
14768static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
14769{
14770 if ((res >> 26) == ALC880_HP_EVENT)
14771 alc861vd_dallas_automute(codec);
14772}
14773
Takashi Iwaicb53c622007-08-10 17:21:45 +020014774#ifdef CONFIG_SND_HDA_POWER_SAVE
14775#define alc861vd_loopbacks alc880_loopbacks
14776#endif
14777
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014778/* pcm configuration: identiacal with ALC880 */
14779#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
14780#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
14781#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
14782#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
14783
14784/*
14785 * configuration and preset
14786 */
14787static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
14788 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020014789 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010014790 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014791 [ALC861VD_3ST] = "3stack",
14792 [ALC861VD_3ST_DIG] = "3stack-digout",
14793 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020014794 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020014795 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020014796 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014797 [ALC861VD_AUTO] = "auto",
14798};
14799
14800static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014801 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
14802 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010014803 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014804 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Takashi Iwai13c94742008-11-05 08:06:08 +010014805 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020014806 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014807 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014808 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020014809 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Kailang Yang272a5272007-05-14 11:00:38 +020014810 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Takashi Iwai542d7c62007-08-16 18:57:30 +020014811 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010014812 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020014813 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010014814 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020014815 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014816 {}
14817};
14818
14819static struct alc_config_preset alc861vd_presets[] = {
14820 [ALC660VD_3ST] = {
14821 .mixers = { alc861vd_3st_mixer },
14822 .init_verbs = { alc861vd_volume_init_verbs,
14823 alc861vd_3stack_init_verbs },
14824 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14825 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014826 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14827 .channel_mode = alc861vd_3stack_2ch_modes,
14828 .input_mux = &alc861vd_capture_source,
14829 },
Mike Crash6963f842007-06-25 12:12:51 +020014830 [ALC660VD_3ST_DIG] = {
14831 .mixers = { alc861vd_3st_mixer },
14832 .init_verbs = { alc861vd_volume_init_verbs,
14833 alc861vd_3stack_init_verbs },
14834 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14835 .dac_nids = alc660vd_dac_nids,
14836 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020014837 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14838 .channel_mode = alc861vd_3stack_2ch_modes,
14839 .input_mux = &alc861vd_capture_source,
14840 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014841 [ALC861VD_3ST] = {
14842 .mixers = { alc861vd_3st_mixer },
14843 .init_verbs = { alc861vd_volume_init_verbs,
14844 alc861vd_3stack_init_verbs },
14845 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14846 .dac_nids = alc861vd_dac_nids,
14847 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14848 .channel_mode = alc861vd_3stack_2ch_modes,
14849 .input_mux = &alc861vd_capture_source,
14850 },
14851 [ALC861VD_3ST_DIG] = {
14852 .mixers = { alc861vd_3st_mixer },
14853 .init_verbs = { alc861vd_volume_init_verbs,
14854 alc861vd_3stack_init_verbs },
14855 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14856 .dac_nids = alc861vd_dac_nids,
14857 .dig_out_nid = ALC861VD_DIGOUT_NID,
14858 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14859 .channel_mode = alc861vd_3stack_2ch_modes,
14860 .input_mux = &alc861vd_capture_source,
14861 },
14862 [ALC861VD_6ST_DIG] = {
14863 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
14864 .init_verbs = { alc861vd_volume_init_verbs,
14865 alc861vd_6stack_init_verbs },
14866 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14867 .dac_nids = alc861vd_dac_nids,
14868 .dig_out_nid = ALC861VD_DIGOUT_NID,
14869 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
14870 .channel_mode = alc861vd_6stack_modes,
14871 .input_mux = &alc861vd_capture_source,
14872 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020014873 [ALC861VD_LENOVO] = {
14874 .mixers = { alc861vd_lenovo_mixer },
14875 .init_verbs = { alc861vd_volume_init_verbs,
14876 alc861vd_3stack_init_verbs,
14877 alc861vd_eapd_verbs,
14878 alc861vd_lenovo_unsol_verbs },
14879 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14880 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020014881 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14882 .channel_mode = alc861vd_3stack_2ch_modes,
14883 .input_mux = &alc861vd_capture_source,
14884 .unsol_event = alc861vd_lenovo_unsol_event,
14885 .init_hook = alc861vd_lenovo_automute,
14886 },
Kailang Yang272a5272007-05-14 11:00:38 +020014887 [ALC861VD_DALLAS] = {
14888 .mixers = { alc861vd_dallas_mixer },
14889 .init_verbs = { alc861vd_dallas_verbs },
14890 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14891 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020014892 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14893 .channel_mode = alc861vd_3stack_2ch_modes,
14894 .input_mux = &alc861vd_dallas_capture_source,
14895 .unsol_event = alc861vd_dallas_unsol_event,
14896 .init_hook = alc861vd_dallas_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014897 },
14898 [ALC861VD_HP] = {
14899 .mixers = { alc861vd_hp_mixer },
14900 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
14901 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14902 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014903 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014904 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14905 .channel_mode = alc861vd_3stack_2ch_modes,
14906 .input_mux = &alc861vd_hp_capture_source,
14907 .unsol_event = alc861vd_dallas_unsol_event,
14908 .init_hook = alc861vd_dallas_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020014909 },
Takashi Iwai13c94742008-11-05 08:06:08 +010014910 [ALC660VD_ASUS_V1S] = {
14911 .mixers = { alc861vd_lenovo_mixer },
14912 .init_verbs = { alc861vd_volume_init_verbs,
14913 alc861vd_3stack_init_verbs,
14914 alc861vd_eapd_verbs,
14915 alc861vd_lenovo_unsol_verbs },
14916 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14917 .dac_nids = alc660vd_dac_nids,
14918 .dig_out_nid = ALC861VD_DIGOUT_NID,
14919 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14920 .channel_mode = alc861vd_3stack_2ch_modes,
14921 .input_mux = &alc861vd_capture_source,
14922 .unsol_event = alc861vd_lenovo_unsol_event,
14923 .init_hook = alc861vd_lenovo_automute,
14924 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014925};
14926
14927/*
14928 * BIOS auto configuration
14929 */
14930static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
14931 hda_nid_t nid, int pin_type, int dac_idx)
14932{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014933 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014934}
14935
14936static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
14937{
14938 struct alc_spec *spec = codec->spec;
14939 int i;
14940
14941 for (i = 0; i <= HDA_SIDE; i++) {
14942 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014943 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014944 if (nid)
14945 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014946 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014947 }
14948}
14949
14950
14951static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
14952{
14953 struct alc_spec *spec = codec->spec;
14954 hda_nid_t pin;
14955
14956 pin = spec->autocfg.hp_pins[0];
14957 if (pin) /* connect to front and use dac 0 */
14958 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014959 pin = spec->autocfg.speaker_pins[0];
14960 if (pin)
14961 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014962}
14963
14964#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
14965#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
14966
14967static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
14968{
14969 struct alc_spec *spec = codec->spec;
14970 int i;
14971
14972 for (i = 0; i < AUTO_PIN_LAST; i++) {
14973 hda_nid_t nid = spec->autocfg.input_pins[i];
14974 if (alc861vd_is_input_pin(nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010014975 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +010014976 if (nid != ALC861VD_PIN_CD_NID &&
14977 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014978 snd_hda_codec_write(codec, nid, 0,
14979 AC_VERB_SET_AMP_GAIN_MUTE,
14980 AMP_OUT_MUTE);
14981 }
14982 }
14983}
14984
Takashi Iwaif511b012008-08-15 16:46:42 +020014985#define alc861vd_auto_init_input_src alc882_auto_init_input_src
14986
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014987#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
14988#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
14989
14990/* add playback controls from the parsed DAC table */
14991/* Based on ALC880 version. But ALC861VD has separate,
14992 * different NIDs for mute/unmute switch and volume control */
14993static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
14994 const struct auto_pin_cfg *cfg)
14995{
14996 char name[32];
14997 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
14998 hda_nid_t nid_v, nid_s;
14999 int i, err;
15000
15001 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015002 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015003 continue;
15004 nid_v = alc861vd_idx_to_mixer_vol(
15005 alc880_dac_to_idx(
15006 spec->multiout.dac_nids[i]));
15007 nid_s = alc861vd_idx_to_mixer_switch(
15008 alc880_dac_to_idx(
15009 spec->multiout.dac_nids[i]));
15010
15011 if (i == 2) {
15012 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015013 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15014 "Center Playback Volume",
15015 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
15016 HDA_OUTPUT));
15017 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015018 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015019 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15020 "LFE Playback Volume",
15021 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
15022 HDA_OUTPUT));
15023 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015024 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015025 err = add_control(spec, ALC_CTL_BIND_MUTE,
15026 "Center Playback Switch",
15027 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
15028 HDA_INPUT));
15029 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015030 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015031 err = add_control(spec, ALC_CTL_BIND_MUTE,
15032 "LFE Playback Switch",
15033 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
15034 HDA_INPUT));
15035 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015036 return err;
15037 } else {
15038 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015039 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
15040 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
15041 HDA_OUTPUT));
15042 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015043 return err;
15044 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015045 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015046 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015047 HDA_INPUT));
15048 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015049 return err;
15050 }
15051 }
15052 return 0;
15053}
15054
15055/* add playback controls for speaker and HP outputs */
15056/* Based on ALC880 version. But ALC861VD has separate,
15057 * different NIDs for mute/unmute switch and volume control */
15058static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
15059 hda_nid_t pin, const char *pfx)
15060{
15061 hda_nid_t nid_v, nid_s;
15062 int err;
15063 char name[32];
15064
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015065 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015066 return 0;
15067
15068 if (alc880_is_fixed_pin(pin)) {
15069 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
15070 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015071 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015072 spec->multiout.hp_nid = nid_v;
15073 else
15074 spec->multiout.extra_out_nid[0] = nid_v;
15075 /* control HP volume/switch on the output mixer amp */
15076 nid_v = alc861vd_idx_to_mixer_vol(
15077 alc880_fixed_pin_idx(pin));
15078 nid_s = alc861vd_idx_to_mixer_switch(
15079 alc880_fixed_pin_idx(pin));
15080
15081 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015082 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
15083 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
15084 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015085 return err;
15086 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015087 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
15088 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
15089 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015090 return err;
15091 } else if (alc880_is_multi_pin(pin)) {
15092 /* set manual connection */
15093 /* we have only a switch on HP-out PIN */
15094 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015095 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
15096 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
15097 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015098 return err;
15099 }
15100 return 0;
15101}
15102
15103/* parse the BIOS configuration and set up the alc_spec
15104 * return 1 if successful, 0 if the proper config is not found,
15105 * or a negative error code
15106 * Based on ALC880 version - had to change it to override
15107 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
15108static int alc861vd_parse_auto_config(struct hda_codec *codec)
15109{
15110 struct alc_spec *spec = codec->spec;
15111 int err;
15112 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
15113
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015114 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15115 alc861vd_ignore);
15116 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015117 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015118 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015119 return 0; /* can't find valid BIOS pin config */
15120
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015121 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
15122 if (err < 0)
15123 return err;
15124 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
15125 if (err < 0)
15126 return err;
15127 err = alc861vd_auto_create_extra_out(spec,
15128 spec->autocfg.speaker_pins[0],
15129 "Speaker");
15130 if (err < 0)
15131 return err;
15132 err = alc861vd_auto_create_extra_out(spec,
15133 spec->autocfg.hp_pins[0],
15134 "Headphone");
15135 if (err < 0)
15136 return err;
15137 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
15138 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015139 return err;
15140
15141 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15142
Takashi Iwai0852d7a2009-02-11 11:35:15 +010015143 if (spec->autocfg.dig_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015144 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
15145
Takashi Iwai603c4012008-07-30 15:01:44 +020015146 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010015147 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015148
Takashi Iwaid88897e2008-10-31 15:01:37 +010015149 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015150
15151 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015152 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015153
Takashi Iwai776e1842007-08-29 15:07:11 +020015154 err = alc_auto_add_mic_boost(codec);
15155 if (err < 0)
15156 return err;
15157
Takashi Iwai4a79ba32009-04-22 16:31:35 +020015158 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
15159
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015160 return 1;
15161}
15162
15163/* additional initialization for auto-configuration model */
15164static void alc861vd_auto_init(struct hda_codec *codec)
15165{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015166 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015167 alc861vd_auto_init_multi_out(codec);
15168 alc861vd_auto_init_hp_out(codec);
15169 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020015170 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015171 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020015172 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015173}
15174
15175static int patch_alc861vd(struct hda_codec *codec)
15176{
15177 struct alc_spec *spec;
15178 int err, board_config;
15179
15180 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15181 if (spec == NULL)
15182 return -ENOMEM;
15183
15184 codec->spec = spec;
15185
15186 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
15187 alc861vd_models,
15188 alc861vd_cfg_tbl);
15189
15190 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
15191 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
15192 "ALC861VD, trying auto-probe from BIOS...\n");
15193 board_config = ALC861VD_AUTO;
15194 }
15195
15196 if (board_config == ALC861VD_AUTO) {
15197 /* automatic parse from the BIOS config */
15198 err = alc861vd_parse_auto_config(codec);
15199 if (err < 0) {
15200 alc_free(codec);
15201 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015202 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015203 printk(KERN_INFO
15204 "hda_codec: Cannot set up configuration "
15205 "from BIOS. Using base mode...\n");
15206 board_config = ALC861VD_3ST;
15207 }
15208 }
15209
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015210 err = snd_hda_attach_beep_device(codec, 0x23);
15211 if (err < 0) {
15212 alc_free(codec);
15213 return err;
15214 }
15215
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015216 if (board_config != ALC861VD_AUTO)
15217 setup_preset(spec, &alc861vd_presets[board_config]);
15218
Kailang Yang2f893282008-05-27 12:14:47 +020015219 if (codec->vendor_id == 0x10ec0660) {
15220 spec->stream_name_analog = "ALC660-VD Analog";
15221 spec->stream_name_digital = "ALC660-VD Digital";
Kailang Yangf9423e72008-05-27 12:32:25 +020015222 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010015223 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020015224 } else {
15225 spec->stream_name_analog = "ALC861VD Analog";
15226 spec->stream_name_digital = "ALC861VD Digital";
15227 }
15228
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015229 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
15230 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
15231
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015232 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
15233 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
15234
15235 spec->adc_nids = alc861vd_adc_nids;
15236 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +010015237 spec->capsrc_nids = alc861vd_capsrc_nids;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015238 spec->capture_style = CAPT_MIX;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015239
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015240 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015241 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015242
Takashi Iwai2134ea42008-01-10 16:53:55 +010015243 spec->vmaster_nid = 0x02;
15244
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015245 codec->patch_ops = alc_patch_ops;
15246
15247 if (board_config == ALC861VD_AUTO)
15248 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015249#ifdef CONFIG_SND_HDA_POWER_SAVE
15250 if (!spec->loopback.amplist)
15251 spec->loopback.amplist = alc861vd_loopbacks;
15252#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010015253 codec->proc_widget_hook = print_realtek_coef;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015254
15255 return 0;
15256}
15257
15258/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015259 * ALC662 support
15260 *
15261 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
15262 * configuration. Each pin widget can choose any input DACs and a mixer.
15263 * Each ADC is connected from a mixer of all inputs. This makes possible
15264 * 6-channel independent captures.
15265 *
15266 * In addition, an independent DAC for the multi-playback (not used in this
15267 * driver yet).
15268 */
15269#define ALC662_DIGOUT_NID 0x06
15270#define ALC662_DIGIN_NID 0x0a
15271
15272static hda_nid_t alc662_dac_nids[4] = {
15273 /* front, rear, clfe, rear_surr */
15274 0x02, 0x03, 0x04
15275};
15276
Kailang Yang622e84c2009-04-21 07:39:04 +020015277static hda_nid_t alc272_dac_nids[2] = {
15278 0x02, 0x03
15279};
15280
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015281static hda_nid_t alc662_adc_nids[1] = {
15282 /* ADC1-2 */
15283 0x09,
15284};
Takashi Iwaie1406342008-02-11 18:32:32 +010015285
Kailang Yang622e84c2009-04-21 07:39:04 +020015286static hda_nid_t alc272_adc_nids[1] = {
15287 /* ADC1-2 */
15288 0x08,
15289};
15290
Kailang Yang77a261b2008-02-19 11:38:05 +010015291static hda_nid_t alc662_capsrc_nids[1] = { 0x22 };
Kailang Yang622e84c2009-04-21 07:39:04 +020015292static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
15293
Takashi Iwaie1406342008-02-11 18:32:32 +010015294
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015295/* input MUX */
15296/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015297static struct hda_input_mux alc662_capture_source = {
15298 .num_items = 4,
15299 .items = {
15300 { "Mic", 0x0 },
15301 { "Front Mic", 0x1 },
15302 { "Line", 0x2 },
15303 { "CD", 0x4 },
15304 },
15305};
15306
15307static struct hda_input_mux alc662_lenovo_101e_capture_source = {
15308 .num_items = 2,
15309 .items = {
15310 { "Mic", 0x1 },
15311 { "Line", 0x2 },
15312 },
15313};
Kailang Yang291702f2007-10-16 14:28:03 +020015314
15315static struct hda_input_mux alc662_eeepc_capture_source = {
15316 .num_items = 2,
15317 .items = {
15318 { "i-Mic", 0x1 },
15319 { "e-Mic", 0x0 },
15320 },
15321};
15322
Kailang Yang6dda9f42008-05-27 12:05:31 +020015323static struct hda_input_mux alc663_capture_source = {
15324 .num_items = 3,
15325 .items = {
15326 { "Mic", 0x0 },
15327 { "Front Mic", 0x1 },
15328 { "Line", 0x2 },
15329 },
15330};
15331
15332static struct hda_input_mux alc663_m51va_capture_source = {
15333 .num_items = 2,
15334 .items = {
15335 { "Ext-Mic", 0x0 },
15336 { "D-Mic", 0x9 },
15337 },
15338};
15339
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015340/*
15341 * 2ch mode
15342 */
15343static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
15344 { 2, NULL }
15345};
15346
15347/*
15348 * 2ch mode
15349 */
15350static struct hda_verb alc662_3ST_ch2_init[] = {
15351 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
15352 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15353 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
15354 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15355 { } /* end */
15356};
15357
15358/*
15359 * 6ch mode
15360 */
15361static struct hda_verb alc662_3ST_ch6_init[] = {
15362 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15363 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15364 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
15365 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15366 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15367 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
15368 { } /* end */
15369};
15370
15371static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
15372 { 2, alc662_3ST_ch2_init },
15373 { 6, alc662_3ST_ch6_init },
15374};
15375
15376/*
15377 * 2ch mode
15378 */
15379static struct hda_verb alc662_sixstack_ch6_init[] = {
15380 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15381 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15382 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15383 { } /* end */
15384};
15385
15386/*
15387 * 6ch mode
15388 */
15389static struct hda_verb alc662_sixstack_ch8_init[] = {
15390 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15391 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15392 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15393 { } /* end */
15394};
15395
15396static struct hda_channel_mode alc662_5stack_modes[2] = {
15397 { 2, alc662_sixstack_ch6_init },
15398 { 6, alc662_sixstack_ch8_init },
15399};
15400
15401/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15402 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15403 */
15404
15405static struct snd_kcontrol_new alc662_base_mixer[] = {
15406 /* output mixer control */
15407 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015408 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015409 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015410 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015411 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15412 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015413 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15414 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015415 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15416
15417 /*Input mixer control */
15418 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
15419 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
15420 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
15421 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
15422 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
15423 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
15424 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
15425 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015426 { } /* end */
15427};
15428
15429static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
15430 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015431 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015432 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15433 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15434 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15435 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15436 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15437 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15438 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15439 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15440 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015441 { } /* end */
15442};
15443
15444static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
15445 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015446 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015447 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015448 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015449 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15450 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015451 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15452 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015453 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15454 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15455 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15456 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15457 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15458 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15459 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15460 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15461 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015462 { } /* end */
15463};
15464
15465static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
15466 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15467 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010015468 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15469 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015470 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15471 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15472 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15473 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15474 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015475 { } /* end */
15476};
15477
Kailang Yang291702f2007-10-16 14:28:03 +020015478static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010015479 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020015480
Herton Ronaldo Krzesinskib4818492008-02-23 11:34:12 +010015481 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15482 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020015483
15484 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
15485 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15486 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15487
15488 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
15489 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15490 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15491 { } /* end */
15492};
15493
Kailang Yang8c427222008-01-10 13:03:59 +010015494static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai31bffaa2008-02-27 16:10:44 +010015495 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15496 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015497 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15498 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
15499 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15500 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
15501 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
15502 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010015503 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015504 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
15505 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15506 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15507 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15508 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15509 { } /* end */
15510};
15511
Kailang Yangf1d4e282008-08-26 14:03:29 +020015512static struct hda_bind_ctls alc663_asus_bind_master_vol = {
15513 .ops = &snd_hda_bind_vol,
15514 .values = {
15515 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15516 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
15517 0
15518 },
15519};
15520
15521static struct hda_bind_ctls alc663_asus_one_bind_switch = {
15522 .ops = &snd_hda_bind_sw,
15523 .values = {
15524 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15525 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15526 0
15527 },
15528};
15529
Kailang Yang6dda9f42008-05-27 12:05:31 +020015530static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015531 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15532 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
15533 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15534 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15535 { } /* end */
15536};
15537
15538static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
15539 .ops = &snd_hda_bind_sw,
15540 .values = {
15541 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15542 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15543 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15544 0
15545 },
15546};
15547
15548static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
15549 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15550 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
15551 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15552 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15553 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15554 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15555
15556 { } /* end */
15557};
15558
15559static struct hda_bind_ctls alc663_asus_four_bind_switch = {
15560 .ops = &snd_hda_bind_sw,
15561 .values = {
15562 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15563 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15564 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
15565 0
15566 },
15567};
15568
15569static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
15570 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15571 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
15572 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15573 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15574 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15575 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15576 { } /* end */
15577};
15578
15579static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020015580 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15581 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015582 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15583 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15584 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15585 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15586 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15587 { } /* end */
15588};
15589
15590static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
15591 .ops = &snd_hda_bind_vol,
15592 .values = {
15593 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15594 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
15595 0
15596 },
15597};
15598
15599static struct hda_bind_ctls alc663_asus_two_bind_switch = {
15600 .ops = &snd_hda_bind_sw,
15601 .values = {
15602 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15603 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
15604 0
15605 },
15606};
15607
15608static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
15609 HDA_BIND_VOL("Master Playback Volume",
15610 &alc663_asus_two_bind_master_vol),
15611 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15612 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015613 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15614 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15615 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015616 { } /* end */
15617};
15618
15619static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
15620 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15621 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15622 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15623 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15624 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15625 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015626 { } /* end */
15627};
15628
15629static struct snd_kcontrol_new alc663_g71v_mixer[] = {
15630 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15631 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15632 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15633 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15634 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15635
15636 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15637 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15638 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15639 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15640 { } /* end */
15641};
15642
15643static struct snd_kcontrol_new alc663_g50v_mixer[] = {
15644 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15645 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15646 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15647
15648 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15649 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15650 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15651 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15652 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15653 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15654 { } /* end */
15655};
15656
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015657static struct snd_kcontrol_new alc662_chmode_mixer[] = {
15658 {
15659 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15660 .name = "Channel Mode",
15661 .info = alc_ch_mode_info,
15662 .get = alc_ch_mode_get,
15663 .put = alc_ch_mode_put,
15664 },
15665 { } /* end */
15666};
15667
15668static struct hda_verb alc662_init_verbs[] = {
15669 /* ADC: mute amp left and right */
15670 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15671 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15672 /* Front mixer: unmute input/output amp left and right (volume = 0) */
15673
Takashi Iwaicb53c622007-08-10 17:21:45 +020015674 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15675 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15676 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15677 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15678 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015679
Kailang Yangb60dd392007-09-20 12:50:29 +020015680 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15681 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15682 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15683 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15684 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15685 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015686
15687 /* Front Pin: output 0 (0x0c) */
15688 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15689 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15690
15691 /* Rear Pin: output 1 (0x0d) */
15692 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15693 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15694
15695 /* CLFE Pin: output 2 (0x0e) */
15696 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15697 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15698
15699 /* Mic (rear) pin: input vref at 80% */
15700 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15701 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15702 /* Front Mic pin: input vref at 80% */
15703 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15704 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15705 /* Line In pin: input */
15706 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15707 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15708 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15709 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15710 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15711 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15712 /* CD pin widget for input */
15713 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15714
15715 /* FIXME: use matrix-type input source selection */
15716 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15717 /* Input mixer */
15718 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020015719 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015720
15721 /* always trun on EAPD */
15722 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15723 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
15724
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015725 { }
15726};
15727
15728static struct hda_verb alc662_sue_init_verbs[] = {
15729 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15730 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020015731 {}
15732};
15733
15734static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
15735 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15736 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15737 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015738};
15739
Kailang Yang8c427222008-01-10 13:03:59 +010015740/* Set Unsolicited Event*/
15741static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
15742 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15743 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15744 {}
15745};
15746
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015747/*
15748 * generic initialization of ADC, input mixers and output mixers
15749 */
15750static struct hda_verb alc662_auto_init_verbs[] = {
15751 /*
15752 * Unmute ADC and set the default input to mic-in
15753 */
15754 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15755 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15756
15757 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
15758 * mixer widget
15759 * Note: PASD motherboards uses the Line In 2 as the input for front
15760 * panel mic (mic 2)
15761 */
15762 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020015763 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15764 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15765 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15766 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15767 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015768
15769 /*
15770 * Set up output mixers (0x0c - 0x0f)
15771 */
15772 /* set vol=0 to output mixers */
15773 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15774 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15775 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15776
15777 /* set up input amps for analog loopback */
15778 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020015779 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15780 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15781 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15782 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15783 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15784 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015785
15786
15787 /* FIXME: use matrix-type input source selection */
15788 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15789 /* Input mixer */
15790 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020015791 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015792 { }
15793};
15794
Takashi Iwai24fb9172008-09-02 14:48:20 +020015795/* additional verbs for ALC663 */
15796static struct hda_verb alc663_auto_init_verbs[] = {
15797 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15798 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15799 { }
15800};
15801
Kailang Yang6dda9f42008-05-27 12:05:31 +020015802static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015803 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15804 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015805 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15806 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020015807 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15808 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15809 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015810 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15811 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15812 {}
15813};
15814
Kailang Yangf1d4e282008-08-26 14:03:29 +020015815static struct hda_verb alc663_21jd_amic_init_verbs[] = {
15816 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15817 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15818 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15819 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15820 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15821 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15822 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15823 {}
15824};
15825
15826static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
15827 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15828 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15829 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15830 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15831 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15832 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15833 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15834 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15835 {}
15836};
15837
15838static struct hda_verb alc663_15jd_amic_init_verbs[] = {
15839 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15840 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15841 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15842 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15843 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15844 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15845 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15846 {}
15847};
15848
15849static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
15850 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15851 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15852 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15853 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15854 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15855 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15856 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15857 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15858 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15859 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15860 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15861 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15862 {}
15863};
15864
15865static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
15866 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15867 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15868 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15869 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15870 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15871 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15872 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15873 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15874 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15875 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15876 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15877 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15878 {}
15879};
15880
Kailang Yang6dda9f42008-05-27 12:05:31 +020015881static struct hda_verb alc663_g71v_init_verbs[] = {
15882 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15883 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
15884 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
15885
15886 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15887 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15888 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15889
15890 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15891 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
15892 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
15893 {}
15894};
15895
15896static struct hda_verb alc663_g50v_init_verbs[] = {
15897 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15898 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15899 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15900
15901 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15902 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15903 {}
15904};
15905
Kailang Yangf1d4e282008-08-26 14:03:29 +020015906static struct hda_verb alc662_ecs_init_verbs[] = {
15907 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
15908 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15909 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15910 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15911 {}
15912};
15913
Kailang Yang622e84c2009-04-21 07:39:04 +020015914static struct hda_verb alc272_dell_zm1_init_verbs[] = {
15915 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15916 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15917 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15918 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15919 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15920 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15921 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15922 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15923 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
15924 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15925 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15926 {}
15927};
15928
15929static struct hda_verb alc272_dell_init_verbs[] = {
15930 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15931 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15932 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15933 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15934 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15935 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15936 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15937 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15938 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
15939 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15940 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15941 {}
15942};
15943
Kailang Yangf1d4e282008-08-26 14:03:29 +020015944static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
15945 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
15946 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
15947 { } /* end */
15948};
15949
Kailang Yang622e84c2009-04-21 07:39:04 +020015950static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
15951 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
15952 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
15953 { } /* end */
15954};
15955
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015956static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
15957{
15958 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015959 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015960
15961 present = snd_hda_codec_read(codec, 0x14, 0,
15962 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020015963 bits = present ? HDA_AMP_MUTE : 0;
15964 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15965 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015966}
15967
15968static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
15969{
15970 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015971 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015972
15973 present = snd_hda_codec_read(codec, 0x1b, 0,
15974 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020015975 bits = present ? HDA_AMP_MUTE : 0;
15976 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15977 HDA_AMP_MUTE, bits);
15978 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
15979 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015980}
15981
15982static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
15983 unsigned int res)
15984{
15985 if ((res >> 26) == ALC880_HP_EVENT)
15986 alc662_lenovo_101e_all_automute(codec);
15987 if ((res >> 26) == ALC880_FRONT_EVENT)
15988 alc662_lenovo_101e_ispeaker_automute(codec);
15989}
15990
Kailang Yang291702f2007-10-16 14:28:03 +020015991static void alc662_eeepc_mic_automute(struct hda_codec *codec)
15992{
15993 unsigned int present;
15994
15995 present = snd_hda_codec_read(codec, 0x18, 0,
15996 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
15997 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15998 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
15999 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16000 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
16001 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16002 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
16003 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16004 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
16005}
16006
16007/* unsolicited event for HP jack sensing */
16008static void alc662_eeepc_unsol_event(struct hda_codec *codec,
16009 unsigned int res)
16010{
16011 if ((res >> 26) == ALC880_HP_EVENT)
16012 alc262_hippo1_automute( codec );
16013
16014 if ((res >> 26) == ALC880_MIC_EVENT)
16015 alc662_eeepc_mic_automute(codec);
16016}
16017
16018static void alc662_eeepc_inithook(struct hda_codec *codec)
16019{
16020 alc262_hippo1_automute( codec );
16021 alc662_eeepc_mic_automute(codec);
16022}
16023
Kailang Yang8c427222008-01-10 13:03:59 +010016024static void alc662_eeepc_ep20_automute(struct hda_codec *codec)
16025{
16026 unsigned int mute;
16027 unsigned int present;
16028
16029 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
16030 present = snd_hda_codec_read(codec, 0x14, 0,
16031 AC_VERB_GET_PIN_SENSE, 0);
16032 present = (present & 0x80000000) != 0;
16033 if (present) {
16034 /* mute internal speaker */
16035 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020016036 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yang8c427222008-01-10 13:03:59 +010016037 } else {
16038 /* unmute internal speaker if necessary */
16039 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
16040 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020016041 HDA_AMP_MUTE, mute);
Kailang Yang8c427222008-01-10 13:03:59 +010016042 }
16043}
16044
16045/* unsolicited event for HP jack sensing */
16046static void alc662_eeepc_ep20_unsol_event(struct hda_codec *codec,
16047 unsigned int res)
16048{
16049 if ((res >> 26) == ALC880_HP_EVENT)
16050 alc662_eeepc_ep20_automute(codec);
16051}
16052
16053static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
16054{
16055 alc662_eeepc_ep20_automute(codec);
16056}
16057
Kailang Yang6dda9f42008-05-27 12:05:31 +020016058static void alc663_m51va_speaker_automute(struct hda_codec *codec)
16059{
16060 unsigned int present;
16061 unsigned char bits;
16062
16063 present = snd_hda_codec_read(codec, 0x21, 0,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016064 AC_VERB_GET_PIN_SENSE, 0)
16065 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020016066 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020016067 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16068 AMP_IN_MUTE(0), bits);
16069 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16070 AMP_IN_MUTE(0), bits);
16071}
16072
16073static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
16074{
16075 unsigned int present;
16076 unsigned char bits;
16077
16078 present = snd_hda_codec_read(codec, 0x21, 0,
16079 AC_VERB_GET_PIN_SENSE, 0)
16080 & AC_PINSENSE_PRESENCE;
16081 bits = present ? HDA_AMP_MUTE : 0;
16082 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16083 AMP_IN_MUTE(0), bits);
16084 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16085 AMP_IN_MUTE(0), bits);
16086 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16087 AMP_IN_MUTE(0), bits);
16088 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16089 AMP_IN_MUTE(0), bits);
16090}
16091
16092static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
16093{
16094 unsigned int present;
16095 unsigned char bits;
16096
16097 present = snd_hda_codec_read(codec, 0x15, 0,
16098 AC_VERB_GET_PIN_SENSE, 0)
16099 & AC_PINSENSE_PRESENCE;
16100 bits = present ? HDA_AMP_MUTE : 0;
16101 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16102 AMP_IN_MUTE(0), bits);
16103 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16104 AMP_IN_MUTE(0), bits);
16105 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16106 AMP_IN_MUTE(0), bits);
16107 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16108 AMP_IN_MUTE(0), bits);
16109}
16110
16111static void alc662_f5z_speaker_automute(struct hda_codec *codec)
16112{
16113 unsigned int present;
16114 unsigned char bits;
16115
16116 present = snd_hda_codec_read(codec, 0x1b, 0,
16117 AC_VERB_GET_PIN_SENSE, 0)
16118 & AC_PINSENSE_PRESENCE;
16119 bits = present ? 0 : PIN_OUT;
16120 snd_hda_codec_write(codec, 0x14, 0,
16121 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
16122}
16123
16124static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
16125{
16126 unsigned int present1, present2;
16127
16128 present1 = snd_hda_codec_read(codec, 0x21, 0,
16129 AC_VERB_GET_PIN_SENSE, 0)
16130 & AC_PINSENSE_PRESENCE;
16131 present2 = snd_hda_codec_read(codec, 0x15, 0,
16132 AC_VERB_GET_PIN_SENSE, 0)
16133 & AC_PINSENSE_PRESENCE;
16134
16135 if (present1 || present2) {
16136 snd_hda_codec_write_cache(codec, 0x14, 0,
16137 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16138 } else {
16139 snd_hda_codec_write_cache(codec, 0x14, 0,
16140 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16141 }
16142}
16143
16144static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
16145{
16146 unsigned int present1, present2;
16147
16148 present1 = snd_hda_codec_read(codec, 0x1b, 0,
16149 AC_VERB_GET_PIN_SENSE, 0)
16150 & AC_PINSENSE_PRESENCE;
16151 present2 = snd_hda_codec_read(codec, 0x15, 0,
16152 AC_VERB_GET_PIN_SENSE, 0)
16153 & AC_PINSENSE_PRESENCE;
16154
16155 if (present1 || present2) {
16156 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16157 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16158 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16159 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16160 } else {
16161 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16162 AMP_IN_MUTE(0), 0);
16163 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16164 AMP_IN_MUTE(0), 0);
16165 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020016166}
16167
16168static void alc663_m51va_mic_automute(struct hda_codec *codec)
16169{
16170 unsigned int present;
16171
16172 present = snd_hda_codec_read(codec, 0x18, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020016173 AC_VERB_GET_PIN_SENSE, 0)
16174 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020016175 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016176 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016177 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016178 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016179 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016180 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016181 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016182 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016183}
16184
16185static void alc663_m51va_unsol_event(struct hda_codec *codec,
16186 unsigned int res)
16187{
16188 switch (res >> 26) {
16189 case ALC880_HP_EVENT:
16190 alc663_m51va_speaker_automute(codec);
16191 break;
16192 case ALC880_MIC_EVENT:
16193 alc663_m51va_mic_automute(codec);
16194 break;
16195 }
16196}
16197
16198static void alc663_m51va_inithook(struct hda_codec *codec)
16199{
16200 alc663_m51va_speaker_automute(codec);
16201 alc663_m51va_mic_automute(codec);
16202}
16203
Kailang Yangf1d4e282008-08-26 14:03:29 +020016204/* ***************** Mode1 ******************************/
16205static void alc663_mode1_unsol_event(struct hda_codec *codec,
16206 unsigned int res)
16207{
16208 switch (res >> 26) {
16209 case ALC880_HP_EVENT:
16210 alc663_m51va_speaker_automute(codec);
16211 break;
16212 case ALC880_MIC_EVENT:
16213 alc662_eeepc_mic_automute(codec);
16214 break;
16215 }
16216}
16217
16218static void alc663_mode1_inithook(struct hda_codec *codec)
16219{
16220 alc663_m51va_speaker_automute(codec);
16221 alc662_eeepc_mic_automute(codec);
16222}
16223/* ***************** Mode2 ******************************/
16224static void alc662_mode2_unsol_event(struct hda_codec *codec,
16225 unsigned int res)
16226{
16227 switch (res >> 26) {
16228 case ALC880_HP_EVENT:
16229 alc662_f5z_speaker_automute(codec);
16230 break;
16231 case ALC880_MIC_EVENT:
16232 alc662_eeepc_mic_automute(codec);
16233 break;
16234 }
16235}
16236
16237static void alc662_mode2_inithook(struct hda_codec *codec)
16238{
16239 alc662_f5z_speaker_automute(codec);
16240 alc662_eeepc_mic_automute(codec);
16241}
16242/* ***************** Mode3 ******************************/
16243static void alc663_mode3_unsol_event(struct hda_codec *codec,
16244 unsigned int res)
16245{
16246 switch (res >> 26) {
16247 case ALC880_HP_EVENT:
16248 alc663_two_hp_m1_speaker_automute(codec);
16249 break;
16250 case ALC880_MIC_EVENT:
16251 alc662_eeepc_mic_automute(codec);
16252 break;
16253 }
16254}
16255
16256static void alc663_mode3_inithook(struct hda_codec *codec)
16257{
16258 alc663_two_hp_m1_speaker_automute(codec);
16259 alc662_eeepc_mic_automute(codec);
16260}
16261/* ***************** Mode4 ******************************/
16262static void alc663_mode4_unsol_event(struct hda_codec *codec,
16263 unsigned int res)
16264{
16265 switch (res >> 26) {
16266 case ALC880_HP_EVENT:
16267 alc663_21jd_two_speaker_automute(codec);
16268 break;
16269 case ALC880_MIC_EVENT:
16270 alc662_eeepc_mic_automute(codec);
16271 break;
16272 }
16273}
16274
16275static void alc663_mode4_inithook(struct hda_codec *codec)
16276{
16277 alc663_21jd_two_speaker_automute(codec);
16278 alc662_eeepc_mic_automute(codec);
16279}
16280/* ***************** Mode5 ******************************/
16281static void alc663_mode5_unsol_event(struct hda_codec *codec,
16282 unsigned int res)
16283{
16284 switch (res >> 26) {
16285 case ALC880_HP_EVENT:
16286 alc663_15jd_two_speaker_automute(codec);
16287 break;
16288 case ALC880_MIC_EVENT:
16289 alc662_eeepc_mic_automute(codec);
16290 break;
16291 }
16292}
16293
16294static void alc663_mode5_inithook(struct hda_codec *codec)
16295{
16296 alc663_15jd_two_speaker_automute(codec);
16297 alc662_eeepc_mic_automute(codec);
16298}
16299/* ***************** Mode6 ******************************/
16300static void alc663_mode6_unsol_event(struct hda_codec *codec,
16301 unsigned int res)
16302{
16303 switch (res >> 26) {
16304 case ALC880_HP_EVENT:
16305 alc663_two_hp_m2_speaker_automute(codec);
16306 break;
16307 case ALC880_MIC_EVENT:
16308 alc662_eeepc_mic_automute(codec);
16309 break;
16310 }
16311}
16312
16313static void alc663_mode6_inithook(struct hda_codec *codec)
16314{
16315 alc663_two_hp_m2_speaker_automute(codec);
16316 alc662_eeepc_mic_automute(codec);
16317}
16318
Kailang Yang6dda9f42008-05-27 12:05:31 +020016319static void alc663_g71v_hp_automute(struct hda_codec *codec)
16320{
16321 unsigned int present;
16322 unsigned char bits;
16323
16324 present = snd_hda_codec_read(codec, 0x21, 0,
16325 AC_VERB_GET_PIN_SENSE, 0)
16326 & AC_PINSENSE_PRESENCE;
16327 bits = present ? HDA_AMP_MUTE : 0;
16328 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16329 HDA_AMP_MUTE, bits);
16330 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16331 HDA_AMP_MUTE, bits);
16332}
16333
16334static void alc663_g71v_front_automute(struct hda_codec *codec)
16335{
16336 unsigned int present;
16337 unsigned char bits;
16338
16339 present = snd_hda_codec_read(codec, 0x15, 0,
16340 AC_VERB_GET_PIN_SENSE, 0)
16341 & AC_PINSENSE_PRESENCE;
16342 bits = present ? HDA_AMP_MUTE : 0;
16343 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16344 HDA_AMP_MUTE, bits);
16345}
16346
16347static void alc663_g71v_unsol_event(struct hda_codec *codec,
16348 unsigned int res)
16349{
16350 switch (res >> 26) {
16351 case ALC880_HP_EVENT:
16352 alc663_g71v_hp_automute(codec);
16353 break;
16354 case ALC880_FRONT_EVENT:
16355 alc663_g71v_front_automute(codec);
16356 break;
16357 case ALC880_MIC_EVENT:
16358 alc662_eeepc_mic_automute(codec);
16359 break;
16360 }
16361}
16362
16363static void alc663_g71v_inithook(struct hda_codec *codec)
16364{
16365 alc663_g71v_front_automute(codec);
16366 alc663_g71v_hp_automute(codec);
16367 alc662_eeepc_mic_automute(codec);
16368}
16369
16370static void alc663_g50v_unsol_event(struct hda_codec *codec,
16371 unsigned int res)
16372{
16373 switch (res >> 26) {
16374 case ALC880_HP_EVENT:
16375 alc663_m51va_speaker_automute(codec);
16376 break;
16377 case ALC880_MIC_EVENT:
16378 alc662_eeepc_mic_automute(codec);
16379 break;
16380 }
16381}
16382
16383static void alc663_g50v_inithook(struct hda_codec *codec)
16384{
16385 alc663_m51va_speaker_automute(codec);
16386 alc662_eeepc_mic_automute(codec);
16387}
16388
Kailang Yangf1d4e282008-08-26 14:03:29 +020016389/* bind hp and internal speaker mute (with plug check) */
16390static int alc662_ecs_master_sw_put(struct snd_kcontrol *kcontrol,
16391 struct snd_ctl_elem_value *ucontrol)
16392{
16393 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
16394 long *valp = ucontrol->value.integer.value;
16395 int change;
16396
16397 change = snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
16398 HDA_AMP_MUTE,
16399 valp[0] ? 0 : HDA_AMP_MUTE);
16400 change |= snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
16401 HDA_AMP_MUTE,
16402 valp[1] ? 0 : HDA_AMP_MUTE);
16403 if (change)
16404 alc262_hippo1_automute(codec);
16405 return change;
16406}
16407
16408static struct snd_kcontrol_new alc662_ecs_mixer[] = {
16409 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16410 {
16411 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16412 .name = "Master Playback Switch",
16413 .info = snd_hda_mixer_amp_switch_info,
16414 .get = snd_hda_mixer_amp_switch_get,
16415 .put = alc662_ecs_master_sw_put,
16416 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
16417 },
16418
16419 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
16420 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
16421 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
16422
16423 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16424 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16425 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16426 { } /* end */
16427};
16428
Takashi Iwaicb53c622007-08-10 17:21:45 +020016429#ifdef CONFIG_SND_HDA_POWER_SAVE
16430#define alc662_loopbacks alc880_loopbacks
16431#endif
16432
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016433
16434/* pcm configuration: identiacal with ALC880 */
16435#define alc662_pcm_analog_playback alc880_pcm_analog_playback
16436#define alc662_pcm_analog_capture alc880_pcm_analog_capture
16437#define alc662_pcm_digital_playback alc880_pcm_digital_playback
16438#define alc662_pcm_digital_capture alc880_pcm_digital_capture
16439
16440/*
16441 * configuration and preset
16442 */
16443static const char *alc662_models[ALC662_MODEL_LAST] = {
16444 [ALC662_3ST_2ch_DIG] = "3stack-dig",
16445 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
16446 [ALC662_3ST_6ch] = "3stack-6ch",
16447 [ALC662_5ST_DIG] = "6stack-dig",
16448 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020016449 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010016450 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016451 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020016452 [ALC663_ASUS_M51VA] = "m51va",
16453 [ALC663_ASUS_G71V] = "g71v",
16454 [ALC663_ASUS_H13] = "h13",
16455 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016456 [ALC663_ASUS_MODE1] = "asus-mode1",
16457 [ALC662_ASUS_MODE2] = "asus-mode2",
16458 [ALC663_ASUS_MODE3] = "asus-mode3",
16459 [ALC663_ASUS_MODE4] = "asus-mode4",
16460 [ALC663_ASUS_MODE5] = "asus-mode5",
16461 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016462 [ALC662_AUTO] = "auto",
16463};
16464
16465static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010016466 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020016467 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
16468 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016469 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
16470 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
16471 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
16472 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
16473 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
16474 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
16475 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
16476 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
16477 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
16478 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
16479 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
16480 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016481 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
16482 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
16483 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016484 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
16485 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
16486 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
16487 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016488 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016489 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
16490 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016491 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016492 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
16493 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
16494 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020016495 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
16496 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
16497 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016498 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
16499 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
16500 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016501 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016502 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
16503 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020016504 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016505 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020016506 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016507 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
16508 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
16509 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016510 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016511 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
16512 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010016513 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020016514 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010016515 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016516 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030016517 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
16518 ALC662_3ST_6ch_DIG),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030016519 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
16520 ALC662_3ST_6ch_DIG),
Vedran Miletic19c009a2008-09-29 20:29:25 +020016521 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020016522 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016523 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020016524 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020016525 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016526 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
16527 ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016528 {}
16529};
16530
16531static struct alc_config_preset alc662_presets[] = {
16532 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016533 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016534 .init_verbs = { alc662_init_verbs },
16535 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16536 .dac_nids = alc662_dac_nids,
16537 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016538 .dig_in_nid = ALC662_DIGIN_NID,
16539 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16540 .channel_mode = alc662_3ST_2ch_modes,
16541 .input_mux = &alc662_capture_source,
16542 },
16543 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016544 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016545 .init_verbs = { alc662_init_verbs },
16546 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16547 .dac_nids = alc662_dac_nids,
16548 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016549 .dig_in_nid = ALC662_DIGIN_NID,
16550 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16551 .channel_mode = alc662_3ST_6ch_modes,
16552 .need_dac_fix = 1,
16553 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016554 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016555 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016556 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016557 .init_verbs = { alc662_init_verbs },
16558 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16559 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016560 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16561 .channel_mode = alc662_3ST_6ch_modes,
16562 .need_dac_fix = 1,
16563 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016564 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016565 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016566 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016567 .init_verbs = { alc662_init_verbs },
16568 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16569 .dac_nids = alc662_dac_nids,
16570 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016571 .dig_in_nid = ALC662_DIGIN_NID,
16572 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
16573 .channel_mode = alc662_5stack_modes,
16574 .input_mux = &alc662_capture_source,
16575 },
16576 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016577 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016578 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
16579 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16580 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016581 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16582 .channel_mode = alc662_3ST_2ch_modes,
16583 .input_mux = &alc662_lenovo_101e_capture_source,
16584 .unsol_event = alc662_lenovo_101e_unsol_event,
16585 .init_hook = alc662_lenovo_101e_all_automute,
16586 },
Kailang Yang291702f2007-10-16 14:28:03 +020016587 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016588 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020016589 .init_verbs = { alc662_init_verbs,
16590 alc662_eeepc_sue_init_verbs },
16591 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16592 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020016593 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16594 .channel_mode = alc662_3ST_2ch_modes,
16595 .input_mux = &alc662_eeepc_capture_source,
16596 .unsol_event = alc662_eeepc_unsol_event,
16597 .init_hook = alc662_eeepc_inithook,
16598 },
Kailang Yang8c427222008-01-10 13:03:59 +010016599 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016600 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010016601 alc662_chmode_mixer },
16602 .init_verbs = { alc662_init_verbs,
16603 alc662_eeepc_ep20_sue_init_verbs },
16604 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16605 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010016606 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16607 .channel_mode = alc662_3ST_6ch_modes,
16608 .input_mux = &alc662_lenovo_101e_capture_source,
16609 .unsol_event = alc662_eeepc_ep20_unsol_event,
16610 .init_hook = alc662_eeepc_ep20_inithook,
16611 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016612 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016613 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016614 .init_verbs = { alc662_init_verbs,
16615 alc662_ecs_init_verbs },
16616 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16617 .dac_nids = alc662_dac_nids,
16618 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16619 .channel_mode = alc662_3ST_2ch_modes,
16620 .input_mux = &alc662_eeepc_capture_source,
16621 .unsol_event = alc662_eeepc_unsol_event,
16622 .init_hook = alc662_eeepc_inithook,
16623 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016624 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016625 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016626 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16627 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16628 .dac_nids = alc662_dac_nids,
16629 .dig_out_nid = ALC662_DIGOUT_NID,
16630 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16631 .channel_mode = alc662_3ST_2ch_modes,
16632 .input_mux = &alc663_m51va_capture_source,
16633 .unsol_event = alc663_m51va_unsol_event,
16634 .init_hook = alc663_m51va_inithook,
16635 },
16636 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016637 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016638 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
16639 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16640 .dac_nids = alc662_dac_nids,
16641 .dig_out_nid = ALC662_DIGOUT_NID,
16642 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16643 .channel_mode = alc662_3ST_2ch_modes,
16644 .input_mux = &alc662_eeepc_capture_source,
16645 .unsol_event = alc663_g71v_unsol_event,
16646 .init_hook = alc663_g71v_inithook,
16647 },
16648 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016649 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016650 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16651 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16652 .dac_nids = alc662_dac_nids,
16653 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16654 .channel_mode = alc662_3ST_2ch_modes,
16655 .input_mux = &alc663_m51va_capture_source,
16656 .unsol_event = alc663_m51va_unsol_event,
16657 .init_hook = alc663_m51va_inithook,
16658 },
16659 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016660 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016661 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
16662 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16663 .dac_nids = alc662_dac_nids,
16664 .dig_out_nid = ALC662_DIGOUT_NID,
16665 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16666 .channel_mode = alc662_3ST_6ch_modes,
16667 .input_mux = &alc663_capture_source,
16668 .unsol_event = alc663_g50v_unsol_event,
16669 .init_hook = alc663_g50v_inithook,
16670 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016671 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016672 .mixers = { alc663_m51va_mixer },
16673 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016674 .init_verbs = { alc662_init_verbs,
16675 alc663_21jd_amic_init_verbs },
16676 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16677 .hp_nid = 0x03,
16678 .dac_nids = alc662_dac_nids,
16679 .dig_out_nid = ALC662_DIGOUT_NID,
16680 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16681 .channel_mode = alc662_3ST_2ch_modes,
16682 .input_mux = &alc662_eeepc_capture_source,
16683 .unsol_event = alc663_mode1_unsol_event,
16684 .init_hook = alc663_mode1_inithook,
16685 },
16686 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016687 .mixers = { alc662_1bjd_mixer },
16688 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016689 .init_verbs = { alc662_init_verbs,
16690 alc662_1bjd_amic_init_verbs },
16691 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16692 .dac_nids = alc662_dac_nids,
16693 .dig_out_nid = ALC662_DIGOUT_NID,
16694 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16695 .channel_mode = alc662_3ST_2ch_modes,
16696 .input_mux = &alc662_eeepc_capture_source,
16697 .unsol_event = alc662_mode2_unsol_event,
16698 .init_hook = alc662_mode2_inithook,
16699 },
16700 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016701 .mixers = { alc663_two_hp_m1_mixer },
16702 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016703 .init_verbs = { alc662_init_verbs,
16704 alc663_two_hp_amic_m1_init_verbs },
16705 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16706 .hp_nid = 0x03,
16707 .dac_nids = alc662_dac_nids,
16708 .dig_out_nid = ALC662_DIGOUT_NID,
16709 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16710 .channel_mode = alc662_3ST_2ch_modes,
16711 .input_mux = &alc662_eeepc_capture_source,
16712 .unsol_event = alc663_mode3_unsol_event,
16713 .init_hook = alc663_mode3_inithook,
16714 },
16715 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016716 .mixers = { alc663_asus_21jd_clfe_mixer },
16717 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016718 .init_verbs = { alc662_init_verbs,
16719 alc663_21jd_amic_init_verbs},
16720 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16721 .hp_nid = 0x03,
16722 .dac_nids = alc662_dac_nids,
16723 .dig_out_nid = ALC662_DIGOUT_NID,
16724 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16725 .channel_mode = alc662_3ST_2ch_modes,
16726 .input_mux = &alc662_eeepc_capture_source,
16727 .unsol_event = alc663_mode4_unsol_event,
16728 .init_hook = alc663_mode4_inithook,
16729 },
16730 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016731 .mixers = { alc663_asus_15jd_clfe_mixer },
16732 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016733 .init_verbs = { alc662_init_verbs,
16734 alc663_15jd_amic_init_verbs },
16735 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16736 .hp_nid = 0x03,
16737 .dac_nids = alc662_dac_nids,
16738 .dig_out_nid = ALC662_DIGOUT_NID,
16739 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16740 .channel_mode = alc662_3ST_2ch_modes,
16741 .input_mux = &alc662_eeepc_capture_source,
16742 .unsol_event = alc663_mode5_unsol_event,
16743 .init_hook = alc663_mode5_inithook,
16744 },
16745 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016746 .mixers = { alc663_two_hp_m2_mixer },
16747 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016748 .init_verbs = { alc662_init_verbs,
16749 alc663_two_hp_amic_m2_init_verbs },
16750 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16751 .hp_nid = 0x03,
16752 .dac_nids = alc662_dac_nids,
16753 .dig_out_nid = ALC662_DIGOUT_NID,
16754 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16755 .channel_mode = alc662_3ST_2ch_modes,
16756 .input_mux = &alc662_eeepc_capture_source,
16757 .unsol_event = alc663_mode6_unsol_event,
16758 .init_hook = alc663_mode6_inithook,
16759 },
Kailang Yang622e84c2009-04-21 07:39:04 +020016760 [ALC272_DELL] = {
16761 .mixers = { alc663_m51va_mixer },
16762 .cap_mixer = alc272_auto_capture_mixer,
16763 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
16764 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
16765 .dac_nids = alc662_dac_nids,
16766 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16767 .adc_nids = alc272_adc_nids,
16768 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
16769 .capsrc_nids = alc272_capsrc_nids,
16770 .channel_mode = alc662_3ST_2ch_modes,
16771 .input_mux = &alc663_m51va_capture_source,
16772 .unsol_event = alc663_m51va_unsol_event,
16773 .init_hook = alc663_m51va_inithook,
16774 },
16775 [ALC272_DELL_ZM1] = {
16776 .mixers = { alc663_m51va_mixer },
16777 .cap_mixer = alc662_auto_capture_mixer,
16778 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
16779 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
16780 .dac_nids = alc662_dac_nids,
16781 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16782 .adc_nids = alc662_adc_nids,
16783 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
16784 .capsrc_nids = alc662_capsrc_nids,
16785 .channel_mode = alc662_3ST_2ch_modes,
16786 .input_mux = &alc663_m51va_capture_source,
16787 .unsol_event = alc663_m51va_unsol_event,
16788 .init_hook = alc663_m51va_inithook,
16789 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016790};
16791
16792
16793/*
16794 * BIOS auto configuration
16795 */
16796
16797/* add playback controls from the parsed DAC table */
16798static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
16799 const struct auto_pin_cfg *cfg)
16800{
16801 char name[32];
16802 static const char *chname[4] = {
16803 "Front", "Surround", NULL /*CLFE*/, "Side"
16804 };
16805 hda_nid_t nid;
16806 int i, err;
16807
16808 for (i = 0; i < cfg->line_outs; i++) {
16809 if (!spec->multiout.dac_nids[i])
16810 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020016811 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016812 if (i == 2) {
16813 /* Center/LFE */
16814 err = add_control(spec, ALC_CTL_WIDGET_VOL,
16815 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016816 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
16817 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016818 if (err < 0)
16819 return err;
16820 err = add_control(spec, ALC_CTL_WIDGET_VOL,
16821 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016822 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
16823 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016824 if (err < 0)
16825 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016826 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016827 "Center Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016828 HDA_COMPOSE_AMP_VAL(0x0e, 1, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016829 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016830 if (err < 0)
16831 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016832 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016833 "LFE Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016834 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016835 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016836 if (err < 0)
16837 return err;
16838 } else {
16839 sprintf(name, "%s Playback Volume", chname[i]);
16840 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016841 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
16842 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016843 if (err < 0)
16844 return err;
16845 sprintf(name, "%s Playback Switch", chname[i]);
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016846 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16847 HDA_COMPOSE_AMP_VAL(alc880_idx_to_mixer(i),
16848 3, 0, HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016849 if (err < 0)
16850 return err;
16851 }
16852 }
16853 return 0;
16854}
16855
16856/* add playback controls for speaker and HP outputs */
16857static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
16858 const char *pfx)
16859{
16860 hda_nid_t nid;
16861 int err;
16862 char name[32];
16863
16864 if (!pin)
16865 return 0;
16866
Takashi Iwai24fb9172008-09-02 14:48:20 +020016867 if (pin == 0x17) {
16868 /* ALC663 has a mono output pin on 0x17 */
16869 sprintf(name, "%s Playback Switch", pfx);
16870 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16871 HDA_COMPOSE_AMP_VAL(pin, 2, 0, HDA_OUTPUT));
16872 return err;
16873 }
16874
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016875 if (alc880_is_fixed_pin(pin)) {
16876 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai939778a2009-02-05 15:57:55 +010016877 /* printk(KERN_DEBUG "DAC nid=%x\n",nid); */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016878 /* specify the DAC as the extra output */
16879 if (!spec->multiout.hp_nid)
16880 spec->multiout.hp_nid = nid;
16881 else
16882 spec->multiout.extra_out_nid[0] = nid;
16883 /* control HP volume/switch on the output mixer amp */
16884 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16885 sprintf(name, "%s Playback Volume", pfx);
16886 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
16887 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
16888 if (err < 0)
16889 return err;
16890 sprintf(name, "%s Playback Switch", pfx);
16891 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
16892 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
16893 if (err < 0)
16894 return err;
16895 } else if (alc880_is_multi_pin(pin)) {
16896 /* set manual connection */
16897 /* we have only a switch on HP-out PIN */
16898 sprintf(name, "%s Playback Switch", pfx);
16899 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16900 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
16901 if (err < 0)
16902 return err;
16903 }
16904 return 0;
16905}
16906
Takashi Iwai2d864c42009-03-20 12:52:47 +010016907/* return the index of the src widget from the connection list of the nid.
16908 * return -1 if not found
16909 */
16910static int alc662_input_pin_idx(struct hda_codec *codec, hda_nid_t nid,
16911 hda_nid_t src)
16912{
16913 hda_nid_t conn_list[HDA_MAX_CONNECTIONS];
16914 int i, conns;
16915
16916 conns = snd_hda_get_connections(codec, nid, conn_list,
16917 ARRAY_SIZE(conn_list));
16918 if (conns < 0)
16919 return -1;
16920 for (i = 0; i < conns; i++)
16921 if (conn_list[i] == src)
16922 return i;
16923 return -1;
16924}
16925
16926static int alc662_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
16927{
Takashi Iwai1327a322009-03-23 13:07:47 +010016928 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai2d864c42009-03-20 12:52:47 +010016929 return (pincap & AC_PINCAP_IN) != 0;
16930}
16931
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016932/* create playback/capture controls for input pins */
Takashi Iwai2d864c42009-03-20 12:52:47 +010016933static int alc662_auto_create_analog_input_ctls(struct hda_codec *codec,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016934 const struct auto_pin_cfg *cfg)
16935{
Takashi Iwai2d864c42009-03-20 12:52:47 +010016936 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016937 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016938 int i, err, idx;
16939
16940 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai2d864c42009-03-20 12:52:47 +010016941 if (alc662_is_input_pin(codec, cfg->input_pins[i])) {
16942 idx = alc662_input_pin_idx(codec, 0x0b,
16943 cfg->input_pins[i]);
16944 if (idx >= 0) {
16945 err = new_analog_input(spec, cfg->input_pins[i],
16946 auto_pin_cfg_labels[i],
16947 idx, 0x0b);
16948 if (err < 0)
16949 return err;
16950 }
16951 idx = alc662_input_pin_idx(codec, 0x22,
16952 cfg->input_pins[i]);
16953 if (idx >= 0) {
16954 imux->items[imux->num_items].label =
16955 auto_pin_cfg_labels[i];
16956 imux->items[imux->num_items].index = idx;
16957 imux->num_items++;
16958 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016959 }
16960 }
16961 return 0;
16962}
16963
16964static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
16965 hda_nid_t nid, int pin_type,
16966 int dac_idx)
16967{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016968 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016969 /* need the manual connection? */
16970 if (alc880_is_multi_pin(nid)) {
16971 struct alc_spec *spec = codec->spec;
16972 int idx = alc880_multi_pin_idx(nid);
16973 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
16974 AC_VERB_SET_CONNECT_SEL,
16975 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
16976 }
16977}
16978
16979static void alc662_auto_init_multi_out(struct hda_codec *codec)
16980{
16981 struct alc_spec *spec = codec->spec;
16982 int i;
16983
16984 for (i = 0; i <= HDA_SIDE; i++) {
16985 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016986 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016987 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016988 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016989 i);
16990 }
16991}
16992
16993static void alc662_auto_init_hp_out(struct hda_codec *codec)
16994{
16995 struct alc_spec *spec = codec->spec;
16996 hda_nid_t pin;
16997
16998 pin = spec->autocfg.hp_pins[0];
16999 if (pin) /* connect to front */
17000 /* use dac 0 */
17001 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017002 pin = spec->autocfg.speaker_pins[0];
17003 if (pin)
17004 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017005}
17006
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017007#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
17008
17009static void alc662_auto_init_analog_input(struct hda_codec *codec)
17010{
17011 struct alc_spec *spec = codec->spec;
17012 int i;
17013
17014 for (i = 0; i < AUTO_PIN_LAST; i++) {
17015 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai2d864c42009-03-20 12:52:47 +010017016 if (alc662_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010017017 alc_set_input_pin(codec, nid, i);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010017018 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010017019 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017020 snd_hda_codec_write(codec, nid, 0,
17021 AC_VERB_SET_AMP_GAIN_MUTE,
17022 AMP_OUT_MUTE);
17023 }
17024 }
17025}
17026
Takashi Iwaif511b012008-08-15 16:46:42 +020017027#define alc662_auto_init_input_src alc882_auto_init_input_src
17028
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017029static int alc662_parse_auto_config(struct hda_codec *codec)
17030{
17031 struct alc_spec *spec = codec->spec;
17032 int err;
17033 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
17034
17035 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
17036 alc662_ignore);
17037 if (err < 0)
17038 return err;
17039 if (!spec->autocfg.line_outs)
17040 return 0; /* can't find valid BIOS pin config */
17041
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017042 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
17043 if (err < 0)
17044 return err;
17045 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
17046 if (err < 0)
17047 return err;
17048 err = alc662_auto_create_extra_out(spec,
17049 spec->autocfg.speaker_pins[0],
17050 "Speaker");
17051 if (err < 0)
17052 return err;
17053 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
17054 "Headphone");
17055 if (err < 0)
17056 return err;
Takashi Iwai2d864c42009-03-20 12:52:47 +010017057 err = alc662_auto_create_analog_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017058 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017059 return err;
17060
17061 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
17062
Takashi Iwai0852d7a2009-02-11 11:35:15 +010017063 if (spec->autocfg.dig_outs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017064 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
17065
Takashi Iwai603c4012008-07-30 15:01:44 +020017066 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017067 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017068
17069 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017070 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020017071
Takashi Iwaid88897e2008-10-31 15:01:37 +010017072 add_verb(spec, alc662_auto_init_verbs);
Takashi Iwai24fb9172008-09-02 14:48:20 +020017073 if (codec->vendor_id == 0x10ec0663)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017074 add_verb(spec, alc663_auto_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020017075
17076 err = alc_auto_add_mic_boost(codec);
17077 if (err < 0)
17078 return err;
17079
Takashi Iwai4a79ba32009-04-22 16:31:35 +020017080 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
17081
Takashi Iwai8c87286f2007-06-19 12:11:16 +020017082 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017083}
17084
17085/* additional initialization for auto-configuration model */
17086static void alc662_auto_init(struct hda_codec *codec)
17087{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017088 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017089 alc662_auto_init_multi_out(codec);
17090 alc662_auto_init_hp_out(codec);
17091 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020017092 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017093 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020017094 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017095}
17096
17097static int patch_alc662(struct hda_codec *codec)
17098{
17099 struct alc_spec *spec;
17100 int err, board_config;
17101
17102 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
17103 if (!spec)
17104 return -ENOMEM;
17105
17106 codec->spec = spec;
17107
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020017108 alc_fix_pll_init(codec, 0x20, 0x04, 15);
17109
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017110 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
17111 alc662_models,
17112 alc662_cfg_tbl);
17113 if (board_config < 0) {
17114 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
17115 "trying auto-probe from BIOS...\n");
17116 board_config = ALC662_AUTO;
17117 }
17118
17119 if (board_config == ALC662_AUTO) {
17120 /* automatic parse from the BIOS config */
17121 err = alc662_parse_auto_config(codec);
17122 if (err < 0) {
17123 alc_free(codec);
17124 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020017125 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017126 printk(KERN_INFO
17127 "hda_codec: Cannot set up configuration "
17128 "from BIOS. Using base mode...\n");
17129 board_config = ALC662_3ST_2ch_DIG;
17130 }
17131 }
17132
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090017133 err = snd_hda_attach_beep_device(codec, 0x1);
17134 if (err < 0) {
17135 alc_free(codec);
17136 return err;
17137 }
17138
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017139 if (board_config != ALC662_AUTO)
17140 setup_preset(spec, &alc662_presets[board_config]);
17141
Kailang Yang6dda9f42008-05-27 12:05:31 +020017142 if (codec->vendor_id == 0x10ec0663) {
17143 spec->stream_name_analog = "ALC663 Analog";
17144 spec->stream_name_digital = "ALC663 Digital";
Kailang Yang01afd412008-10-15 11:22:09 +020017145 } else if (codec->vendor_id == 0x10ec0272) {
17146 spec->stream_name_analog = "ALC272 Analog";
17147 spec->stream_name_digital = "ALC272 Digital";
Kailang Yang6dda9f42008-05-27 12:05:31 +020017148 } else {
17149 spec->stream_name_analog = "ALC662 Analog";
17150 spec->stream_name_digital = "ALC662 Digital";
17151 }
17152
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017153 spec->stream_analog_playback = &alc662_pcm_analog_playback;
17154 spec->stream_analog_capture = &alc662_pcm_analog_capture;
17155
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017156 spec->stream_digital_playback = &alc662_pcm_digital_playback;
17157 spec->stream_digital_capture = &alc662_pcm_digital_capture;
17158
Takashi Iwaie1406342008-02-11 18:32:32 +010017159 spec->adc_nids = alc662_adc_nids;
17160 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
17161 spec->capsrc_nids = alc662_capsrc_nids;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017162 spec->capture_style = CAPT_MIX;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017163
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017164 if (!spec->cap_mixer)
17165 set_capture_mixer(spec);
Takashi Iwaib9591442009-03-16 15:25:00 +010017166 if (codec->vendor_id == 0x10ec0662)
17167 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
17168 else
17169 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017170
Takashi Iwai2134ea42008-01-10 16:53:55 +010017171 spec->vmaster_nid = 0x02;
17172
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017173 codec->patch_ops = alc_patch_ops;
17174 if (board_config == ALC662_AUTO)
17175 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020017176#ifdef CONFIG_SND_HDA_POWER_SAVE
17177 if (!spec->loopback.amplist)
17178 spec->loopback.amplist = alc662_loopbacks;
17179#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010017180 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017181
17182 return 0;
17183}
17184
17185/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070017186 * patch entries
17187 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017188static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070017189 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010017190 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017191 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020017192 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017193 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020017194 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017195 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017196 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017197 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
17198 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
17199 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017200 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
17201 .patch = patch_alc883 },
17202 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
17203 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017204 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017205 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017206 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020017207 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Clive Messer669faba2008-09-30 15:49:13 +020017208 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
17209 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Takashi Iwaicb308f92008-04-16 14:13:29 +020017210 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai7943a8a2008-04-16 17:29:09 +020017211 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Kailang Yangdf694da2005-12-05 19:42:22 +010017212 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Kailang Yanga385a522008-10-15 11:20:21 +020017213 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc883 },
Kailang Yang44426082008-10-15 11:18:05 +020017214 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
17215 .patch = patch_alc883 },
Wu Fengguang3fea2cb2008-12-26 12:20:43 +080017216 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017217 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017218 {} /* terminator */
17219};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017220
17221MODULE_ALIAS("snd-hda-codec-id:10ec*");
17222
17223MODULE_LICENSE("GPL");
17224MODULE_DESCRIPTION("Realtek HD-audio codec");
17225
17226static struct hda_codec_preset_list realtek_list = {
17227 .preset = snd_hda_preset_realtek,
17228 .owner = THIS_MODULE,
17229};
17230
17231static int __init patch_realtek_init(void)
17232{
17233 return snd_hda_add_codec_preset(&realtek_list);
17234}
17235
17236static void __exit patch_realtek_exit(void)
17237{
17238 snd_hda_delete_codec_preset(&realtek_list);
17239}
17240
17241module_init(patch_realtek_init)
17242module_exit(patch_realtek_exit)