blob: 3e7207b927c86016988f5effd95ae2c9e5611b8f [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]) {
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001102 if (spec->autocfg.line_out_pins[0] &&
1103 spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT)
Kailang Yangc9b58002007-10-16 14:30:01 +02001104 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +01001105 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +02001106 else
1107 return;
1108 }
1109
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001110 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1111 spec->autocfg.hp_pins[0]);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001112 snd_hda_codec_write_cache(codec, spec->autocfg.hp_pins[0], 0,
1113 AC_VERB_SET_UNSOLICITED_ENABLE,
1114 AC_USRSP_EN | ALC880_HP_EVENT);
1115 spec->unsol_event = alc_sku_unsol_event;
1116}
1117
1118/* check subsystem ID and set up device-specific initialization;
1119 * return 1 if initialized, 0 if invalid SSID
1120 */
1121/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1122 * 31 ~ 16 : Manufacture ID
1123 * 15 ~ 8 : SKU ID
1124 * 7 ~ 0 : Assembly ID
1125 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1126 */
1127static int alc_subsystem_id(struct hda_codec *codec,
1128 hda_nid_t porta, hda_nid_t porte,
1129 hda_nid_t portd)
1130{
1131 unsigned int ass, tmp, i;
1132 unsigned nid;
1133 struct alc_spec *spec = codec->spec;
1134
1135 ass = codec->subsystem_id & 0xffff;
1136 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1137 goto do_sku;
1138
1139 /* invalid SSID, check the special NID pin defcfg instead */
1140 /*
1141 * 31~30 : port conetcivity
1142 * 29~21 : reserve
1143 * 20 : PCBEEP input
1144 * 19~16 : Check sum (15:1)
1145 * 15~1 : Custom
1146 * 0 : override
1147 */
1148 nid = 0x1d;
1149 if (codec->vendor_id == 0x10ec0260)
1150 nid = 0x17;
1151 ass = snd_hda_codec_get_pincfg(codec, nid);
1152 snd_printd("realtek: No valid SSID, "
1153 "checking pincfg 0x%08x for NID 0x%x\n",
Takashi Iwaicb6605c2009-04-28 13:03:19 +02001154 ass, nid);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001155 if (!(ass & 1) && !(ass & 0x100000))
1156 return 0;
1157 if ((ass >> 30) != 1) /* no physical connection */
1158 return 0;
1159
1160 /* check sum */
1161 tmp = 0;
1162 for (i = 1; i < 16; i++) {
1163 if ((ass >> i) & 1)
1164 tmp++;
1165 }
1166 if (((ass >> 16) & 0xf) != tmp)
1167 return 0;
1168do_sku:
1169 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1170 ass & 0xffff, codec->vendor_id);
1171 /*
1172 * 0 : override
1173 * 1 : Swap Jack
1174 * 2 : 0 --> Desktop, 1 --> Laptop
1175 * 3~5 : External Amplifier control
1176 * 7~6 : Reserved
1177 */
1178 tmp = (ass & 0x38) >> 3; /* external Amp control */
1179 switch (tmp) {
1180 case 1:
1181 spec->init_amp = ALC_INIT_GPIO1;
1182 break;
1183 case 3:
1184 spec->init_amp = ALC_INIT_GPIO2;
1185 break;
1186 case 7:
1187 spec->init_amp = ALC_INIT_GPIO3;
1188 break;
1189 case 5:
1190 spec->init_amp = ALC_INIT_DEFAULT;
1191 break;
1192 }
1193
1194 /* is laptop or Desktop and enable the function "Mute internal speaker
1195 * when the external headphone out jack is plugged"
1196 */
1197 if (!(ass & 0x8000))
1198 return 1;
1199 /*
1200 * 10~8 : Jack location
1201 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1202 * 14~13: Resvered
1203 * 15 : 1 --> enable the function "Mute internal speaker
1204 * when the external headphone out jack is plugged"
1205 */
Kailang Yangc9b58002007-10-16 14:30:01 +02001206 if (!spec->autocfg.hp_pins[0]) {
1207 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1208 if (tmp == 0)
1209 spec->autocfg.hp_pins[0] = porta;
1210 else if (tmp == 1)
1211 spec->autocfg.hp_pins[0] = porte;
1212 else if (tmp == 2)
1213 spec->autocfg.hp_pins[0] = portd;
1214 else
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001215 return 1;
Kailang Yangc9b58002007-10-16 14:30:01 +02001216 }
1217
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001218 alc_init_auto_hp(codec);
1219 return 1;
1220}
Kailang Yangea1fb292008-08-26 12:58:38 +02001221
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001222static void alc_ssid_check(struct hda_codec *codec,
1223 hda_nid_t porta, hda_nid_t porte, hda_nid_t portd)
1224{
1225 if (!alc_subsystem_id(codec, porta, porte, portd)) {
1226 struct alc_spec *spec = codec->spec;
1227 snd_printd("realtek: "
1228 "Enable default setup for auto mode as fallback\n");
1229 spec->init_amp = ALC_INIT_DEFAULT;
1230 alc_init_auto_hp(codec);
1231 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001232}
1233
Takashi Iwai41e41f12005-06-08 14:48:49 +02001234/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02001235 * Fix-up pin default configurations
1236 */
1237
1238struct alc_pincfg {
1239 hda_nid_t nid;
1240 u32 val;
1241};
1242
1243static void alc_fix_pincfg(struct hda_codec *codec,
1244 const struct snd_pci_quirk *quirk,
1245 const struct alc_pincfg **pinfix)
1246{
1247 const struct alc_pincfg *cfg;
1248
1249 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1250 if (!quirk)
1251 return;
1252
1253 cfg = pinfix[quirk->value];
Takashi Iwai0e8a21b2009-02-20 14:13:06 +01001254 for (; cfg->nid; cfg++)
1255 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
Takashi Iwaif95474e2007-07-10 00:47:43 +02001256}
1257
1258/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001259 * ALC888
1260 */
1261
1262/*
1263 * 2ch mode
1264 */
1265static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1266/* Mic-in jack as mic in */
1267 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1268 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1269/* Line-in jack as Line in */
1270 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1271 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1272/* Line-Out as Front */
1273 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1274 { } /* end */
1275};
1276
1277/*
1278 * 4ch mode
1279 */
1280static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1281/* Mic-in jack as mic in */
1282 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1283 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1284/* Line-in jack as Surround */
1285 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1286 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1287/* Line-Out as Front */
1288 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1289 { } /* end */
1290};
1291
1292/*
1293 * 6ch mode
1294 */
1295static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1296/* Mic-in jack as CLFE */
1297 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1298 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1299/* Line-in jack as Surround */
1300 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1301 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1302/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1303 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1304 { } /* end */
1305};
1306
1307/*
1308 * 8ch mode
1309 */
1310static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1311/* Mic-in jack as CLFE */
1312 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1313 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1314/* Line-in jack as Surround */
1315 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1316 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1317/* Line-Out as Side */
1318 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1319 { } /* end */
1320};
1321
1322static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1323 { 2, alc888_4ST_ch2_intel_init },
1324 { 4, alc888_4ST_ch4_intel_init },
1325 { 6, alc888_4ST_ch6_intel_init },
1326 { 8, alc888_4ST_ch8_intel_init },
1327};
1328
1329/*
1330 * ALC888 Fujitsu Siemens Amillo xa3530
1331 */
1332
1333static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1334/* Front Mic: set to PIN_IN (empty by default) */
1335 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1336/* Connect Internal HP to Front */
1337 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1338 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1339 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1340/* Connect Bass HP to Front */
1341 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1342 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1343 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1344/* Connect Line-Out side jack (SPDIF) to Side */
1345 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1346 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1347 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1348/* Connect Mic jack to CLFE */
1349 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1350 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1351 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1352/* Connect Line-in jack to Surround */
1353 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1354 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1355 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1356/* Connect HP out jack to Front */
1357 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1358 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1359 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1360/* Enable unsolicited event for HP jack and Line-out jack */
1361 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1362 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1363 {}
1364};
1365
1366static void alc888_fujitsu_xa3530_automute(struct hda_codec *codec)
1367{
1368 unsigned int present;
1369 unsigned int bits;
1370 /* Line out presence */
1371 present = snd_hda_codec_read(codec, 0x17, 0,
1372 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1373 /* HP out presence */
1374 present = present || snd_hda_codec_read(codec, 0x1b, 0,
1375 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1376 bits = present ? HDA_AMP_MUTE : 0;
1377 /* Toggle internal speakers muting */
1378 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
1379 HDA_AMP_MUTE, bits);
1380 /* Toggle internal bass muting */
1381 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
1382 HDA_AMP_MUTE, bits);
1383}
1384
1385static void alc888_fujitsu_xa3530_unsol_event(struct hda_codec *codec,
1386 unsigned int res)
1387{
1388 if (res >> 26 == ALC880_HP_EVENT)
1389 alc888_fujitsu_xa3530_automute(codec);
1390}
1391
1392
1393/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001394 * ALC888 Acer Aspire 4930G model
1395 */
1396
1397static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1398/* Front Mic: set to PIN_IN (empty by default) */
1399 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1400/* Unselect Front Mic by default in input mixer 3 */
1401 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001402/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001403 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1404/* Connect Internal HP to front */
1405 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1406 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1407 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1408/* Connect HP out to front */
1409 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1410 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1411 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1412 { }
1413};
1414
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001415static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001416 /* Front mic only available on one ADC */
1417 {
1418 .num_items = 4,
1419 .items = {
1420 { "Mic", 0x0 },
1421 { "Line", 0x2 },
1422 { "CD", 0x4 },
1423 { "Front Mic", 0xb },
1424 },
1425 },
1426 {
1427 .num_items = 3,
1428 .items = {
1429 { "Mic", 0x0 },
1430 { "Line", 0x2 },
1431 { "CD", 0x4 },
1432 },
1433 }
1434};
1435
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001436static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001437 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1438 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1439 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1440 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1441 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1442 HDA_OUTPUT),
1443 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1444 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1445 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1446 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1447 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1448 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1449 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1450 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1451 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1452 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1453 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1454 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001455 { } /* end */
1456};
1457
1458static void alc888_acer_aspire_4930g_automute(struct hda_codec *codec)
1459{
1460 unsigned int present;
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001461 unsigned int bits;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001462 present = snd_hda_codec_read(codec, 0x15, 0,
1463 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001464 bits = present ? HDA_AMP_MUTE : 0;
1465 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
1466 HDA_AMP_MUTE, bits);
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001467}
1468
1469static void alc888_acer_aspire_4930g_unsol_event(struct hda_codec *codec,
1470 unsigned int res)
1471{
1472 if (res >> 26 == ALC880_HP_EVENT)
1473 alc888_acer_aspire_4930g_automute(codec);
1474}
1475
1476/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001477 * ALC880 3-stack model
1478 *
1479 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001480 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1481 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07001482 */
1483
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001484static hda_nid_t alc880_dac_nids[4] = {
1485 /* front, rear, clfe, rear_surr */
1486 0x02, 0x05, 0x04, 0x03
1487};
1488
1489static hda_nid_t alc880_adc_nids[3] = {
1490 /* ADC0-2 */
1491 0x07, 0x08, 0x09,
1492};
1493
1494/* The datasheet says the node 0x07 is connected from inputs,
1495 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01001496 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07001497 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001498static hda_nid_t alc880_adc_nids_alt[2] = {
1499 /* ADC1-2 */
1500 0x08, 0x09,
1501};
1502
1503#define ALC880_DIGOUT_NID 0x06
1504#define ALC880_DIGIN_NID 0x0a
1505
1506static struct hda_input_mux alc880_capture_source = {
1507 .num_items = 4,
1508 .items = {
1509 { "Mic", 0x0 },
1510 { "Front Mic", 0x3 },
1511 { "Line", 0x2 },
1512 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001513 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001514};
1515
1516/* channel source setting (2/6 channel selection for 3-stack) */
1517/* 2ch mode */
1518static struct hda_verb alc880_threestack_ch2_init[] = {
1519 /* set line-in to input, mute it */
1520 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1521 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1522 /* set mic-in to input vref 80%, mute it */
1523 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1524 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001525 { } /* end */
1526};
1527
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001528/* 6ch mode */
1529static struct hda_verb alc880_threestack_ch6_init[] = {
1530 /* set line-in to output, unmute it */
1531 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1532 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1533 /* set mic-in to output, unmute it */
1534 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1535 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1536 { } /* end */
1537};
1538
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001539static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001540 { 2, alc880_threestack_ch2_init },
1541 { 6, alc880_threestack_ch6_init },
1542};
1543
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001544static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001545 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001546 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001547 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001548 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001549 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1550 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001551 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1552 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001553 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1554 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1555 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1556 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1557 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1558 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1559 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1560 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001561 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001562 {
1563 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1564 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001565 .info = alc_ch_mode_info,
1566 .get = alc_ch_mode_get,
1567 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001568 },
1569 { } /* end */
1570};
1571
1572/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001573static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1574 struct snd_ctl_elem_info *uinfo)
1575{
1576 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1577 struct alc_spec *spec = codec->spec;
1578 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001579
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001580 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001581 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1582 HDA_INPUT);
1583 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001584 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001585 return err;
1586}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001587
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001588static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1589 unsigned int size, unsigned int __user *tlv)
1590{
1591 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1592 struct alc_spec *spec = codec->spec;
1593 int err;
1594
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001595 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001596 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1597 HDA_INPUT);
1598 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001599 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001600 return err;
1601}
1602
1603typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1604 struct snd_ctl_elem_value *ucontrol);
1605
1606static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1607 struct snd_ctl_elem_value *ucontrol,
1608 getput_call_t func)
1609{
1610 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1611 struct alc_spec *spec = codec->spec;
1612 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1613 int err;
1614
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001615 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001616 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
1617 3, 0, HDA_INPUT);
1618 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001619 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001620 return err;
1621}
1622
1623static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
1624 struct snd_ctl_elem_value *ucontrol)
1625{
1626 return alc_cap_getput_caller(kcontrol, ucontrol,
1627 snd_hda_mixer_amp_volume_get);
1628}
1629
1630static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
1631 struct snd_ctl_elem_value *ucontrol)
1632{
1633 return alc_cap_getput_caller(kcontrol, ucontrol,
1634 snd_hda_mixer_amp_volume_put);
1635}
1636
1637/* capture mixer elements */
1638#define alc_cap_sw_info snd_ctl_boolean_stereo_info
1639
1640static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
1641 struct snd_ctl_elem_value *ucontrol)
1642{
1643 return alc_cap_getput_caller(kcontrol, ucontrol,
1644 snd_hda_mixer_amp_switch_get);
1645}
1646
1647static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
1648 struct snd_ctl_elem_value *ucontrol)
1649{
1650 return alc_cap_getput_caller(kcontrol, ucontrol,
1651 snd_hda_mixer_amp_switch_put);
1652}
1653
Takashi Iwaia23b6882009-03-23 15:21:36 +01001654#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001655 { \
1656 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1657 .name = "Capture Switch", \
1658 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1659 .count = num, \
1660 .info = alc_cap_sw_info, \
1661 .get = alc_cap_sw_get, \
1662 .put = alc_cap_sw_put, \
1663 }, \
1664 { \
1665 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1666 .name = "Capture Volume", \
1667 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1668 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1669 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
1670 .count = num, \
1671 .info = alc_cap_vol_info, \
1672 .get = alc_cap_vol_get, \
1673 .put = alc_cap_vol_put, \
1674 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01001675 }
1676
1677#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01001678 { \
1679 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1680 /* .name = "Capture Source", */ \
1681 .name = "Input Source", \
1682 .count = num, \
1683 .info = alc_mux_enum_info, \
1684 .get = alc_mux_enum_get, \
1685 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01001686 }
1687
1688#define DEFINE_CAPMIX(num) \
1689static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
1690 _DEFINE_CAPMIX(num), \
1691 _DEFINE_CAPSRC(num), \
1692 { } /* end */ \
1693}
1694
1695#define DEFINE_CAPMIX_NOSRC(num) \
1696static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
1697 _DEFINE_CAPMIX(num), \
1698 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001699}
1700
1701/* up to three ADCs */
1702DEFINE_CAPMIX(1);
1703DEFINE_CAPMIX(2);
1704DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01001705DEFINE_CAPMIX_NOSRC(1);
1706DEFINE_CAPMIX_NOSRC(2);
1707DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001708
1709/*
1710 * ALC880 5-stack model
1711 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001712 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
1713 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001714 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
1715 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
1716 */
1717
1718/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001719static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001720 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001721 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001722 { } /* end */
1723};
1724
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001725/* channel source setting (6/8 channel selection for 5-stack) */
1726/* 6ch mode */
1727static struct hda_verb alc880_fivestack_ch6_init[] = {
1728 /* set line-in to input, mute it */
1729 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1730 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001731 { } /* end */
1732};
1733
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001734/* 8ch mode */
1735static struct hda_verb alc880_fivestack_ch8_init[] = {
1736 /* set line-in to output, unmute it */
1737 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1738 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1739 { } /* end */
1740};
1741
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001742static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001743 { 6, alc880_fivestack_ch6_init },
1744 { 8, alc880_fivestack_ch8_init },
1745};
1746
1747
1748/*
1749 * ALC880 6-stack model
1750 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001751 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
1752 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001753 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
1754 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
1755 */
1756
1757static hda_nid_t alc880_6st_dac_nids[4] = {
1758 /* front, rear, clfe, rear_surr */
1759 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001760};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001761
1762static struct hda_input_mux alc880_6stack_capture_source = {
1763 .num_items = 4,
1764 .items = {
1765 { "Mic", 0x0 },
1766 { "Front Mic", 0x1 },
1767 { "Line", 0x2 },
1768 { "CD", 0x4 },
1769 },
1770};
1771
1772/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001773static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001774 { 8, NULL },
1775};
1776
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001777static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001778 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001779 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001780 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001781 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001782 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1783 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001784 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1785 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001786 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001787 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001788 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1789 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1790 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1791 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1792 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1793 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1794 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1795 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001796 {
1797 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1798 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001799 .info = alc_ch_mode_info,
1800 .get = alc_ch_mode_get,
1801 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001802 },
1803 { } /* end */
1804};
1805
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001806
1807/*
1808 * ALC880 W810 model
1809 *
1810 * W810 has rear IO for:
1811 * Front (DAC 02)
1812 * Surround (DAC 03)
1813 * Center/LFE (DAC 04)
1814 * Digital out (06)
1815 *
1816 * The system also has a pair of internal speakers, and a headphone jack.
1817 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02001818 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001819 * There is a variable resistor to control the speaker or headphone
1820 * volume. This is a hardware-only device without a software API.
1821 *
1822 * Plugging headphones in will disable the internal speakers. This is
1823 * implemented in hardware, not via the driver using jack sense. In
1824 * a similar fashion, plugging into the rear socket marked "front" will
1825 * disable both the speakers and headphones.
1826 *
1827 * For input, there's a microphone jack, and an "audio in" jack.
1828 * These may not do anything useful with this driver yet, because I
1829 * haven't setup any initialization verbs for these yet...
1830 */
1831
1832static hda_nid_t alc880_w810_dac_nids[3] = {
1833 /* front, rear/surround, clfe */
1834 0x02, 0x03, 0x04
1835};
1836
1837/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001838static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001839 { 6, NULL }
1840};
1841
1842/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001843static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001844 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001845 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001846 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001847 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001848 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1849 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001850 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1851 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001852 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1853 { } /* end */
1854};
1855
1856
1857/*
1858 * Z710V model
1859 *
1860 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001861 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1862 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001863 */
1864
1865static hda_nid_t alc880_z71v_dac_nids[1] = {
1866 0x02
1867};
1868#define ALC880_Z71V_HP_DAC 0x03
1869
1870/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001871static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001872 { 2, NULL }
1873};
1874
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001875static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001876 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001877 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001878 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001879 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001880 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1881 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1882 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1883 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1884 { } /* end */
1885};
1886
1887
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001888/*
1889 * ALC880 F1734 model
1890 *
1891 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1892 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1893 */
1894
1895static hda_nid_t alc880_f1734_dac_nids[1] = {
1896 0x03
1897};
1898#define ALC880_F1734_HP_DAC 0x02
1899
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001900static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001901 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001902 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01001903 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1904 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001905 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1906 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01001907 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1908 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001909 { } /* end */
1910};
1911
Takashi Iwai937b4162008-02-11 14:52:36 +01001912static struct hda_input_mux alc880_f1734_capture_source = {
1913 .num_items = 2,
1914 .items = {
1915 { "Mic", 0x1 },
1916 { "CD", 0x4 },
1917 },
1918};
1919
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001920
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001921/*
1922 * ALC880 ASUS model
1923 *
1924 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1925 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1926 * Mic = 0x18, Line = 0x1a
1927 */
1928
1929#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1930#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1931
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001932static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001933 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001934 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001935 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001936 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001937 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1938 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001939 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1940 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001941 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1942 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1943 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1944 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1945 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1946 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001947 {
1948 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1949 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001950 .info = alc_ch_mode_info,
1951 .get = alc_ch_mode_get,
1952 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001953 },
1954 { } /* end */
1955};
1956
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001957/*
1958 * ALC880 ASUS W1V model
1959 *
1960 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1961 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1962 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1963 */
1964
1965/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001966static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001967 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1968 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001969 { } /* end */
1970};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001971
Kailang Yangdf694da2005-12-05 19:42:22 +01001972/* TCL S700 */
1973static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1974 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1975 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1976 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1977 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1978 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1979 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1980 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1981 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1982 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01001983 { } /* end */
1984};
1985
Kailang Yangccc656c2006-10-17 12:32:26 +02001986/* Uniwill */
1987static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001988 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1989 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1990 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1991 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001992 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1993 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1994 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1995 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1996 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1997 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1998 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1999 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2000 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2001 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2002 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2003 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002004 {
2005 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2006 .name = "Channel Mode",
2007 .info = alc_ch_mode_info,
2008 .get = alc_ch_mode_get,
2009 .put = alc_ch_mode_put,
2010 },
2011 { } /* end */
2012};
2013
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002014static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2015 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2016 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2017 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2018 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2019 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2020 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2021 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2022 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2023 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2024 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2025 { } /* end */
2026};
2027
Kailang Yangccc656c2006-10-17 12:32:26 +02002028static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002029 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2030 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2031 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2032 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002033 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2034 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2035 { } /* end */
2036};
2037
Linus Torvalds1da177e2005-04-16 15:20:36 -07002038/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01002039 * virtual master controls
2040 */
2041
2042/*
2043 * slave controls for virtual master
2044 */
2045static const char *alc_slave_vols[] = {
2046 "Front Playback Volume",
2047 "Surround Playback Volume",
2048 "Center Playback Volume",
2049 "LFE Playback Volume",
2050 "Side Playback Volume",
2051 "Headphone Playback Volume",
2052 "Speaker Playback Volume",
2053 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002054 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01002055 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002056 NULL,
2057};
2058
2059static const char *alc_slave_sws[] = {
2060 "Front Playback Switch",
2061 "Surround Playback Switch",
2062 "Center Playback Switch",
2063 "LFE Playback Switch",
2064 "Side Playback Switch",
2065 "Headphone Playback Switch",
2066 "Speaker Playback Switch",
2067 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01002068 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002069 NULL,
2070};
2071
2072/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002073 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002074 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002075
2076static void alc_free_kctls(struct hda_codec *codec);
2077
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002078/* additional beep mixers; the actual parameters are overwritten at build */
2079static struct snd_kcontrol_new alc_beep_mixer[] = {
2080 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
2081 HDA_CODEC_MUTE("Beep Playback Switch", 0, 0, HDA_INPUT),
2082 { } /* end */
2083};
2084
Linus Torvalds1da177e2005-04-16 15:20:36 -07002085static int alc_build_controls(struct hda_codec *codec)
2086{
2087 struct alc_spec *spec = codec->spec;
2088 int err;
2089 int i;
2090
2091 for (i = 0; i < spec->num_mixers; i++) {
2092 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2093 if (err < 0)
2094 return err;
2095 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002096 if (spec->cap_mixer) {
2097 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2098 if (err < 0)
2099 return err;
2100 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002101 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002102 err = snd_hda_create_spdif_out_ctls(codec,
2103 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002104 if (err < 0)
2105 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002106 if (!spec->no_analog) {
2107 err = snd_hda_create_spdif_share_sw(codec,
2108 &spec->multiout);
2109 if (err < 0)
2110 return err;
2111 spec->multiout.share_spdif = 1;
2112 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002113 }
2114 if (spec->dig_in_nid) {
2115 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2116 if (err < 0)
2117 return err;
2118 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002119
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002120 /* create beep controls if needed */
2121 if (spec->beep_amp) {
2122 struct snd_kcontrol_new *knew;
2123 for (knew = alc_beep_mixer; knew->name; knew++) {
2124 struct snd_kcontrol *kctl;
2125 kctl = snd_ctl_new1(knew, codec);
2126 if (!kctl)
2127 return -ENOMEM;
2128 kctl->private_value = spec->beep_amp;
2129 err = snd_hda_ctl_add(codec, kctl);
2130 if (err < 0)
2131 return err;
2132 }
2133 }
2134
Takashi Iwai2134ea42008-01-10 16:53:55 +01002135 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002136 if (!spec->no_analog &&
2137 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002138 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002139 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002140 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002141 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002142 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002143 if (err < 0)
2144 return err;
2145 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002146 if (!spec->no_analog &&
2147 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002148 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2149 NULL, alc_slave_sws);
2150 if (err < 0)
2151 return err;
2152 }
2153
Takashi Iwai603c4012008-07-30 15:01:44 +02002154 alc_free_kctls(codec); /* no longer needed */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002155 return 0;
2156}
2157
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002158
Linus Torvalds1da177e2005-04-16 15:20:36 -07002159/*
2160 * initialize the codec volumes, etc
2161 */
2162
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002163/*
2164 * generic initialization of ADC, input mixers and output mixers
2165 */
2166static struct hda_verb alc880_volume_init_verbs[] = {
2167 /*
2168 * Unmute ADC0-2 and set the default input to mic-in
2169 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002170 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002171 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002172 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002173 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002174 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002175 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002176
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002177 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2178 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002179 * Note: PASD motherboards uses the Line In 2 as the input for front
2180 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002181 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002182 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02002183 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2184 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2185 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2186 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2187 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2188 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2189 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002190
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002191 /*
2192 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002193 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002194 /* set vol=0 to output mixers */
2195 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2196 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2197 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2198 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2199 /* set up input amps for analog loopback */
2200 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002201 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2202 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002203 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2204 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002205 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2206 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002207 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2208 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002209
2210 { }
2211};
2212
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002213/*
2214 * 3-stack pin configuration:
2215 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2216 */
2217static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2218 /*
2219 * preset connection lists of input pins
2220 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2221 */
2222 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2223 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2224 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2225
2226 /*
2227 * Set pin mode and muting
2228 */
2229 /* set front pin widgets 0x14 for output */
2230 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2231 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2232 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2233 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2234 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2235 /* Mic2 (as headphone out) for HP output */
2236 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2237 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2238 /* Line In pin widget for input */
2239 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2240 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2241 /* Line2 (as front mic) pin widget for input and vref at 80% */
2242 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2243 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2244 /* CD pin widget for input */
2245 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2246
2247 { }
2248};
2249
2250/*
2251 * 5-stack pin configuration:
2252 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2253 * line-in/side = 0x1a, f-mic = 0x1b
2254 */
2255static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2256 /*
2257 * preset connection lists of input pins
2258 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2259 */
2260 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2261 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2262
2263 /*
2264 * Set pin mode and muting
2265 */
2266 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02002267 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2268 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2269 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2270 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002271 /* unmute pins for output (no gain on this amp) */
2272 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2273 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2274 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2275 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2276
Linus Torvalds1da177e2005-04-16 15:20:36 -07002277 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02002278 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002279 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2280 /* Mic2 (as headphone out) for HP output */
2281 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002282 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002283 /* Line In pin widget for input */
2284 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2285 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2286 /* Line2 (as front mic) pin widget for input and vref at 80% */
2287 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2288 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2289 /* CD pin widget for input */
2290 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002291
2292 { }
2293};
2294
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002295/*
2296 * W810 pin configuration:
2297 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2298 */
2299static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002300 /* hphone/speaker input selector: front DAC */
2301 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2302
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002303 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2304 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2305 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2306 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2307 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2308 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2309
2310 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002311 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002312
Linus Torvalds1da177e2005-04-16 15:20:36 -07002313 { }
2314};
2315
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002316/*
2317 * Z71V pin configuration:
2318 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2319 */
2320static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002321 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002322 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02002323 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002324 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002325
Takashi Iwai16ded522005-06-10 19:58:24 +02002326 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002327 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002328 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002329 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002330
2331 { }
2332};
2333
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002334/*
2335 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002336 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2337 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002338 */
2339static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2340 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2341
Takashi Iwai16ded522005-06-10 19:58:24 +02002342 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002343 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002344 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002345 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002346 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002347 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002348 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002349 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2350
Takashi Iwai16ded522005-06-10 19:58:24 +02002351 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002352 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002353 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002354 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002355 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002356 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002357 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02002358 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002359 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002360
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002361 { }
2362};
Takashi Iwai16ded522005-06-10 19:58:24 +02002363
Kailang Yangccc656c2006-10-17 12:32:26 +02002364/*
2365 * Uniwill pin configuration:
2366 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2367 * line = 0x1a
2368 */
2369static struct hda_verb alc880_uniwill_init_verbs[] = {
2370 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2371
2372 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2373 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2374 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2375 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2376 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2377 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2378 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2379 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2380 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2381 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2382 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2383 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2384 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2385 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2386
2387 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2388 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2389 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2390 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2391 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2392 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2393 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2394 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2395 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2396
2397 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2398 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2399
2400 { }
2401};
2402
2403/*
2404* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02002405* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02002406 */
2407static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2408 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2409
2410 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2411 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2412 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2413 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2414 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2415 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2416 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2417 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2418 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2419 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2420 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2421 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2422
2423 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2424 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2425 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2426 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2427 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2428 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2429
2430 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2431 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2432
2433 { }
2434};
2435
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002436static struct hda_verb alc880_beep_init_verbs[] = {
2437 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2438 { }
2439};
2440
Kailang Yangccc656c2006-10-17 12:32:26 +02002441/* toggle speaker-output according to the hp-jack state */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002442static void alc880_uniwill_hp_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02002443{
2444 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002445 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002446
2447 present = snd_hda_codec_read(codec, 0x14, 0,
2448 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002449 bits = present ? HDA_AMP_MUTE : 0;
2450 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
2451 HDA_AMP_MUTE, bits);
2452 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
2453 HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002454}
2455
2456/* auto-toggle front mic */
2457static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2458{
2459 unsigned int present;
2460 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002461
2462 present = snd_hda_codec_read(codec, 0x18, 0,
2463 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002464 bits = present ? HDA_AMP_MUTE : 0;
2465 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002466}
2467
2468static void alc880_uniwill_automute(struct hda_codec *codec)
2469{
2470 alc880_uniwill_hp_automute(codec);
2471 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002472}
2473
2474static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2475 unsigned int res)
2476{
2477 /* Looks like the unsol event is incompatible with the standard
2478 * definition. 4bit tag is placed at 28 bit!
2479 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002480 switch (res >> 28) {
2481 case ALC880_HP_EVENT:
2482 alc880_uniwill_hp_automute(codec);
2483 break;
2484 case ALC880_MIC_EVENT:
2485 alc880_uniwill_mic_automute(codec);
2486 break;
2487 }
Kailang Yangccc656c2006-10-17 12:32:26 +02002488}
2489
2490static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
2491{
2492 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002493 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002494
2495 present = snd_hda_codec_read(codec, 0x14, 0,
2496 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002497 bits = present ? HDA_AMP_MUTE : 0;
Jiang zhe64654c22008-04-14 13:26:21 +02002498 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, HDA_AMP_MUTE, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02002499}
2500
2501static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2502{
2503 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02002504
Kailang Yangccc656c2006-10-17 12:32:26 +02002505 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02002506 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2507 present &= HDA_AMP_VOLMASK;
2508 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2509 HDA_AMP_VOLMASK, present);
2510 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2511 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02002512}
Takashi Iwai47fd8302007-08-10 17:11:07 +02002513
Kailang Yangccc656c2006-10-17 12:32:26 +02002514static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2515 unsigned int res)
2516{
2517 /* Looks like the unsol event is incompatible with the standard
2518 * definition. 4bit tag is placed at 28 bit!
2519 */
2520 if ((res >> 28) == ALC880_HP_EVENT)
2521 alc880_uniwill_p53_hp_automute(codec);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002522 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02002523 alc880_uniwill_p53_dcvol_automute(codec);
2524}
2525
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002526/*
2527 * F1734 pin configuration:
2528 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2529 */
2530static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01002531 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002532 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2533 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2534 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2535 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2536
2537 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2538 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2539 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2540 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2541
2542 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2543 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01002544 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002545 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2546 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2547 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2548 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2549 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2550 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002551
Takashi Iwai937b4162008-02-11 14:52:36 +01002552 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2553 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2554
Takashi Iwai16ded522005-06-10 19:58:24 +02002555 { }
2556};
2557
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002558/*
2559 * ASUS pin configuration:
2560 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2561 */
2562static struct hda_verb alc880_pin_asus_init_verbs[] = {
2563 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2564 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2565 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2566 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2567
2568 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2569 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2570 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2571 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2572 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2573 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2574 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2575 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2576
2577 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2578 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2579 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2580 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2581 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2582 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2583 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2584 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2585 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002586
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002587 { }
2588};
2589
2590/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02002591#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2592#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002593
Kailang Yangdf694da2005-12-05 19:42:22 +01002594/* Clevo m520g init */
2595static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2596 /* headphone output */
2597 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2598 /* line-out */
2599 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2600 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2601 /* Line-in */
2602 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2603 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2604 /* CD */
2605 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2606 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2607 /* Mic1 (rear panel) */
2608 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2609 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2610 /* Mic2 (front panel) */
2611 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2612 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2613 /* headphone */
2614 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2615 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2616 /* change to EAPD mode */
2617 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2618 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2619
2620 { }
2621};
2622
2623static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002624 /* change to EAPD mode */
2625 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2626 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2627
Kailang Yangdf694da2005-12-05 19:42:22 +01002628 /* Headphone output */
2629 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2630 /* Front output*/
2631 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2632 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2633
2634 /* Line In pin widget for input */
2635 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2636 /* CD pin widget for input */
2637 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2638 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2639 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2640
2641 /* change to EAPD mode */
2642 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2643 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2644
2645 { }
2646};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002647
2648/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002649 * LG m1 express dual
2650 *
2651 * Pin assignment:
2652 * Rear Line-In/Out (blue): 0x14
2653 * Build-in Mic-In: 0x15
2654 * Speaker-out: 0x17
2655 * HP-Out (green): 0x1b
2656 * Mic-In/Out (red): 0x19
2657 * SPDIF-Out: 0x1e
2658 */
2659
2660/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2661static hda_nid_t alc880_lg_dac_nids[3] = {
2662 0x05, 0x02, 0x03
2663};
2664
2665/* seems analog CD is not working */
2666static struct hda_input_mux alc880_lg_capture_source = {
2667 .num_items = 3,
2668 .items = {
2669 { "Mic", 0x1 },
2670 { "Line", 0x5 },
2671 { "Internal Mic", 0x6 },
2672 },
2673};
2674
2675/* 2,4,6 channel modes */
2676static struct hda_verb alc880_lg_ch2_init[] = {
2677 /* set line-in and mic-in to input */
2678 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2679 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2680 { }
2681};
2682
2683static struct hda_verb alc880_lg_ch4_init[] = {
2684 /* set line-in to out and mic-in to input */
2685 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2686 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2687 { }
2688};
2689
2690static struct hda_verb alc880_lg_ch6_init[] = {
2691 /* set line-in and mic-in to output */
2692 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2693 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2694 { }
2695};
2696
2697static struct hda_channel_mode alc880_lg_ch_modes[3] = {
2698 { 2, alc880_lg_ch2_init },
2699 { 4, alc880_lg_ch4_init },
2700 { 6, alc880_lg_ch6_init },
2701};
2702
2703static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002704 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2705 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002706 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2707 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
2708 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
2709 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
2710 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
2711 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
2712 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2713 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2714 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
2715 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
2716 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
2717 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
2718 {
2719 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2720 .name = "Channel Mode",
2721 .info = alc_ch_mode_info,
2722 .get = alc_ch_mode_get,
2723 .put = alc_ch_mode_put,
2724 },
2725 { } /* end */
2726};
2727
2728static struct hda_verb alc880_lg_init_verbs[] = {
2729 /* set capture source to mic-in */
2730 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2731 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2732 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2733 /* mute all amp mixer inputs */
2734 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002735 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2736 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002737 /* line-in to input */
2738 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2739 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2740 /* built-in mic */
2741 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2742 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2743 /* speaker-out */
2744 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2745 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2746 /* mic-in to input */
2747 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2748 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2749 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2750 /* HP-out */
2751 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
2752 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2753 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2754 /* jack sense */
2755 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2756 { }
2757};
2758
2759/* toggle speaker-output according to the hp-jack state */
2760static void alc880_lg_automute(struct hda_codec *codec)
2761{
2762 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002763 unsigned char bits;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002764
2765 present = snd_hda_codec_read(codec, 0x1b, 0,
2766 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002767 bits = present ? HDA_AMP_MUTE : 0;
2768 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
2769 HDA_AMP_MUTE, bits);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002770}
2771
2772static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
2773{
2774 /* Looks like the unsol event is incompatible with the standard
2775 * definition. 4bit tag is placed at 28 bit!
2776 */
2777 if ((res >> 28) == 0x01)
2778 alc880_lg_automute(codec);
2779}
2780
2781/*
Takashi Iwaid6815182006-03-23 16:06:23 +01002782 * LG LW20
2783 *
2784 * Pin assignment:
2785 * Speaker-out: 0x14
2786 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002787 * Built-in Mic-In: 0x19
2788 * Line-In: 0x1b
2789 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01002790 * SPDIF-Out: 0x1e
2791 */
2792
Takashi Iwaid6815182006-03-23 16:06:23 +01002793static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002794 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01002795 .items = {
2796 { "Mic", 0x0 },
2797 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002798 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002799 },
2800};
2801
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002802#define alc880_lg_lw_modes alc880_threestack_modes
2803
Takashi Iwaid6815182006-03-23 16:06:23 +01002804static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002805 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2806 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2807 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2808 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2809 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2810 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2811 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2812 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2813 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2814 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01002815 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2816 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2817 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
2818 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002819 {
2820 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2821 .name = "Channel Mode",
2822 .info = alc_ch_mode_info,
2823 .get = alc_ch_mode_get,
2824 .put = alc_ch_mode_put,
2825 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002826 { } /* end */
2827};
2828
2829static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002830 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2831 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2832 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2833
Takashi Iwaid6815182006-03-23 16:06:23 +01002834 /* set capture source to mic-in */
2835 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2836 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2837 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002838 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01002839 /* speaker-out */
2840 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2841 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2842 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01002843 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2844 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2845 /* mic-in to input */
2846 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2847 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2848 /* built-in mic */
2849 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2850 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2851 /* jack sense */
2852 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2853 { }
2854};
2855
2856/* toggle speaker-output according to the hp-jack state */
2857static void alc880_lg_lw_automute(struct hda_codec *codec)
2858{
2859 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002860 unsigned char bits;
Takashi Iwaid6815182006-03-23 16:06:23 +01002861
2862 present = snd_hda_codec_read(codec, 0x1b, 0,
2863 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002864 bits = present ? HDA_AMP_MUTE : 0;
2865 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
2866 HDA_AMP_MUTE, bits);
Takashi Iwaid6815182006-03-23 16:06:23 +01002867}
2868
2869static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
2870{
2871 /* Looks like the unsol event is incompatible with the standard
2872 * definition. 4bit tag is placed at 28 bit!
2873 */
2874 if ((res >> 28) == 0x01)
2875 alc880_lg_lw_automute(codec);
2876}
2877
Takashi Iwaidf99cd32008-04-25 15:25:04 +02002878static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
2879 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2880 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
2881 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2882 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2883 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2884 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
2885 { } /* end */
2886};
2887
2888static struct hda_input_mux alc880_medion_rim_capture_source = {
2889 .num_items = 2,
2890 .items = {
2891 { "Mic", 0x0 },
2892 { "Internal Mic", 0x1 },
2893 },
2894};
2895
2896static struct hda_verb alc880_medion_rim_init_verbs[] = {
2897 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2898
2899 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2900 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2901
2902 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2903 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2904 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2905 /* Mic2 (as headphone out) for HP output */
2906 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2907 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2908 /* Internal Speaker */
2909 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2910 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2911
2912 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2913 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2914
2915 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2916 { }
2917};
2918
2919/* toggle speaker-output according to the hp-jack state */
2920static void alc880_medion_rim_automute(struct hda_codec *codec)
2921{
2922 unsigned int present;
2923 unsigned char bits;
2924
2925 present = snd_hda_codec_read(codec, 0x14, 0,
2926 AC_VERB_GET_PIN_SENSE, 0)
2927 & AC_PINSENSE_PRESENCE;
2928 bits = present ? HDA_AMP_MUTE : 0;
2929 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
2930 HDA_AMP_MUTE, bits);
2931 if (present)
2932 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
2933 else
2934 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
2935}
2936
2937static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
2938 unsigned int res)
2939{
2940 /* Looks like the unsol event is incompatible with the standard
2941 * definition. 4bit tag is placed at 28 bit!
2942 */
2943 if ((res >> 28) == ALC880_HP_EVENT)
2944 alc880_medion_rim_automute(codec);
2945}
2946
Takashi Iwaicb53c622007-08-10 17:21:45 +02002947#ifdef CONFIG_SND_HDA_POWER_SAVE
2948static struct hda_amp_list alc880_loopbacks[] = {
2949 { 0x0b, HDA_INPUT, 0 },
2950 { 0x0b, HDA_INPUT, 1 },
2951 { 0x0b, HDA_INPUT, 2 },
2952 { 0x0b, HDA_INPUT, 3 },
2953 { 0x0b, HDA_INPUT, 4 },
2954 { } /* end */
2955};
2956
2957static struct hda_amp_list alc880_lg_loopbacks[] = {
2958 { 0x0b, HDA_INPUT, 1 },
2959 { 0x0b, HDA_INPUT, 6 },
2960 { 0x0b, HDA_INPUT, 7 },
2961 { } /* end */
2962};
2963#endif
2964
Takashi Iwaid6815182006-03-23 16:06:23 +01002965/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002966 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002967 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002968
Linus Torvalds1da177e2005-04-16 15:20:36 -07002969static int alc_init(struct hda_codec *codec)
2970{
2971 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002972 unsigned int i;
2973
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02002974 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02002975 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02002976
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002977 for (i = 0; i < spec->num_init_verbs; i++)
2978 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002979
2980 if (spec->init_hook)
2981 spec->init_hook(codec);
2982
Linus Torvalds1da177e2005-04-16 15:20:36 -07002983 return 0;
2984}
2985
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002986static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2987{
2988 struct alc_spec *spec = codec->spec;
2989
2990 if (spec->unsol_event)
2991 spec->unsol_event(codec, res);
2992}
2993
Takashi Iwaicb53c622007-08-10 17:21:45 +02002994#ifdef CONFIG_SND_HDA_POWER_SAVE
2995static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
2996{
2997 struct alc_spec *spec = codec->spec;
2998 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
2999}
3000#endif
3001
Linus Torvalds1da177e2005-04-16 15:20:36 -07003002/*
3003 * Analog playback callbacks
3004 */
3005static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3006 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003007 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003008{
3009 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01003010 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3011 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003012}
3013
3014static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3015 struct hda_codec *codec,
3016 unsigned int stream_tag,
3017 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003018 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003019{
3020 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003021 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3022 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003023}
3024
3025static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3026 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003027 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003028{
3029 struct alc_spec *spec = codec->spec;
3030 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3031}
3032
3033/*
3034 * Digital out
3035 */
3036static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3037 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003038 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003039{
3040 struct alc_spec *spec = codec->spec;
3041 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3042}
3043
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003044static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3045 struct hda_codec *codec,
3046 unsigned int stream_tag,
3047 unsigned int format,
3048 struct snd_pcm_substream *substream)
3049{
3050 struct alc_spec *spec = codec->spec;
3051 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3052 stream_tag, format, substream);
3053}
3054
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003055static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3056 struct hda_codec *codec,
3057 struct snd_pcm_substream *substream)
3058{
3059 struct alc_spec *spec = codec->spec;
3060 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3061}
3062
Linus Torvalds1da177e2005-04-16 15:20:36 -07003063static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3064 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003065 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003066{
3067 struct alc_spec *spec = codec->spec;
3068 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3069}
3070
3071/*
3072 * Analog capture
3073 */
Takashi Iwai63300792008-01-24 15:31:36 +01003074static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003075 struct hda_codec *codec,
3076 unsigned int stream_tag,
3077 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003078 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003079{
3080 struct alc_spec *spec = codec->spec;
3081
Takashi Iwai63300792008-01-24 15:31:36 +01003082 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07003083 stream_tag, 0, format);
3084 return 0;
3085}
3086
Takashi Iwai63300792008-01-24 15:31:36 +01003087static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003088 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003089 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003090{
3091 struct alc_spec *spec = codec->spec;
3092
Takashi Iwai888afa12008-03-18 09:57:50 +01003093 snd_hda_codec_cleanup_stream(codec,
3094 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003095 return 0;
3096}
3097
3098
3099/*
3100 */
3101static struct hda_pcm_stream alc880_pcm_analog_playback = {
3102 .substreams = 1,
3103 .channels_min = 2,
3104 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003105 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003106 .ops = {
3107 .open = alc880_playback_pcm_open,
3108 .prepare = alc880_playback_pcm_prepare,
3109 .cleanup = alc880_playback_pcm_cleanup
3110 },
3111};
3112
3113static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01003114 .substreams = 1,
3115 .channels_min = 2,
3116 .channels_max = 2,
3117 /* NID is set in alc_build_pcms */
3118};
3119
3120static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3121 .substreams = 1,
3122 .channels_min = 2,
3123 .channels_max = 2,
3124 /* NID is set in alc_build_pcms */
3125};
3126
3127static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3128 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003129 .channels_min = 2,
3130 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003131 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003132 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01003133 .prepare = alc880_alt_capture_pcm_prepare,
3134 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003135 },
3136};
3137
3138static struct hda_pcm_stream alc880_pcm_digital_playback = {
3139 .substreams = 1,
3140 .channels_min = 2,
3141 .channels_max = 2,
3142 /* NID is set in alc_build_pcms */
3143 .ops = {
3144 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003145 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003146 .prepare = alc880_dig_playback_pcm_prepare,
3147 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003148 },
3149};
3150
3151static struct hda_pcm_stream alc880_pcm_digital_capture = {
3152 .substreams = 1,
3153 .channels_min = 2,
3154 .channels_max = 2,
3155 /* NID is set in alc_build_pcms */
3156};
3157
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003158/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01003159static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003160 .substreams = 0,
3161 .channels_min = 0,
3162 .channels_max = 0,
3163};
3164
Linus Torvalds1da177e2005-04-16 15:20:36 -07003165static int alc_build_pcms(struct hda_codec *codec)
3166{
3167 struct alc_spec *spec = codec->spec;
3168 struct hda_pcm *info = spec->pcm_rec;
3169 int i;
3170
3171 codec->num_pcms = 1;
3172 codec->pcm_info = info;
3173
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003174 if (spec->no_analog)
3175 goto skip_analog;
3176
Linus Torvalds1da177e2005-04-16 15:20:36 -07003177 info->name = spec->stream_name_analog;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003178 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003179 if (snd_BUG_ON(!spec->multiout.dac_nids))
3180 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003181 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3182 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3183 }
3184 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003185 if (snd_BUG_ON(!spec->adc_nids))
3186 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003187 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3188 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3189 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003190
Takashi Iwai4a471b72005-12-07 13:56:29 +01003191 if (spec->channel_mode) {
3192 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3193 for (i = 0; i < spec->num_channel_mode; i++) {
3194 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3195 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3196 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003197 }
3198 }
3199
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003200 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02003201 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003202 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003203 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08003204 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003205 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003206 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01003207 if (spec->dig_out_type)
3208 info->pcm_type = spec->dig_out_type;
3209 else
3210 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003211 if (spec->multiout.dig_out_nid &&
3212 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003213 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
3214 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3215 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01003216 if (spec->dig_in_nid &&
3217 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003218 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
3219 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3220 }
Takashi Iwai963f8032008-08-11 10:04:40 +02003221 /* FIXME: do we need this for all Realtek codec models? */
3222 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003223 }
3224
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003225 if (spec->no_analog)
3226 return 0;
3227
Takashi Iwaie08a0072006-09-07 17:52:14 +02003228 /* If the use of more than one ADC is requested for the current
3229 * model, configure a second analog capture-only PCM.
3230 */
3231 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01003232 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
3233 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003234 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003235 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003236 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01003237 if (spec->alt_dac_nid) {
3238 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3239 *spec->stream_analog_alt_playback;
3240 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3241 spec->alt_dac_nid;
3242 } else {
3243 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3244 alc_pcm_null_stream;
3245 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
3246 }
3247 if (spec->num_adc_nids > 1) {
3248 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3249 *spec->stream_analog_alt_capture;
3250 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
3251 spec->adc_nids[1];
3252 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
3253 spec->num_adc_nids - 1;
3254 } else {
3255 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3256 alc_pcm_null_stream;
3257 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003258 }
3259 }
3260
Linus Torvalds1da177e2005-04-16 15:20:36 -07003261 return 0;
3262}
3263
Takashi Iwai603c4012008-07-30 15:01:44 +02003264static void alc_free_kctls(struct hda_codec *codec)
3265{
3266 struct alc_spec *spec = codec->spec;
3267
3268 if (spec->kctls.list) {
3269 struct snd_kcontrol_new *kctl = spec->kctls.list;
3270 int i;
3271 for (i = 0; i < spec->kctls.used; i++)
3272 kfree(kctl[i].name);
3273 }
3274 snd_array_free(&spec->kctls);
3275}
3276
Linus Torvalds1da177e2005-04-16 15:20:36 -07003277static void alc_free(struct hda_codec *codec)
3278{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003279 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003280
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003281 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003282 return;
3283
Takashi Iwai603c4012008-07-30 15:01:44 +02003284 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003285 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09003286 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003287}
3288
Takashi Iwaie044c392008-10-27 16:56:24 +01003289#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01003290static int alc_resume(struct hda_codec *codec)
3291{
Takashi Iwaie044c392008-10-27 16:56:24 +01003292 codec->patch_ops.init(codec);
3293 snd_hda_codec_resume_amp(codec);
3294 snd_hda_codec_resume_cache(codec);
3295 return 0;
3296}
Takashi Iwaie044c392008-10-27 16:56:24 +01003297#endif
3298
Linus Torvalds1da177e2005-04-16 15:20:36 -07003299/*
3300 */
3301static struct hda_codec_ops alc_patch_ops = {
3302 .build_controls = alc_build_controls,
3303 .build_pcms = alc_build_pcms,
3304 .init = alc_init,
3305 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003306 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01003307#ifdef SND_HDA_NEEDS_RESUME
3308 .resume = alc_resume,
3309#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02003310#ifdef CONFIG_SND_HDA_POWER_SAVE
3311 .check_power_status = alc_check_power_status,
3312#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003313};
3314
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003315
3316/*
3317 * Test configuration for debugging
3318 *
3319 * Almost all inputs/outputs are enabled. I/O pins can be configured via
3320 * enum controls.
3321 */
3322#ifdef CONFIG_SND_DEBUG
3323static hda_nid_t alc880_test_dac_nids[4] = {
3324 0x02, 0x03, 0x04, 0x05
3325};
3326
3327static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003328 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003329 .items = {
3330 { "In-1", 0x0 },
3331 { "In-2", 0x1 },
3332 { "In-3", 0x2 },
3333 { "In-4", 0x3 },
3334 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003335 { "Front", 0x5 },
3336 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003337 },
3338};
3339
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003340static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003341 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003342 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003343 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003344 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003345};
3346
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003347static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
3348 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003349{
3350 static char *texts[] = {
3351 "N/A", "Line Out", "HP Out",
3352 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
3353 };
3354 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3355 uinfo->count = 1;
3356 uinfo->value.enumerated.items = 8;
3357 if (uinfo->value.enumerated.item >= 8)
3358 uinfo->value.enumerated.item = 7;
3359 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3360 return 0;
3361}
3362
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003363static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
3364 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003365{
3366 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3367 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3368 unsigned int pin_ctl, item = 0;
3369
3370 pin_ctl = snd_hda_codec_read(codec, nid, 0,
3371 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3372 if (pin_ctl & AC_PINCTL_OUT_EN) {
3373 if (pin_ctl & AC_PINCTL_HP_EN)
3374 item = 2;
3375 else
3376 item = 1;
3377 } else if (pin_ctl & AC_PINCTL_IN_EN) {
3378 switch (pin_ctl & AC_PINCTL_VREFEN) {
3379 case AC_PINCTL_VREF_HIZ: item = 3; break;
3380 case AC_PINCTL_VREF_50: item = 4; break;
3381 case AC_PINCTL_VREF_GRD: item = 5; break;
3382 case AC_PINCTL_VREF_80: item = 6; break;
3383 case AC_PINCTL_VREF_100: item = 7; break;
3384 }
3385 }
3386 ucontrol->value.enumerated.item[0] = item;
3387 return 0;
3388}
3389
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003390static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
3391 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003392{
3393 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3394 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3395 static unsigned int ctls[] = {
3396 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
3397 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
3398 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
3399 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
3400 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
3401 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
3402 };
3403 unsigned int old_ctl, new_ctl;
3404
3405 old_ctl = snd_hda_codec_read(codec, nid, 0,
3406 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3407 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
3408 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003409 int val;
3410 snd_hda_codec_write_cache(codec, nid, 0,
3411 AC_VERB_SET_PIN_WIDGET_CONTROL,
3412 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003413 val = ucontrol->value.enumerated.item[0] >= 3 ?
3414 HDA_AMP_MUTE : 0;
3415 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3416 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003417 return 1;
3418 }
3419 return 0;
3420}
3421
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003422static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
3423 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003424{
3425 static char *texts[] = {
3426 "Front", "Surround", "CLFE", "Side"
3427 };
3428 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3429 uinfo->count = 1;
3430 uinfo->value.enumerated.items = 4;
3431 if (uinfo->value.enumerated.item >= 4)
3432 uinfo->value.enumerated.item = 3;
3433 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3434 return 0;
3435}
3436
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003437static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
3438 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003439{
3440 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3441 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3442 unsigned int sel;
3443
3444 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
3445 ucontrol->value.enumerated.item[0] = sel & 3;
3446 return 0;
3447}
3448
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003449static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
3450 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003451{
3452 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3453 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3454 unsigned int sel;
3455
3456 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
3457 if (ucontrol->value.enumerated.item[0] != sel) {
3458 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003459 snd_hda_codec_write_cache(codec, nid, 0,
3460 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003461 return 1;
3462 }
3463 return 0;
3464}
3465
3466#define PIN_CTL_TEST(xname,nid) { \
3467 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3468 .name = xname, \
3469 .info = alc_test_pin_ctl_info, \
3470 .get = alc_test_pin_ctl_get, \
3471 .put = alc_test_pin_ctl_put, \
3472 .private_value = nid \
3473 }
3474
3475#define PIN_SRC_TEST(xname,nid) { \
3476 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3477 .name = xname, \
3478 .info = alc_test_pin_src_info, \
3479 .get = alc_test_pin_src_get, \
3480 .put = alc_test_pin_src_put, \
3481 .private_value = nid \
3482 }
3483
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003484static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003485 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3486 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3487 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
3488 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003489 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3490 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
3491 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
3492 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003493 PIN_CTL_TEST("Front Pin Mode", 0x14),
3494 PIN_CTL_TEST("Surround Pin Mode", 0x15),
3495 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
3496 PIN_CTL_TEST("Side Pin Mode", 0x17),
3497 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
3498 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
3499 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
3500 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
3501 PIN_SRC_TEST("In-1 Pin Source", 0x18),
3502 PIN_SRC_TEST("In-2 Pin Source", 0x19),
3503 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
3504 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
3505 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
3506 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
3507 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
3508 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
3509 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
3510 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
3511 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
3512 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
3513 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
3514 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003515 {
3516 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3517 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01003518 .info = alc_ch_mode_info,
3519 .get = alc_ch_mode_get,
3520 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003521 },
3522 { } /* end */
3523};
3524
3525static struct hda_verb alc880_test_init_verbs[] = {
3526 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003527 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3528 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3529 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3530 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3531 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3532 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3533 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3534 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003535 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003536 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3537 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3538 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3539 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003540 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003541 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3542 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3543 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3544 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003545 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003546 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3547 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3548 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3549 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003550 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02003551 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3552 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02003553 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3554 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3555 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003556 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02003557 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3558 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3559 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3560 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003561 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02003562 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003563 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003564 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003565 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003566 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003567 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003568 /* Analog input/passthru */
3569 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3570 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3571 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3572 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3573 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003574 { }
3575};
3576#endif
3577
Linus Torvalds1da177e2005-04-16 15:20:36 -07003578/*
3579 */
3580
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003581static const char *alc880_models[ALC880_MODEL_LAST] = {
3582 [ALC880_3ST] = "3stack",
3583 [ALC880_TCL_S700] = "tcl",
3584 [ALC880_3ST_DIG] = "3stack-digout",
3585 [ALC880_CLEVO] = "clevo",
3586 [ALC880_5ST] = "5stack",
3587 [ALC880_5ST_DIG] = "5stack-digout",
3588 [ALC880_W810] = "w810",
3589 [ALC880_Z71V] = "z71v",
3590 [ALC880_6ST] = "6stack",
3591 [ALC880_6ST_DIG] = "6stack-digout",
3592 [ALC880_ASUS] = "asus",
3593 [ALC880_ASUS_W1V] = "asus-w1v",
3594 [ALC880_ASUS_DIG] = "asus-dig",
3595 [ALC880_ASUS_DIG2] = "asus-dig2",
3596 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003597 [ALC880_UNIWILL_P53] = "uniwill-p53",
3598 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003599 [ALC880_F1734] = "F1734",
3600 [ALC880_LG] = "lg",
3601 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003602 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003603#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003604 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003605#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003606 [ALC880_AUTO] = "auto",
3607};
3608
3609static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003610 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003611 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
3612 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
3613 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
3614 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
3615 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
3616 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
3617 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
3618 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003619 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
3620 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003621 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
3622 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
3623 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
3624 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
3625 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
3626 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
3627 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
3628 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
3629 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
3630 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02003631 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003632 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
3633 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
3634 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01003635 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003636 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003637 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
3638 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003639 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
3640 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003641 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
3642 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
3643 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
3644 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003645 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
3646 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003647 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003648 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003649 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003650 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003651 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
3652 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003653 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003654 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003655 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003656 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003657 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02003658 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003659 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003660 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003661 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003662 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
3663 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003664 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003665 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
3666 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
3667 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
3668 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003669 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
3670 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003671 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003672 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003673 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
3674 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003675 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
3676 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
3677 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01003678 /* default Intel */
3679 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003680 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
3681 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003682 {}
3683};
3684
Takashi Iwai16ded522005-06-10 19:58:24 +02003685/*
Kailang Yangdf694da2005-12-05 19:42:22 +01003686 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02003687 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003688static struct alc_config_preset alc880_presets[] = {
3689 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003690 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003691 .init_verbs = { alc880_volume_init_verbs,
3692 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003693 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003694 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003695 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3696 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003697 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003698 .input_mux = &alc880_capture_source,
3699 },
3700 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003701 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003702 .init_verbs = { alc880_volume_init_verbs,
3703 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003704 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003705 .dac_nids = alc880_dac_nids,
3706 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003707 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3708 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003709 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003710 .input_mux = &alc880_capture_source,
3711 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003712 [ALC880_TCL_S700] = {
3713 .mixers = { alc880_tcl_s700_mixer },
3714 .init_verbs = { alc880_volume_init_verbs,
3715 alc880_pin_tcl_S700_init_verbs,
3716 alc880_gpio2_init_verbs },
3717 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3718 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01003719 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
3720 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01003721 .hp_nid = 0x03,
3722 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3723 .channel_mode = alc880_2_jack_modes,
3724 .input_mux = &alc880_capture_source,
3725 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003726 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003727 .mixers = { alc880_three_stack_mixer,
3728 alc880_five_stack_mixer},
3729 .init_verbs = { alc880_volume_init_verbs,
3730 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003731 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3732 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003733 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3734 .channel_mode = alc880_fivestack_modes,
3735 .input_mux = &alc880_capture_source,
3736 },
3737 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003738 .mixers = { alc880_three_stack_mixer,
3739 alc880_five_stack_mixer },
3740 .init_verbs = { alc880_volume_init_verbs,
3741 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003742 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3743 .dac_nids = alc880_dac_nids,
3744 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003745 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3746 .channel_mode = alc880_fivestack_modes,
3747 .input_mux = &alc880_capture_source,
3748 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003749 [ALC880_6ST] = {
3750 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003751 .init_verbs = { alc880_volume_init_verbs,
3752 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003753 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3754 .dac_nids = alc880_6st_dac_nids,
3755 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3756 .channel_mode = alc880_sixstack_modes,
3757 .input_mux = &alc880_6stack_capture_source,
3758 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003759 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003760 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003761 .init_verbs = { alc880_volume_init_verbs,
3762 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003763 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3764 .dac_nids = alc880_6st_dac_nids,
3765 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003766 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3767 .channel_mode = alc880_sixstack_modes,
3768 .input_mux = &alc880_6stack_capture_source,
3769 },
3770 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003771 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003772 .init_verbs = { alc880_volume_init_verbs,
3773 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003774 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003775 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
3776 .dac_nids = alc880_w810_dac_nids,
3777 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003778 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3779 .channel_mode = alc880_w810_modes,
3780 .input_mux = &alc880_capture_source,
3781 },
3782 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003783 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003784 .init_verbs = { alc880_volume_init_verbs,
3785 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003786 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
3787 .dac_nids = alc880_z71v_dac_nids,
3788 .dig_out_nid = ALC880_DIGOUT_NID,
3789 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003790 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3791 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02003792 .input_mux = &alc880_capture_source,
3793 },
3794 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003795 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003796 .init_verbs = { alc880_volume_init_verbs,
3797 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003798 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
3799 .dac_nids = alc880_f1734_dac_nids,
3800 .hp_nid = 0x02,
3801 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3802 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01003803 .input_mux = &alc880_f1734_capture_source,
3804 .unsol_event = alc880_uniwill_p53_unsol_event,
3805 .init_hook = alc880_uniwill_p53_hp_automute,
Takashi Iwai16ded522005-06-10 19:58:24 +02003806 },
3807 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003808 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003809 .init_verbs = { alc880_volume_init_verbs,
3810 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003811 alc880_gpio1_init_verbs },
3812 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3813 .dac_nids = alc880_asus_dac_nids,
3814 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3815 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003816 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003817 .input_mux = &alc880_capture_source,
3818 },
3819 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003820 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003821 .init_verbs = { alc880_volume_init_verbs,
3822 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003823 alc880_gpio1_init_verbs },
3824 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3825 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003826 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003827 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3828 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003829 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003830 .input_mux = &alc880_capture_source,
3831 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003832 [ALC880_ASUS_DIG2] = {
3833 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003834 .init_verbs = { alc880_volume_init_verbs,
3835 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01003836 alc880_gpio2_init_verbs }, /* use GPIO2 */
3837 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3838 .dac_nids = alc880_asus_dac_nids,
3839 .dig_out_nid = ALC880_DIGOUT_NID,
3840 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3841 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003842 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003843 .input_mux = &alc880_capture_source,
3844 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003845 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003846 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003847 .init_verbs = { alc880_volume_init_verbs,
3848 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003849 alc880_gpio1_init_verbs },
3850 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3851 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003852 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003853 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3854 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003855 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003856 .input_mux = &alc880_capture_source,
3857 },
3858 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01003859 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02003860 .init_verbs = { alc880_volume_init_verbs,
3861 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003862 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3863 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003864 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003865 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3866 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003867 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003868 .input_mux = &alc880_capture_source,
3869 },
Kailang Yangccc656c2006-10-17 12:32:26 +02003870 [ALC880_UNIWILL] = {
3871 .mixers = { alc880_uniwill_mixer },
3872 .init_verbs = { alc880_volume_init_verbs,
3873 alc880_uniwill_init_verbs },
3874 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3875 .dac_nids = alc880_asus_dac_nids,
3876 .dig_out_nid = ALC880_DIGOUT_NID,
3877 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3878 .channel_mode = alc880_threestack_modes,
3879 .need_dac_fix = 1,
3880 .input_mux = &alc880_capture_source,
3881 .unsol_event = alc880_uniwill_unsol_event,
3882 .init_hook = alc880_uniwill_automute,
3883 },
3884 [ALC880_UNIWILL_P53] = {
3885 .mixers = { alc880_uniwill_p53_mixer },
3886 .init_verbs = { alc880_volume_init_verbs,
3887 alc880_uniwill_p53_init_verbs },
3888 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3889 .dac_nids = alc880_asus_dac_nids,
3890 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003891 .channel_mode = alc880_threestack_modes,
3892 .input_mux = &alc880_capture_source,
3893 .unsol_event = alc880_uniwill_p53_unsol_event,
3894 .init_hook = alc880_uniwill_p53_hp_automute,
3895 },
3896 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01003897 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003898 .init_verbs = { alc880_volume_init_verbs,
3899 alc880_uniwill_p53_init_verbs,
3900 alc880_beep_init_verbs },
3901 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3902 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02003903 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003904 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3905 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02003906 .input_mux = &alc880_capture_source,
3907 .unsol_event = alc880_uniwill_p53_unsol_event,
3908 .init_hook = alc880_uniwill_p53_hp_automute,
3909 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003910 [ALC880_CLEVO] = {
3911 .mixers = { alc880_three_stack_mixer },
3912 .init_verbs = { alc880_volume_init_verbs,
3913 alc880_pin_clevo_init_verbs },
3914 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3915 .dac_nids = alc880_dac_nids,
3916 .hp_nid = 0x03,
3917 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3918 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003919 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003920 .input_mux = &alc880_capture_source,
3921 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003922 [ALC880_LG] = {
3923 .mixers = { alc880_lg_mixer },
3924 .init_verbs = { alc880_volume_init_verbs,
3925 alc880_lg_init_verbs },
3926 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
3927 .dac_nids = alc880_lg_dac_nids,
3928 .dig_out_nid = ALC880_DIGOUT_NID,
3929 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
3930 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003931 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003932 .input_mux = &alc880_lg_capture_source,
3933 .unsol_event = alc880_lg_unsol_event,
3934 .init_hook = alc880_lg_automute,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003935#ifdef CONFIG_SND_HDA_POWER_SAVE
3936 .loopbacks = alc880_lg_loopbacks,
3937#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003938 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003939 [ALC880_LG_LW] = {
3940 .mixers = { alc880_lg_lw_mixer },
3941 .init_verbs = { alc880_volume_init_verbs,
3942 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003943 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01003944 .dac_nids = alc880_dac_nids,
3945 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003946 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
3947 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01003948 .input_mux = &alc880_lg_lw_capture_source,
3949 .unsol_event = alc880_lg_lw_unsol_event,
3950 .init_hook = alc880_lg_lw_automute,
3951 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003952 [ALC880_MEDION_RIM] = {
3953 .mixers = { alc880_medion_rim_mixer },
3954 .init_verbs = { alc880_volume_init_verbs,
3955 alc880_medion_rim_init_verbs,
3956 alc_gpio2_init_verbs },
3957 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3958 .dac_nids = alc880_dac_nids,
3959 .dig_out_nid = ALC880_DIGOUT_NID,
3960 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3961 .channel_mode = alc880_2_jack_modes,
3962 .input_mux = &alc880_medion_rim_capture_source,
3963 .unsol_event = alc880_medion_rim_unsol_event,
3964 .init_hook = alc880_medion_rim_automute,
3965 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003966#ifdef CONFIG_SND_DEBUG
3967 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003968 .mixers = { alc880_test_mixer },
3969 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003970 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
3971 .dac_nids = alc880_test_dac_nids,
3972 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003973 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
3974 .channel_mode = alc880_test_modes,
3975 .input_mux = &alc880_test_capture_source,
3976 },
3977#endif
3978};
3979
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003980/*
3981 * Automatic parse of I/O pins from the BIOS configuration
3982 */
3983
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003984enum {
3985 ALC_CTL_WIDGET_VOL,
3986 ALC_CTL_WIDGET_MUTE,
3987 ALC_CTL_BIND_MUTE,
3988};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003989static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003990 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
3991 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01003992 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003993};
3994
3995/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003996static int add_control(struct alc_spec *spec, int type, const char *name,
3997 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003998{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003999 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004000
Takashi Iwai603c4012008-07-30 15:01:44 +02004001 snd_array_init(&spec->kctls, sizeof(*knew), 32);
4002 knew = snd_array_new(&spec->kctls);
4003 if (!knew)
4004 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004005 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07004006 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004007 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004008 return -ENOMEM;
4009 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004010 return 0;
4011}
4012
4013#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
4014#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
4015#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
4016#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
4017#define alc880_is_input_pin(nid) ((nid) >= 0x18)
4018#define alc880_input_pin_idx(nid) ((nid) - 0x18)
4019#define alc880_idx_to_dac(nid) ((nid) + 0x02)
4020#define alc880_dac_to_idx(nid) ((nid) - 0x02)
4021#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
4022#define alc880_idx_to_selector(nid) ((nid) + 0x10)
4023#define ALC880_PIN_CD_NID 0x1c
4024
4025/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004026static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
4027 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004028{
4029 hda_nid_t nid;
4030 int assigned[4];
4031 int i, j;
4032
4033 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004034 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004035
4036 /* check the pins hardwired to audio widget */
4037 for (i = 0; i < cfg->line_outs; i++) {
4038 nid = cfg->line_out_pins[i];
4039 if (alc880_is_fixed_pin(nid)) {
4040 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01004041 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004042 assigned[idx] = 1;
4043 }
4044 }
4045 /* left pins can be connect to any audio widget */
4046 for (i = 0; i < cfg->line_outs; i++) {
4047 nid = cfg->line_out_pins[i];
4048 if (alc880_is_fixed_pin(nid))
4049 continue;
4050 /* search for an empty channel */
4051 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004052 if (!assigned[j]) {
4053 spec->multiout.dac_nids[i] =
4054 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004055 assigned[j] = 1;
4056 break;
4057 }
4058 }
4059 }
4060 spec->multiout.num_dacs = cfg->line_outs;
4061 return 0;
4062}
4063
4064/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01004065static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
4066 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004067{
4068 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004069 static const char *chname[4] = {
4070 "Front", "Surround", NULL /*CLFE*/, "Side"
4071 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004072 hda_nid_t nid;
4073 int i, err;
4074
4075 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004076 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004077 continue;
4078 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4079 if (i == 2) {
4080 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004081 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4082 "Center Playback Volume",
4083 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
4084 HDA_OUTPUT));
4085 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004086 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004087 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4088 "LFE Playback Volume",
4089 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
4090 HDA_OUTPUT));
4091 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004092 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004093 err = add_control(spec, ALC_CTL_BIND_MUTE,
4094 "Center Playback Switch",
4095 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
4096 HDA_INPUT));
4097 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004098 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004099 err = add_control(spec, ALC_CTL_BIND_MUTE,
4100 "LFE Playback Switch",
4101 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
4102 HDA_INPUT));
4103 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004104 return err;
4105 } else {
4106 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004107 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4108 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4109 HDA_OUTPUT));
4110 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004111 return err;
4112 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004113 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4114 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4115 HDA_INPUT));
4116 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004117 return err;
4118 }
4119 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004120 return 0;
4121}
4122
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004123/* add playback controls for speaker and HP outputs */
4124static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
4125 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004126{
4127 hda_nid_t nid;
4128 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004129 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004130
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004131 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004132 return 0;
4133
4134 if (alc880_is_fixed_pin(pin)) {
4135 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01004136 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004137 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004138 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004139 else
4140 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004141 /* control HP volume/switch on the output mixer amp */
4142 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004143 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004144 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4145 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
4146 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004147 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004148 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004149 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4150 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
4151 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004152 return err;
4153 } else if (alc880_is_multi_pin(pin)) {
4154 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004155 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004156 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004157 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4158 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
4159 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004160 return err;
4161 }
4162 return 0;
4163}
4164
4165/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004166static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4167 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01004168 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004169{
4170 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01004171 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004172
4173 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004174 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4175 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4176 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004177 return err;
4178 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004179 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4180 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4181 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004182 return err;
4183 return 0;
4184}
4185
4186/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01004187static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
4188 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004189{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004190 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004191 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004192
4193 for (i = 0; i < AUTO_PIN_LAST; i++) {
4194 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01004195 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01004196 err = new_analog_input(spec, cfg->input_pins[i],
4197 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01004198 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004199 if (err < 0)
4200 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004201 imux->items[imux->num_items].label =
4202 auto_pin_cfg_labels[i];
4203 imux->items[imux->num_items].index =
4204 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004205 imux->num_items++;
4206 }
4207 }
4208 return 0;
4209}
4210
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004211static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
4212 unsigned int pin_type)
4213{
4214 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4215 pin_type);
4216 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01004217 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4218 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004219}
4220
Kailang Yangdf694da2005-12-05 19:42:22 +01004221static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
4222 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004223 int dac_idx)
4224{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004225 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004226 /* need the manual connection? */
4227 if (alc880_is_multi_pin(nid)) {
4228 struct alc_spec *spec = codec->spec;
4229 int idx = alc880_multi_pin_idx(nid);
4230 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
4231 AC_VERB_SET_CONNECT_SEL,
4232 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
4233 }
4234}
4235
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004236static int get_pin_type(int line_out_type)
4237{
4238 if (line_out_type == AUTO_PIN_HP_OUT)
4239 return PIN_HP;
4240 else
4241 return PIN_OUT;
4242}
4243
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004244static void alc880_auto_init_multi_out(struct hda_codec *codec)
4245{
4246 struct alc_spec *spec = codec->spec;
4247 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02004248
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004249 for (i = 0; i < spec->autocfg.line_outs; i++) {
4250 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004251 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4252 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004253 }
4254}
4255
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004256static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004257{
4258 struct alc_spec *spec = codec->spec;
4259 hda_nid_t pin;
4260
Takashi Iwai82bc9552006-03-21 11:24:42 +01004261 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004262 if (pin) /* connect to front */
4263 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004264 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004265 if (pin) /* connect to front */
4266 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
4267}
4268
4269static void alc880_auto_init_analog_input(struct hda_codec *codec)
4270{
4271 struct alc_spec *spec = codec->spec;
4272 int i;
4273
4274 for (i = 0; i < AUTO_PIN_LAST; i++) {
4275 hda_nid_t nid = spec->autocfg.input_pins[i];
4276 if (alc880_is_input_pin(nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01004277 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01004278 if (nid != ALC880_PIN_CD_NID &&
4279 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004280 snd_hda_codec_write(codec, nid, 0,
4281 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004282 AMP_OUT_MUTE);
4283 }
4284 }
4285}
4286
4287/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004288/* return 1 if successful, 0 if the proper config is not found,
4289 * or a negative error code
4290 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004291static int alc880_parse_auto_config(struct hda_codec *codec)
4292{
4293 struct alc_spec *spec = codec->spec;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004294 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +01004295 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004296
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004297 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4298 alc880_ignore);
4299 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004300 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004301 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004302 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01004303
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004304 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
4305 if (err < 0)
4306 return err;
4307 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
4308 if (err < 0)
4309 return err;
4310 err = alc880_auto_create_extra_out(spec,
4311 spec->autocfg.speaker_pins[0],
4312 "Speaker");
4313 if (err < 0)
4314 return err;
4315 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
4316 "Headphone");
4317 if (err < 0)
4318 return err;
4319 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
4320 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004321 return err;
4322
4323 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4324
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004325 /* check multiple SPDIF-out (for recent codecs) */
4326 for (i = 0; i < spec->autocfg.dig_outs; i++) {
4327 hda_nid_t dig_nid;
4328 err = snd_hda_get_connections(codec,
4329 spec->autocfg.dig_out_pins[i],
4330 &dig_nid, 1);
4331 if (err < 0)
4332 continue;
4333 if (!i)
4334 spec->multiout.dig_out_nid = dig_nid;
4335 else {
4336 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
4337 spec->slave_dig_outs[i - 1] = dig_nid;
4338 if (i == ARRAY_SIZE(spec->slave_dig_outs) - 1)
4339 break;
4340 }
4341 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004342 if (spec->autocfg.dig_in_pin)
4343 spec->dig_in_nid = ALC880_DIGIN_NID;
4344
Takashi Iwai603c4012008-07-30 15:01:44 +02004345 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01004346 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004347
Takashi Iwaid88897e2008-10-31 15:01:37 +01004348 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004349
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004350 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004351 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004352
Takashi Iwai4a79ba32009-04-22 16:31:35 +02004353 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
4354
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004355 return 1;
4356}
4357
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004358/* additional initialization for auto-configuration model */
4359static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004360{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004361 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004362 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004363 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004364 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004365 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02004366 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004367}
4368
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004369static void set_capture_mixer(struct alc_spec *spec)
4370{
Takashi Iwaia23b6882009-03-23 15:21:36 +01004371 static struct snd_kcontrol_new *caps[2][3] = {
4372 { alc_capture_mixer_nosrc1,
4373 alc_capture_mixer_nosrc2,
4374 alc_capture_mixer_nosrc3 },
4375 { alc_capture_mixer1,
4376 alc_capture_mixer2,
4377 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004378 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01004379 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
4380 int mux;
4381 if (spec->input_mux && spec->input_mux->num_items > 1)
4382 mux = 1;
4383 else
4384 mux = 0;
4385 spec->cap_mixer = caps[mux][spec->num_adc_nids - 1];
4386 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004387}
4388
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004389#define set_beep_amp(spec, nid, idx, dir) \
4390 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
4391
4392/*
4393 * OK, here we have finally the patch for ALC880
4394 */
4395
Linus Torvalds1da177e2005-04-16 15:20:36 -07004396static int patch_alc880(struct hda_codec *codec)
4397{
4398 struct alc_spec *spec;
4399 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01004400 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004401
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004402 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004403 if (spec == NULL)
4404 return -ENOMEM;
4405
4406 codec->spec = spec;
4407
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004408 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
4409 alc880_models,
4410 alc880_cfg_tbl);
4411 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004412 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
4413 "trying auto-probe from BIOS...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004414 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004415 }
4416
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004417 if (board_config == ALC880_AUTO) {
4418 /* automatic parse from the BIOS config */
4419 err = alc880_parse_auto_config(codec);
4420 if (err < 0) {
4421 alc_free(codec);
4422 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004423 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004424 printk(KERN_INFO
4425 "hda_codec: Cannot set up configuration "
4426 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004427 board_config = ALC880_3ST;
4428 }
4429 }
4430
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09004431 err = snd_hda_attach_beep_device(codec, 0x1);
4432 if (err < 0) {
4433 alc_free(codec);
4434 return err;
4435 }
4436
Kailang Yangdf694da2005-12-05 19:42:22 +01004437 if (board_config != ALC880_AUTO)
4438 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004439
4440 spec->stream_name_analog = "ALC880 Analog";
4441 spec->stream_analog_playback = &alc880_pcm_analog_playback;
4442 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01004443 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004444
4445 spec->stream_name_digital = "ALC880 Digital";
4446 spec->stream_digital_playback = &alc880_pcm_digital_playback;
4447 spec->stream_digital_capture = &alc880_pcm_digital_capture;
4448
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004449 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004450 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01004451 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004452 /* get type */
4453 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004454 if (wcap != AC_WID_AUD_IN) {
4455 spec->adc_nids = alc880_adc_nids_alt;
4456 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004457 } else {
4458 spec->adc_nids = alc880_adc_nids;
4459 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004460 }
4461 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004462 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004463 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004464
Takashi Iwai2134ea42008-01-10 16:53:55 +01004465 spec->vmaster_nid = 0x0c;
4466
Linus Torvalds1da177e2005-04-16 15:20:36 -07004467 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004468 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004469 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02004470#ifdef CONFIG_SND_HDA_POWER_SAVE
4471 if (!spec->loopback.amplist)
4472 spec->loopback.amplist = alc880_loopbacks;
4473#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01004474 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004475
4476 return 0;
4477}
4478
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004479
Linus Torvalds1da177e2005-04-16 15:20:36 -07004480/*
4481 * ALC260 support
4482 */
4483
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004484static hda_nid_t alc260_dac_nids[1] = {
4485 /* front */
4486 0x02,
4487};
4488
4489static hda_nid_t alc260_adc_nids[1] = {
4490 /* ADC0 */
4491 0x04,
4492};
4493
Kailang Yangdf694da2005-12-05 19:42:22 +01004494static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004495 /* ADC1 */
4496 0x05,
4497};
4498
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004499/* NIDs used when simultaneous access to both ADCs makes sense. Note that
4500 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
4501 */
4502static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004503 /* ADC0, ADC1 */
4504 0x04, 0x05
4505};
4506
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004507#define ALC260_DIGOUT_NID 0x03
4508#define ALC260_DIGIN_NID 0x06
4509
4510static struct hda_input_mux alc260_capture_source = {
4511 .num_items = 4,
4512 .items = {
4513 { "Mic", 0x0 },
4514 { "Front Mic", 0x1 },
4515 { "Line", 0x2 },
4516 { "CD", 0x4 },
4517 },
4518};
4519
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004520/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004521 * headphone jack and the internal CD lines since these are the only pins at
4522 * which audio can appear. For flexibility, also allow the option of
4523 * recording the mixer output on the second ADC (ADC0 doesn't have a
4524 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004525 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004526static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
4527 {
4528 .num_items = 3,
4529 .items = {
4530 { "Mic/Line", 0x0 },
4531 { "CD", 0x4 },
4532 { "Headphone", 0x2 },
4533 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004534 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004535 {
4536 .num_items = 4,
4537 .items = {
4538 { "Mic/Line", 0x0 },
4539 { "CD", 0x4 },
4540 { "Headphone", 0x2 },
4541 { "Mixer", 0x5 },
4542 },
4543 },
4544
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004545};
4546
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004547/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
4548 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004549 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004550static struct hda_input_mux alc260_acer_capture_sources[2] = {
4551 {
4552 .num_items = 4,
4553 .items = {
4554 { "Mic", 0x0 },
4555 { "Line", 0x2 },
4556 { "CD", 0x4 },
4557 { "Headphone", 0x5 },
4558 },
4559 },
4560 {
4561 .num_items = 5,
4562 .items = {
4563 { "Mic", 0x0 },
4564 { "Line", 0x2 },
4565 { "CD", 0x4 },
4566 { "Headphone", 0x6 },
4567 { "Mixer", 0x5 },
4568 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004569 },
4570};
Michael Schwingencc959482009-02-22 18:58:45 +01004571
4572/* Maxdata Favorit 100XS */
4573static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
4574 {
4575 .num_items = 2,
4576 .items = {
4577 { "Line/Mic", 0x0 },
4578 { "CD", 0x4 },
4579 },
4580 },
4581 {
4582 .num_items = 3,
4583 .items = {
4584 { "Line/Mic", 0x0 },
4585 { "CD", 0x4 },
4586 { "Mixer", 0x5 },
4587 },
4588 },
4589};
4590
Linus Torvalds1da177e2005-04-16 15:20:36 -07004591/*
4592 * This is just place-holder, so there's something for alc_build_pcms to look
4593 * at when it calculates the maximum number of channels. ALC260 has no mixer
4594 * element which allows changing the channel mode, so the verb list is
4595 * never used.
4596 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004597static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004598 { 2, NULL },
4599};
4600
Kailang Yangdf694da2005-12-05 19:42:22 +01004601
4602/* Mixer combinations
4603 *
4604 * basic: base_output + input + pc_beep + capture
4605 * HP: base_output + input + capture_alt
4606 * HP_3013: hp_3013 + input + capture
4607 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004608 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01004609 */
4610
4611static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004612 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004613 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004614 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4615 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4616 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4617 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4618 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004619};
Kailang Yangdf694da2005-12-05 19:42:22 +01004620
4621static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004622 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4623 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4624 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4625 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4626 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4627 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4628 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
4629 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004630 { } /* end */
4631};
4632
Takashi Iwaibec15c32008-01-28 18:16:30 +01004633/* update HP, line and mono out pins according to the master switch */
4634static void alc260_hp_master_update(struct hda_codec *codec,
4635 hda_nid_t hp, hda_nid_t line,
4636 hda_nid_t mono)
4637{
4638 struct alc_spec *spec = codec->spec;
4639 unsigned int val = spec->master_sw ? PIN_HP : 0;
4640 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004641 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004642 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004643 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004644 val);
4645 /* mono (speaker) depending on the HP jack sense */
4646 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004647 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004648 val);
4649}
4650
4651static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
4652 struct snd_ctl_elem_value *ucontrol)
4653{
4654 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4655 struct alc_spec *spec = codec->spec;
4656 *ucontrol->value.integer.value = spec->master_sw;
4657 return 0;
4658}
4659
4660static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
4661 struct snd_ctl_elem_value *ucontrol)
4662{
4663 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4664 struct alc_spec *spec = codec->spec;
4665 int val = !!*ucontrol->value.integer.value;
4666 hda_nid_t hp, line, mono;
4667
4668 if (val == spec->master_sw)
4669 return 0;
4670 spec->master_sw = val;
4671 hp = (kcontrol->private_value >> 16) & 0xff;
4672 line = (kcontrol->private_value >> 8) & 0xff;
4673 mono = kcontrol->private_value & 0xff;
4674 alc260_hp_master_update(codec, hp, line, mono);
4675 return 1;
4676}
4677
4678static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
4679 {
4680 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4681 .name = "Master Playback Switch",
4682 .info = snd_ctl_boolean_mono_info,
4683 .get = alc260_hp_master_sw_get,
4684 .put = alc260_hp_master_sw_put,
4685 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
4686 },
4687 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4688 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
4689 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4690 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4691 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
4692 HDA_OUTPUT),
4693 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4694 { } /* end */
4695};
4696
4697static struct hda_verb alc260_hp_unsol_verbs[] = {
4698 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4699 {},
4700};
4701
4702static void alc260_hp_automute(struct hda_codec *codec)
4703{
4704 struct alc_spec *spec = codec->spec;
4705 unsigned int present;
4706
4707 present = snd_hda_codec_read(codec, 0x10, 0,
4708 AC_VERB_GET_PIN_SENSE, 0);
4709 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4710 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
4711}
4712
4713static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
4714{
4715 if ((res >> 26) == ALC880_HP_EVENT)
4716 alc260_hp_automute(codec);
4717}
4718
Kailang Yangdf694da2005-12-05 19:42:22 +01004719static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01004720 {
4721 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4722 .name = "Master Playback Switch",
4723 .info = snd_ctl_boolean_mono_info,
4724 .get = alc260_hp_master_sw_get,
4725 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004726 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01004727 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004728 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4729 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4730 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
4731 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
4732 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4733 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01004734 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4735 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02004736 { } /* end */
4737};
4738
Kailang Yang3f878302008-08-26 13:02:23 +02004739static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
4740 .ops = &snd_hda_bind_vol,
4741 .values = {
4742 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
4743 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
4744 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
4745 0
4746 },
4747};
4748
4749static struct hda_bind_ctls alc260_dc7600_bind_switch = {
4750 .ops = &snd_hda_bind_sw,
4751 .values = {
4752 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
4753 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
4754 0
4755 },
4756};
4757
4758static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
4759 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
4760 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
4761 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
4762 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4763 { } /* end */
4764};
4765
Takashi Iwaibec15c32008-01-28 18:16:30 +01004766static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
4767 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4768 {},
4769};
4770
4771static void alc260_hp_3013_automute(struct hda_codec *codec)
4772{
4773 struct alc_spec *spec = codec->spec;
4774 unsigned int present;
4775
4776 present = snd_hda_codec_read(codec, 0x15, 0,
4777 AC_VERB_GET_PIN_SENSE, 0);
4778 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004779 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01004780}
4781
4782static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
4783 unsigned int res)
4784{
4785 if ((res >> 26) == ALC880_HP_EVENT)
4786 alc260_hp_3013_automute(codec);
4787}
4788
Kailang Yang3f878302008-08-26 13:02:23 +02004789static void alc260_hp_3012_automute(struct hda_codec *codec)
4790{
4791 unsigned int present, bits;
4792
4793 present = snd_hda_codec_read(codec, 0x10, 0,
4794 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
4795
4796 bits = present ? 0 : PIN_OUT;
4797 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4798 bits);
4799 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4800 bits);
4801 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4802 bits);
4803}
4804
4805static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
4806 unsigned int res)
4807{
4808 if ((res >> 26) == ALC880_HP_EVENT)
4809 alc260_hp_3012_automute(codec);
4810}
4811
4812/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004813 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
4814 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004815static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004816 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004817 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004818 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004819 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4820 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4821 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
4822 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004823 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004824 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4825 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004826 { } /* end */
4827};
4828
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004829/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
4830 * versions of the ALC260 don't act on requests to enable mic bias from NID
4831 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
4832 * datasheet doesn't mention this restriction. At this stage it's not clear
4833 * whether this behaviour is intentional or is a hardware bug in chip
4834 * revisions available in early 2006. Therefore for now allow the
4835 * "Headphone Jack Mode" control to span all choices, but if it turns out
4836 * that the lack of mic bias for this NID is intentional we could change the
4837 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4838 *
4839 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
4840 * don't appear to make the mic bias available from the "line" jack, even
4841 * though the NID used for this jack (0x14) can supply it. The theory is
4842 * that perhaps Acer have included blocking capacitors between the ALC260
4843 * and the output jack. If this turns out to be the case for all such
4844 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
4845 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01004846 *
4847 * The C20x Tablet series have a mono internal speaker which is controlled
4848 * via the chip's Mono sum widget and pin complex, so include the necessary
4849 * controls for such models. On models without a "mono speaker" the control
4850 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004851 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004852static struct snd_kcontrol_new alc260_acer_mixer[] = {
4853 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4854 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004855 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004856 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01004857 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004858 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01004859 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004860 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4861 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4862 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4863 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4864 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4865 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4866 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4867 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004868 { } /* end */
4869};
4870
Michael Schwingencc959482009-02-22 18:58:45 +01004871/* Maxdata Favorit 100XS: one output and one input (0x12) jack
4872 */
4873static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
4874 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4875 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
4876 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
4877 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4878 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4879 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4880 { } /* end */
4881};
4882
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004883/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
4884 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
4885 */
4886static struct snd_kcontrol_new alc260_will_mixer[] = {
4887 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4888 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4889 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4890 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4891 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4892 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4893 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4894 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4895 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4896 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004897 { } /* end */
4898};
4899
4900/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
4901 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
4902 */
4903static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
4904 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4905 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4906 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4907 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4908 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4909 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
4910 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
4911 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4912 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4913 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4914 { } /* end */
4915};
4916
Kailang Yangdf694da2005-12-05 19:42:22 +01004917/*
4918 * initialization verbs
4919 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004920static struct hda_verb alc260_init_verbs[] = {
4921 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004922 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004923 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004924 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004925 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004926 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004927 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004928 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004929 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02004930 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004931 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01004932 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004933 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02004934 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004935 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02004936 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004937 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02004938 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4939 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02004940 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004941 /* set connection select to line in (default select for this ADC) */
4942 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02004943 /* mute capture amp left and right */
4944 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4945 /* set connection select to line in (default select for this ADC) */
4946 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02004947 /* set vol=0 Line-Out mixer amp left and right */
4948 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4949 /* unmute pin widget amp left and right (no gain on this amp) */
4950 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4951 /* set vol=0 HP mixer amp left and right */
4952 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4953 /* unmute pin widget amp left and right (no gain on this amp) */
4954 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4955 /* set vol=0 Mono mixer amp left and right */
4956 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4957 /* unmute pin widget amp left and right (no gain on this amp) */
4958 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4959 /* unmute LINE-2 out pin */
4960 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004961 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4962 * Line In 2 = 0x03
4963 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004964 /* mute analog inputs */
4965 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4966 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4967 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4968 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4969 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004970 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004971 /* mute Front out path */
4972 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4973 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4974 /* mute Headphone out path */
4975 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4976 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4977 /* mute Mono out path */
4978 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4979 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004980 { }
4981};
4982
Takashi Iwai474167d2006-05-17 17:17:43 +02004983#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01004984static struct hda_verb alc260_hp_init_verbs[] = {
4985 /* Headphone and output */
4986 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4987 /* mono output */
4988 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4989 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4990 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4991 /* Mic2 (front panel) pin widget for input and vref at 80% */
4992 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4993 /* Line In pin widget for input */
4994 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4995 /* Line-2 pin widget for output */
4996 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4997 /* CD pin widget for input */
4998 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4999 /* unmute amp left and right */
5000 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5001 /* set connection select to line in (default select for this ADC) */
5002 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5003 /* unmute Line-Out mixer amp left and right (volume = 0) */
5004 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5005 /* mute pin widget amp left and right (no gain on this amp) */
5006 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5007 /* unmute HP mixer amp left and right (volume = 0) */
5008 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5009 /* mute pin widget amp left and right (no gain on this amp) */
5010 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005011 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5012 * Line In 2 = 0x03
5013 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005014 /* mute analog inputs */
5015 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5016 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5017 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5018 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5019 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005020 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5021 /* Unmute Front out path */
5022 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5023 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5024 /* Unmute Headphone out path */
5025 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5026 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5027 /* Unmute Mono out path */
5028 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5029 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5030 { }
5031};
Takashi Iwai474167d2006-05-17 17:17:43 +02005032#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005033
5034static struct hda_verb alc260_hp_3013_init_verbs[] = {
5035 /* Line out and output */
5036 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5037 /* mono output */
5038 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5039 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5040 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5041 /* Mic2 (front panel) pin widget for input and vref at 80% */
5042 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5043 /* Line In pin widget for input */
5044 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5045 /* Headphone pin widget for output */
5046 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5047 /* CD pin widget for input */
5048 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5049 /* unmute amp left and right */
5050 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5051 /* set connection select to line in (default select for this ADC) */
5052 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5053 /* unmute Line-Out mixer amp left and right (volume = 0) */
5054 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5055 /* mute pin widget amp left and right (no gain on this amp) */
5056 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5057 /* unmute HP mixer amp left and right (volume = 0) */
5058 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5059 /* mute pin widget amp left and right (no gain on this amp) */
5060 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005061 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5062 * Line In 2 = 0x03
5063 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005064 /* mute analog inputs */
5065 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5066 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5067 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5068 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5069 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005070 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5071 /* Unmute Front out path */
5072 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5073 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5074 /* Unmute Headphone out path */
5075 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5076 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5077 /* Unmute Mono out path */
5078 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5079 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5080 { }
5081};
5082
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005083/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005084 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
5085 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005086 */
5087static struct hda_verb alc260_fujitsu_init_verbs[] = {
5088 /* Disable all GPIOs */
5089 {0x01, AC_VERB_SET_GPIO_MASK, 0},
5090 /* Internal speaker is connected to headphone pin */
5091 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5092 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
5093 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005094 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
5095 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5096 /* Ensure all other unused pins are disabled and muted. */
5097 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5098 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005099 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005100 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005101 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005102 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5103 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5104 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005105
Jonathan Woithef7ace402006-02-28 11:46:14 +01005106 /* Disable digital (SPDIF) pins */
5107 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5108 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005109
Kailang Yangea1fb292008-08-26 12:58:38 +02005110 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01005111 * when acting as an output.
5112 */
5113 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5114
5115 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01005116 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5117 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5118 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5119 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5120 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5121 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5122 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5123 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5124 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005125
Jonathan Woithef7ace402006-02-28 11:46:14 +01005126 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
5127 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5128 /* Unmute Line1 pin widget output buffer since it starts as an output.
5129 * If the pin mode is changed by the user the pin mode control will
5130 * take care of enabling the pin's input/output buffers as needed.
5131 * Therefore there's no need to enable the input buffer at this
5132 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005133 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005134 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02005135 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005136 * mixer ctrl)
5137 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005138 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005139
Jonathan Woithef7ace402006-02-28 11:46:14 +01005140 /* Mute capture amp left and right */
5141 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005142 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01005143 * in (on mic1 pin)
5144 */
5145 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005146
Jonathan Woithef7ace402006-02-28 11:46:14 +01005147 /* Do the same for the second ADC: mute capture input amp and
5148 * set ADC connection to line in (on mic1 pin)
5149 */
5150 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5151 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005152
Jonathan Woithef7ace402006-02-28 11:46:14 +01005153 /* Mute all inputs to mixer widget (even unconnected ones) */
5154 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5155 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5156 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5157 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5158 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5159 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5160 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5161 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005162
5163 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005164};
5165
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005166/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
5167 * similar laptops (adapted from Fujitsu init verbs).
5168 */
5169static struct hda_verb alc260_acer_init_verbs[] = {
5170 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
5171 * the headphone jack. Turn this on and rely on the standard mute
5172 * methods whenever the user wants to turn these outputs off.
5173 */
5174 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5175 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5176 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5177 /* Internal speaker/Headphone jack is connected to Line-out pin */
5178 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5179 /* Internal microphone/Mic jack is connected to Mic1 pin */
5180 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5181 /* Line In jack is connected to Line1 pin */
5182 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01005183 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
5184 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005185 /* Ensure all other unused pins are disabled and muted. */
5186 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5187 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005188 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5189 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5190 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5191 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5192 /* Disable digital (SPDIF) pins */
5193 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5194 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5195
Kailang Yangea1fb292008-08-26 12:58:38 +02005196 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005197 * bus when acting as outputs.
5198 */
5199 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5200 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5201
5202 /* Start with output sum widgets muted and their output gains at min */
5203 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5204 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5205 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5206 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5207 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5208 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5209 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5210 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5211 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5212
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005213 /* Unmute Line-out pin widget amp left and right
5214 * (no equiv mixer ctrl)
5215 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005216 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01005217 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
5218 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005219 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5220 * inputs. If the pin mode is changed by the user the pin mode control
5221 * will take care of enabling the pin's input/output buffers as needed.
5222 * Therefore there's no need to enable the input buffer at this
5223 * stage.
5224 */
5225 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5226 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5227
5228 /* Mute capture amp left and right */
5229 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5230 /* Set ADC connection select to match default mixer setting - mic
5231 * (on mic1 pin)
5232 */
5233 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5234
5235 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005236 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005237 */
5238 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005239 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005240
5241 /* Mute all inputs to mixer widget (even unconnected ones) */
5242 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5243 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5244 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5245 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5246 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5247 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5248 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5249 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5250
5251 { }
5252};
5253
Michael Schwingencc959482009-02-22 18:58:45 +01005254/* Initialisation sequence for Maxdata Favorit 100XS
5255 * (adapted from Acer init verbs).
5256 */
5257static struct hda_verb alc260_favorit100_init_verbs[] = {
5258 /* GPIO 0 enables the output jack.
5259 * Turn this on and rely on the standard mute
5260 * methods whenever the user wants to turn these outputs off.
5261 */
5262 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5263 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5264 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5265 /* Line/Mic input jack is connected to Mic1 pin */
5266 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5267 /* Ensure all other unused pins are disabled and muted. */
5268 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5269 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5270 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5271 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5272 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5273 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5274 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5275 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5276 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5277 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5278 /* Disable digital (SPDIF) pins */
5279 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5280 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5281
5282 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
5283 * bus when acting as outputs.
5284 */
5285 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5286 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5287
5288 /* Start with output sum widgets muted and their output gains at min */
5289 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5290 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5291 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5292 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5293 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5294 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5295 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5296 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5297 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5298
5299 /* Unmute Line-out pin widget amp left and right
5300 * (no equiv mixer ctrl)
5301 */
5302 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5303 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5304 * inputs. If the pin mode is changed by the user the pin mode control
5305 * will take care of enabling the pin's input/output buffers as needed.
5306 * Therefore there's no need to enable the input buffer at this
5307 * stage.
5308 */
5309 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5310
5311 /* Mute capture amp left and right */
5312 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5313 /* Set ADC connection select to match default mixer setting - mic
5314 * (on mic1 pin)
5315 */
5316 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5317
5318 /* Do similar with the second ADC: mute capture input amp and
5319 * set ADC connection to mic to match ALSA's default state.
5320 */
5321 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5322 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5323
5324 /* Mute all inputs to mixer widget (even unconnected ones) */
5325 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5326 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5327 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5328 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5329 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5330 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5331 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5332 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5333
5334 { }
5335};
5336
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005337static struct hda_verb alc260_will_verbs[] = {
5338 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5339 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
5340 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
5341 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5342 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5343 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
5344 {}
5345};
5346
5347static struct hda_verb alc260_replacer_672v_verbs[] = {
5348 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5349 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5350 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
5351
5352 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5353 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5354 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5355
5356 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5357 {}
5358};
5359
5360/* toggle speaker-output according to the hp-jack state */
5361static void alc260_replacer_672v_automute(struct hda_codec *codec)
5362{
5363 unsigned int present;
5364
5365 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
5366 present = snd_hda_codec_read(codec, 0x0f, 0,
5367 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5368 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005369 snd_hda_codec_write_cache(codec, 0x01, 0,
5370 AC_VERB_SET_GPIO_DATA, 1);
5371 snd_hda_codec_write_cache(codec, 0x0f, 0,
5372 AC_VERB_SET_PIN_WIDGET_CONTROL,
5373 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005374 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005375 snd_hda_codec_write_cache(codec, 0x01, 0,
5376 AC_VERB_SET_GPIO_DATA, 0);
5377 snd_hda_codec_write_cache(codec, 0x0f, 0,
5378 AC_VERB_SET_PIN_WIDGET_CONTROL,
5379 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005380 }
5381}
5382
5383static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
5384 unsigned int res)
5385{
5386 if ((res >> 26) == ALC880_HP_EVENT)
5387 alc260_replacer_672v_automute(codec);
5388}
5389
Kailang Yang3f878302008-08-26 13:02:23 +02005390static struct hda_verb alc260_hp_dc7600_verbs[] = {
5391 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
5392 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5393 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5394 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5395 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5396 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5397 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5398 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5399 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5400 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5401 {}
5402};
5403
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005404/* Test configuration for debugging, modelled after the ALC880 test
5405 * configuration.
5406 */
5407#ifdef CONFIG_SND_DEBUG
5408static hda_nid_t alc260_test_dac_nids[1] = {
5409 0x02,
5410};
5411static hda_nid_t alc260_test_adc_nids[2] = {
5412 0x04, 0x05,
5413};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005414/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02005415 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005416 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005417 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005418static struct hda_input_mux alc260_test_capture_sources[2] = {
5419 {
5420 .num_items = 7,
5421 .items = {
5422 { "MIC1 pin", 0x0 },
5423 { "MIC2 pin", 0x1 },
5424 { "LINE1 pin", 0x2 },
5425 { "LINE2 pin", 0x3 },
5426 { "CD pin", 0x4 },
5427 { "LINE-OUT pin", 0x5 },
5428 { "HP-OUT pin", 0x6 },
5429 },
5430 },
5431 {
5432 .num_items = 8,
5433 .items = {
5434 { "MIC1 pin", 0x0 },
5435 { "MIC2 pin", 0x1 },
5436 { "LINE1 pin", 0x2 },
5437 { "LINE2 pin", 0x3 },
5438 { "CD pin", 0x4 },
5439 { "Mixer", 0x5 },
5440 { "LINE-OUT pin", 0x6 },
5441 { "HP-OUT pin", 0x7 },
5442 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005443 },
5444};
5445static struct snd_kcontrol_new alc260_test_mixer[] = {
5446 /* Output driver widgets */
5447 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5448 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5449 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5450 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
5451 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5452 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
5453
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005454 /* Modes for retasking pin widgets
5455 * Note: the ALC260 doesn't seem to act on requests to enable mic
5456 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
5457 * mention this restriction. At this stage it's not clear whether
5458 * this behaviour is intentional or is a hardware bug in chip
5459 * revisions available at least up until early 2006. Therefore for
5460 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
5461 * choices, but if it turns out that the lack of mic bias for these
5462 * NIDs is intentional we could change their modes from
5463 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5464 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005465 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
5466 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
5467 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
5468 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
5469 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
5470 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
5471
5472 /* Loopback mixer controls */
5473 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
5474 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
5475 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
5476 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
5477 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
5478 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
5479 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
5480 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
5481 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5482 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005483 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
5484 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
5485 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
5486 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005487
5488 /* Controls for GPIO pins, assuming they are configured as outputs */
5489 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
5490 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
5491 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
5492 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
5493
Jonathan Woithe92621f12006-02-28 11:47:47 +01005494 /* Switches to allow the digital IO pins to be enabled. The datasheet
5495 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02005496 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01005497 */
5498 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
5499 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
5500
Jonathan Woithef8225f62008-01-08 12:16:54 +01005501 /* A switch allowing EAPD to be enabled. Some laptops seem to use
5502 * this output to turn on an external amplifier.
5503 */
5504 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
5505 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
5506
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005507 { } /* end */
5508};
5509static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005510 /* Enable all GPIOs as outputs with an initial value of 0 */
5511 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
5512 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5513 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
5514
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005515 /* Enable retasking pins as output, initially without power amp */
5516 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5517 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5518 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5519 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5520 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5521 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5522
Jonathan Woithe92621f12006-02-28 11:47:47 +01005523 /* Disable digital (SPDIF) pins initially, but users can enable
5524 * them via a mixer switch. In the case of SPDIF-out, this initverb
5525 * payload also sets the generation to 0, output to be in "consumer"
5526 * PCM format, copyright asserted, no pre-emphasis and no validity
5527 * control.
5528 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005529 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5530 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5531
Kailang Yangea1fb292008-08-26 12:58:38 +02005532 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005533 * OUT1 sum bus when acting as an output.
5534 */
5535 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5536 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
5537 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5538 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
5539
5540 /* Start with output sum widgets muted and their output gains at min */
5541 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5542 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5543 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5544 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5545 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5546 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5547 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5548 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5549 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5550
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005551 /* Unmute retasking pin widget output buffers since the default
5552 * state appears to be output. As the pin mode is changed by the
5553 * user the pin mode control will take care of enabling the pin's
5554 * input/output buffers as needed.
5555 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005556 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5557 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5558 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5559 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5560 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5561 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5562 /* Also unmute the mono-out pin widget */
5563 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5564
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005565 /* Mute capture amp left and right */
5566 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005567 /* Set ADC connection select to match default mixer setting (mic1
5568 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005569 */
5570 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5571
5572 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01005573 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005574 */
5575 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5576 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5577
5578 /* Mute all inputs to mixer widget (even unconnected ones) */
5579 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5580 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5581 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5582 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5583 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5584 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5585 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5586 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5587
5588 { }
5589};
5590#endif
5591
Takashi Iwai63300792008-01-24 15:31:36 +01005592#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
5593#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07005594
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005595#define alc260_pcm_digital_playback alc880_pcm_digital_playback
5596#define alc260_pcm_digital_capture alc880_pcm_digital_capture
5597
Kailang Yangdf694da2005-12-05 19:42:22 +01005598/*
5599 * for BIOS auto-configuration
5600 */
5601
5602static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02005603 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01005604{
5605 hda_nid_t nid_vol;
5606 unsigned long vol_val, sw_val;
5607 char name[32];
5608 int err;
5609
5610 if (nid >= 0x0f && nid < 0x11) {
5611 nid_vol = nid - 0x7;
5612 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5613 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5614 } else if (nid == 0x11) {
5615 nid_vol = nid - 0x7;
5616 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
5617 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
5618 } else if (nid >= 0x12 && nid <= 0x15) {
5619 nid_vol = 0x08;
5620 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5621 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5622 } else
5623 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02005624
Takashi Iwai863b4512008-10-21 17:01:47 +02005625 if (!(*vol_bits & (1 << nid_vol))) {
5626 /* first control for the volume widget */
5627 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
5628 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
5629 if (err < 0)
5630 return err;
5631 *vol_bits |= (1 << nid_vol);
5632 }
Kailang Yangdf694da2005-12-05 19:42:22 +01005633 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005634 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
5635 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005636 return err;
5637 return 1;
5638}
5639
5640/* add playback controls from the parsed DAC table */
5641static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
5642 const struct auto_pin_cfg *cfg)
5643{
5644 hda_nid_t nid;
5645 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02005646 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005647
5648 spec->multiout.num_dacs = 1;
5649 spec->multiout.dac_nids = spec->private_dac_nids;
5650 spec->multiout.dac_nids[0] = 0x02;
5651
5652 nid = cfg->line_out_pins[0];
5653 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005654 err = alc260_add_playback_controls(spec, nid, "Front", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005655 if (err < 0)
5656 return err;
5657 }
5658
Takashi Iwai82bc9552006-03-21 11:24:42 +01005659 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005660 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005661 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005662 if (err < 0)
5663 return err;
5664 }
5665
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005666 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005667 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005668 err = alc260_add_playback_controls(spec, nid, "Headphone",
5669 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005670 if (err < 0)
5671 return err;
5672 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005673 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005674}
5675
5676/* create playback/capture controls for input pins */
5677static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
5678 const struct auto_pin_cfg *cfg)
5679{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005680 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005681 int i, err, idx;
5682
5683 for (i = 0; i < AUTO_PIN_LAST; i++) {
5684 if (cfg->input_pins[i] >= 0x12) {
5685 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005686 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005687 auto_pin_cfg_labels[i], idx,
5688 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005689 if (err < 0)
5690 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005691 imux->items[imux->num_items].label =
5692 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005693 imux->items[imux->num_items].index = idx;
5694 imux->num_items++;
5695 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005696 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01005697 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005698 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005699 auto_pin_cfg_labels[i], idx,
5700 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005701 if (err < 0)
5702 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005703 imux->items[imux->num_items].label =
5704 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005705 imux->items[imux->num_items].index = idx;
5706 imux->num_items++;
5707 }
5708 }
5709 return 0;
5710}
5711
5712static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
5713 hda_nid_t nid, int pin_type,
5714 int sel_idx)
5715{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005716 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01005717 /* need the manual connection? */
5718 if (nid >= 0x12) {
5719 int idx = nid - 0x12;
5720 snd_hda_codec_write(codec, idx + 0x0b, 0,
5721 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01005722 }
5723}
5724
5725static void alc260_auto_init_multi_out(struct hda_codec *codec)
5726{
5727 struct alc_spec *spec = codec->spec;
5728 hda_nid_t nid;
5729
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005730 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005731 if (nid) {
5732 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5733 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
5734 }
Kailang Yangea1fb292008-08-26 12:58:38 +02005735
Takashi Iwai82bc9552006-03-21 11:24:42 +01005736 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005737 if (nid)
5738 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
5739
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005740 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005741 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005742 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005743}
Kailang Yangdf694da2005-12-05 19:42:22 +01005744
5745#define ALC260_PIN_CD_NID 0x16
5746static void alc260_auto_init_analog_input(struct hda_codec *codec)
5747{
5748 struct alc_spec *spec = codec->spec;
5749 int i;
5750
5751 for (i = 0; i < AUTO_PIN_LAST; i++) {
5752 hda_nid_t nid = spec->autocfg.input_pins[i];
5753 if (nid >= 0x12) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01005754 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01005755 if (nid != ALC260_PIN_CD_NID &&
5756 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005757 snd_hda_codec_write(codec, nid, 0,
5758 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01005759 AMP_OUT_MUTE);
5760 }
5761 }
5762}
5763
5764/*
5765 * generic initialization of ADC, input mixers and output mixers
5766 */
5767static struct hda_verb alc260_volume_init_verbs[] = {
5768 /*
5769 * Unmute ADC0-1 and set the default input to mic-in
5770 */
5771 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5772 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5773 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5774 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005775
Kailang Yangdf694da2005-12-05 19:42:22 +01005776 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5777 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005778 * Note: PASD motherboards uses the Line In 2 as the input for
5779 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01005780 */
5781 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005782 /* mute analog inputs */
5783 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5784 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5785 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5786 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5787 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005788
5789 /*
5790 * Set up output mixers (0x08 - 0x0a)
5791 */
5792 /* set vol=0 to output mixers */
5793 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5794 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5795 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5796 /* set up input amps for analog loopback */
5797 /* Amp Indices: DAC = 0, mixer = 1 */
5798 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5799 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5800 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5801 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5802 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5803 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005804
Kailang Yangdf694da2005-12-05 19:42:22 +01005805 { }
5806};
5807
5808static int alc260_parse_auto_config(struct hda_codec *codec)
5809{
5810 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005811 int err;
5812 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
5813
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005814 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5815 alc260_ignore);
5816 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005817 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005818 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
5819 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01005820 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02005821 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01005822 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005823 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
5824 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005825 return err;
5826
5827 spec->multiout.max_channels = 2;
5828
Takashi Iwai0852d7a2009-02-11 11:35:15 +01005829 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01005830 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02005831 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01005832 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01005833
Takashi Iwaid88897e2008-10-31 15:01:37 +01005834 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01005835
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005836 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005837 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005838
Takashi Iwai4a79ba32009-04-22 16:31:35 +02005839 alc_ssid_check(codec, 0x10, 0x15, 0x0f);
5840
Kailang Yangdf694da2005-12-05 19:42:22 +01005841 return 1;
5842}
5843
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005844/* additional initialization for auto-configuration model */
5845static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01005846{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005847 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005848 alc260_auto_init_multi_out(codec);
5849 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005850 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02005851 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005852}
5853
Takashi Iwaicb53c622007-08-10 17:21:45 +02005854#ifdef CONFIG_SND_HDA_POWER_SAVE
5855static struct hda_amp_list alc260_loopbacks[] = {
5856 { 0x07, HDA_INPUT, 0 },
5857 { 0x07, HDA_INPUT, 1 },
5858 { 0x07, HDA_INPUT, 2 },
5859 { 0x07, HDA_INPUT, 3 },
5860 { 0x07, HDA_INPUT, 4 },
5861 { } /* end */
5862};
5863#endif
5864
Kailang Yangdf694da2005-12-05 19:42:22 +01005865/*
5866 * ALC260 configurations
5867 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005868static const char *alc260_models[ALC260_MODEL_LAST] = {
5869 [ALC260_BASIC] = "basic",
5870 [ALC260_HP] = "hp",
5871 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02005872 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005873 [ALC260_FUJITSU_S702X] = "fujitsu",
5874 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005875 [ALC260_WILL] = "will",
5876 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01005877 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005878#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005879 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005880#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005881 [ALC260_AUTO] = "auto",
5882};
5883
5884static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01005885 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005886 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01005887 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01005888 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01005889 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005890 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02005891 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02005892 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005893 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
5894 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
5895 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
5896 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
5897 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
5898 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
5899 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
5900 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
5901 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005902 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01005903 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02005904 {}
5905};
5906
Kailang Yangdf694da2005-12-05 19:42:22 +01005907static struct alc_config_preset alc260_presets[] = {
5908 [ALC260_BASIC] = {
5909 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005910 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01005911 .init_verbs = { alc260_init_verbs },
5912 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5913 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005914 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Kailang Yangdf694da2005-12-05 19:42:22 +01005915 .adc_nids = alc260_adc_nids,
5916 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5917 .channel_mode = alc260_modes,
5918 .input_mux = &alc260_capture_source,
5919 },
5920 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005921 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005922 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005923 .init_verbs = { alc260_init_verbs,
5924 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005925 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5926 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005927 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5928 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01005929 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5930 .channel_mode = alc260_modes,
5931 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005932 .unsol_event = alc260_hp_unsol_event,
5933 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005934 },
Kailang Yang3f878302008-08-26 13:02:23 +02005935 [ALC260_HP_DC7600] = {
5936 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005937 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02005938 .init_verbs = { alc260_init_verbs,
5939 alc260_hp_dc7600_verbs },
5940 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5941 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005942 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5943 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02005944 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5945 .channel_mode = alc260_modes,
5946 .input_mux = &alc260_capture_source,
5947 .unsol_event = alc260_hp_3012_unsol_event,
5948 .init_hook = alc260_hp_3012_automute,
5949 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005950 [ALC260_HP_3013] = {
5951 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005952 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005953 .init_verbs = { alc260_hp_3013_init_verbs,
5954 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005955 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5956 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005957 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5958 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01005959 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5960 .channel_mode = alc260_modes,
5961 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005962 .unsol_event = alc260_hp_3013_unsol_event,
5963 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005964 },
5965 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005966 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01005967 .init_verbs = { alc260_fujitsu_init_verbs },
5968 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5969 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005970 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5971 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01005972 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5973 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005974 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
5975 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01005976 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005977 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005978 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005979 .init_verbs = { alc260_acer_init_verbs },
5980 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5981 .dac_nids = alc260_dac_nids,
5982 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5983 .adc_nids = alc260_dual_adc_nids,
5984 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5985 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005986 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
5987 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005988 },
Michael Schwingencc959482009-02-22 18:58:45 +01005989 [ALC260_FAVORIT100] = {
5990 .mixers = { alc260_favorit100_mixer },
5991 .init_verbs = { alc260_favorit100_init_verbs },
5992 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5993 .dac_nids = alc260_dac_nids,
5994 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5995 .adc_nids = alc260_dual_adc_nids,
5996 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5997 .channel_mode = alc260_modes,
5998 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
5999 .input_mux = alc260_favorit100_capture_sources,
6000 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006001 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006002 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006003 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
6004 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6005 .dac_nids = alc260_dac_nids,
6006 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6007 .adc_nids = alc260_adc_nids,
6008 .dig_out_nid = ALC260_DIGOUT_NID,
6009 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6010 .channel_mode = alc260_modes,
6011 .input_mux = &alc260_capture_source,
6012 },
6013 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006014 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006015 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
6016 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6017 .dac_nids = alc260_dac_nids,
6018 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6019 .adc_nids = alc260_adc_nids,
6020 .dig_out_nid = ALC260_DIGOUT_NID,
6021 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6022 .channel_mode = alc260_modes,
6023 .input_mux = &alc260_capture_source,
6024 .unsol_event = alc260_replacer_672v_unsol_event,
6025 .init_hook = alc260_replacer_672v_automute,
6026 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006027#ifdef CONFIG_SND_DEBUG
6028 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006029 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006030 .init_verbs = { alc260_test_init_verbs },
6031 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
6032 .dac_nids = alc260_test_dac_nids,
6033 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
6034 .adc_nids = alc260_test_adc_nids,
6035 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6036 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006037 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
6038 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006039 },
6040#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006041};
6042
Linus Torvalds1da177e2005-04-16 15:20:36 -07006043static int patch_alc260(struct hda_codec *codec)
6044{
6045 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006046 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006047
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006048 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006049 if (spec == NULL)
6050 return -ENOMEM;
6051
6052 codec->spec = spec;
6053
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006054 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
6055 alc260_models,
6056 alc260_cfg_tbl);
6057 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006058 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
6059 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006060 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02006061 }
6062
Kailang Yangdf694da2005-12-05 19:42:22 +01006063 if (board_config == ALC260_AUTO) {
6064 /* automatic parse from the BIOS config */
6065 err = alc260_parse_auto_config(codec);
6066 if (err < 0) {
6067 alc_free(codec);
6068 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006069 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006070 printk(KERN_INFO
6071 "hda_codec: Cannot set up configuration "
6072 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006073 board_config = ALC260_BASIC;
6074 }
Takashi Iwai16ded522005-06-10 19:58:24 +02006075 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006076
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09006077 err = snd_hda_attach_beep_device(codec, 0x1);
6078 if (err < 0) {
6079 alc_free(codec);
6080 return err;
6081 }
6082
Kailang Yangdf694da2005-12-05 19:42:22 +01006083 if (board_config != ALC260_AUTO)
6084 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006085
6086 spec->stream_name_analog = "ALC260 Analog";
6087 spec->stream_analog_playback = &alc260_pcm_analog_playback;
6088 spec->stream_analog_capture = &alc260_pcm_analog_capture;
6089
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006090 spec->stream_name_digital = "ALC260 Digital";
6091 spec->stream_digital_playback = &alc260_pcm_digital_playback;
6092 spec->stream_digital_capture = &alc260_pcm_digital_capture;
6093
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006094 if (!spec->adc_nids && spec->input_mux) {
6095 /* check whether NID 0x04 is valid */
6096 unsigned int wcap = get_wcaps(codec, 0x04);
6097 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
6098 /* get type */
6099 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
6100 spec->adc_nids = alc260_adc_nids_alt;
6101 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
6102 } else {
6103 spec->adc_nids = alc260_adc_nids;
6104 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
6105 }
6106 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006107 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006108 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006109
Takashi Iwai2134ea42008-01-10 16:53:55 +01006110 spec->vmaster_nid = 0x08;
6111
Linus Torvalds1da177e2005-04-16 15:20:36 -07006112 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006113 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006114 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006115#ifdef CONFIG_SND_HDA_POWER_SAVE
6116 if (!spec->loopback.amplist)
6117 spec->loopback.amplist = alc260_loopbacks;
6118#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01006119 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006120
6121 return 0;
6122}
6123
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006124
Linus Torvalds1da177e2005-04-16 15:20:36 -07006125/*
6126 * ALC882 support
6127 *
6128 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
6129 * configuration. Each pin widget can choose any input DACs and a mixer.
6130 * Each ADC is connected from a mixer of all inputs. This makes possible
6131 * 6-channel independent captures.
6132 *
6133 * In addition, an independent DAC for the multi-playback (not used in this
6134 * driver yet).
6135 */
Kailang Yangdf694da2005-12-05 19:42:22 +01006136#define ALC882_DIGOUT_NID 0x06
6137#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07006138
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01006139static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07006140 { 8, NULL }
6141};
6142
6143static hda_nid_t alc882_dac_nids[4] = {
6144 /* front, rear, clfe, rear_surr */
6145 0x02, 0x03, 0x04, 0x05
6146};
6147
Kailang Yangdf694da2005-12-05 19:42:22 +01006148/* identical with ALC880 */
6149#define alc882_adc_nids alc880_adc_nids
6150#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07006151
Takashi Iwaie1406342008-02-11 18:32:32 +01006152static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
6153static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
6154
Linus Torvalds1da177e2005-04-16 15:20:36 -07006155/* input MUX */
6156/* FIXME: should be a matrix-type input source selection */
6157
6158static struct hda_input_mux alc882_capture_source = {
6159 .num_items = 4,
6160 .items = {
6161 { "Mic", 0x0 },
6162 { "Front Mic", 0x1 },
6163 { "Line", 0x2 },
6164 { "CD", 0x4 },
6165 },
6166};
Kailang Yangdf694da2005-12-05 19:42:22 +01006167/*
Kailang Yang272a5272007-05-14 11:00:38 +02006168 * 2ch mode
6169 */
6170static struct hda_verb alc882_3ST_ch2_init[] = {
6171 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6172 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6173 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6174 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6175 { } /* end */
6176};
6177
6178/*
6179 * 6ch mode
6180 */
6181static struct hda_verb alc882_3ST_ch6_init[] = {
6182 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6183 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6184 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6185 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6186 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6187 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6188 { } /* end */
6189};
6190
6191static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
6192 { 2, alc882_3ST_ch2_init },
6193 { 6, alc882_3ST_ch6_init },
6194};
6195
6196/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006197 * 6ch mode
6198 */
6199static struct hda_verb alc882_sixstack_ch6_init[] = {
6200 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6201 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6202 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6203 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6204 { } /* end */
6205};
6206
6207/*
6208 * 8ch mode
6209 */
6210static struct hda_verb alc882_sixstack_ch8_init[] = {
6211 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6212 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6213 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6214 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6215 { } /* end */
6216};
6217
6218static struct hda_channel_mode alc882_sixstack_modes[2] = {
6219 { 6, alc882_sixstack_ch6_init },
6220 { 8, alc882_sixstack_ch8_init },
6221};
6222
Takashi Iwai87350ad2007-08-16 18:19:38 +02006223/*
6224 * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
6225 */
6226
6227/*
6228 * 2ch mode
6229 */
6230static struct hda_verb alc885_mbp_ch2_init[] = {
6231 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6232 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6233 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6234 { } /* end */
6235};
6236
6237/*
6238 * 6ch mode
6239 */
6240static struct hda_verb alc885_mbp_ch6_init[] = {
6241 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6242 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6243 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6244 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6245 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6246 { } /* end */
6247};
6248
6249static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
6250 { 2, alc885_mbp_ch2_init },
6251 { 6, alc885_mbp_ch6_init },
6252};
6253
6254
Linus Torvalds1da177e2005-04-16 15:20:36 -07006255/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6256 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6257 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01006258static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02006259 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006260 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006261 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006262 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006263 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6264 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006265 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6266 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006267 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006268 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006269 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6270 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6271 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6272 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6273 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6274 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006275 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006276 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6277 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006278 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006279 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006280 { } /* end */
6281};
6282
Takashi Iwai87350ad2007-08-16 18:19:38 +02006283static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01006284 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6285 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
6286 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
6287 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
6288 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6289 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006290 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
6291 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01006292 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006293 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
6294 { } /* end */
6295};
Kailang Yangbdd148a2007-05-08 15:19:08 +02006296static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
6297 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6298 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6299 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6300 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6301 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6302 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6303 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6304 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6305 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02006306 { } /* end */
6307};
6308
Kailang Yang272a5272007-05-14 11:00:38 +02006309static struct snd_kcontrol_new alc882_targa_mixer[] = {
6310 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6311 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6312 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6313 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6314 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6315 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6316 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6317 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6318 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006319 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006320 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6321 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006322 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006323 { } /* end */
6324};
6325
6326/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
6327 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
6328 */
6329static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
6330 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6331 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6332 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6333 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
6334 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6335 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6336 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6337 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6338 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
6339 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
6340 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6341 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006342 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006343 { } /* end */
6344};
6345
Takashi Iwai914759b2007-09-06 14:52:04 +02006346static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
6347 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6348 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6349 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6350 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6351 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6352 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6353 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6354 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6355 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6356 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02006357 { } /* end */
6358};
6359
Kailang Yangdf694da2005-12-05 19:42:22 +01006360static struct snd_kcontrol_new alc882_chmode_mixer[] = {
6361 {
6362 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6363 .name = "Channel Mode",
6364 .info = alc_ch_mode_info,
6365 .get = alc_ch_mode_get,
6366 .put = alc_ch_mode_put,
6367 },
6368 { } /* end */
6369};
6370
Linus Torvalds1da177e2005-04-16 15:20:36 -07006371static struct hda_verb alc882_init_verbs[] = {
6372 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006373 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6374 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6375 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006376 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006377 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6378 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6379 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006380 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006381 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6382 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6383 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006384 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006385 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6386 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6387 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006388
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006389 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006390 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006391 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006392 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006393 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006394 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006395 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006396 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006397 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006398 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006399 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006400 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006401 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006402 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006403 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006404 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006405 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006406 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006407 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6408 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006409 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006410 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6411 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006412 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006413 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6414 /* Line-2 In: Headphone output (output 0 - 0x0c) */
6415 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6416 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6417 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006418 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006419 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006420
6421 /* FIXME: use matrix-type input source selection */
6422 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6423 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02006424 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6425 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6426 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6427 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006428 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006429 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6430 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6431 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6432 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006433 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006434 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6435 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6436 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6437 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6438 /* ADC1: mute amp left and right */
6439 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006440 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02006441 /* ADC2: mute amp left and right */
6442 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006443 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02006444 /* ADC3: mute amp left and right */
6445 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006446 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006447
6448 { }
6449};
6450
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006451static struct hda_verb alc882_eapd_verbs[] = {
6452 /* change to EAPD mode */
6453 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006454 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006455 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006456};
6457
Tobin Davis9102cd12006-12-15 10:02:12 +01006458/* Mac Pro test */
6459static struct snd_kcontrol_new alc882_macpro_mixer[] = {
6460 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6461 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6462 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
6463 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
6464 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006465 /* FIXME: this looks suspicious...
Tobin Davis9102cd12006-12-15 10:02:12 +01006466 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
6467 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006468 */
Tobin Davis9102cd12006-12-15 10:02:12 +01006469 { } /* end */
6470};
6471
6472static struct hda_verb alc882_macpro_init_verbs[] = {
6473 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6474 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6475 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6476 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6477 /* Front Pin: output 0 (0x0c) */
6478 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6479 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6480 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6481 /* Front Mic pin: input vref at 80% */
6482 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6483 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6484 /* Speaker: output */
6485 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6486 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6487 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
6488 /* Headphone output (output 0 - 0x0c) */
6489 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6490 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6491 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6492
6493 /* FIXME: use matrix-type input source selection */
6494 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6495 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6496 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6497 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6498 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6499 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6500 /* Input mixer2 */
6501 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6502 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6503 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6504 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6505 /* Input mixer3 */
6506 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6507 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6508 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6509 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6510 /* ADC1: mute amp left and right */
6511 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6512 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6513 /* ADC2: mute amp left and right */
6514 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6515 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6516 /* ADC3: mute amp left and right */
6517 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6518 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6519
6520 { }
6521};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006522
Takashi Iwai87350ad2007-08-16 18:19:38 +02006523/* Macbook Pro rev3 */
6524static struct hda_verb alc885_mbp3_init_verbs[] = {
6525 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6526 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6527 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6528 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6529 /* Rear mixer */
6530 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6531 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6532 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6533 /* Front Pin: output 0 (0x0c) */
6534 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6535 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6536 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6537 /* HP Pin: output 0 (0x0d) */
6538 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
6539 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6540 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6541 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6542 /* Mic (rear) pin: input vref at 80% */
6543 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6544 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6545 /* Front Mic pin: input vref at 80% */
6546 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6547 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6548 /* Line In pin: use output 1 when in LineOut mode */
6549 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6550 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6551 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
6552
6553 /* FIXME: use matrix-type input source selection */
6554 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6555 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6556 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6557 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6558 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6559 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6560 /* Input mixer2 */
6561 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6562 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6563 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6564 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6565 /* Input mixer3 */
6566 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6567 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6568 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6569 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6570 /* ADC1: mute amp left and right */
6571 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6572 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6573 /* ADC2: mute amp left and right */
6574 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6575 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6576 /* ADC3: mute amp left and right */
6577 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6578 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6579
6580 { }
6581};
6582
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006583/* iMac 24 mixer. */
6584static struct snd_kcontrol_new alc885_imac24_mixer[] = {
6585 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6586 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
6587 { } /* end */
6588};
6589
6590/* iMac 24 init verbs. */
6591static struct hda_verb alc885_imac24_init_verbs[] = {
6592 /* Internal speakers: output 0 (0x0c) */
6593 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6594 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6595 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6596 /* Internal speakers: output 0 (0x0c) */
6597 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6598 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6599 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
6600 /* Headphone: output 0 (0x0c) */
6601 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6602 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6603 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6604 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6605 /* Front Mic: input vref at 80% */
6606 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6607 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6608 { }
6609};
6610
6611/* Toggle speaker-output according to the hp-jack state */
6612static void alc885_imac24_automute(struct hda_codec *codec)
6613{
6614 unsigned int present;
6615
6616 present = snd_hda_codec_read(codec, 0x14, 0,
6617 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02006618 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
6619 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6620 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
6621 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006622}
6623
6624/* Processes unsolicited events. */
6625static void alc885_imac24_unsol_event(struct hda_codec *codec,
6626 unsigned int res)
6627{
6628 /* Headphone insertion or removal. */
6629 if ((res >> 26) == ALC880_HP_EVENT)
6630 alc885_imac24_automute(codec);
6631}
6632
Takashi Iwai87350ad2007-08-16 18:19:38 +02006633static void alc885_mbp3_automute(struct hda_codec *codec)
6634{
6635 unsigned int present;
6636
6637 present = snd_hda_codec_read(codec, 0x15, 0,
6638 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6639 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
6640 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6641 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6642 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
6643
6644}
6645static void alc885_mbp3_unsol_event(struct hda_codec *codec,
6646 unsigned int res)
6647{
6648 /* Headphone insertion or removal. */
6649 if ((res >> 26) == ALC880_HP_EVENT)
6650 alc885_mbp3_automute(codec);
6651}
6652
6653
Kailang Yang272a5272007-05-14 11:00:38 +02006654static struct hda_verb alc882_targa_verbs[] = {
6655 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6656 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6657
6658 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6659 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006660
Kailang Yang272a5272007-05-14 11:00:38 +02006661 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6662 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6663 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6664
6665 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6666 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
6667 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
6668 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
6669 { } /* end */
6670};
6671
6672/* toggle speaker-output according to the hp-jack state */
6673static void alc882_targa_automute(struct hda_codec *codec)
6674{
6675 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02006676
Kailang Yang272a5272007-05-14 11:00:38 +02006677 present = snd_hda_codec_read(codec, 0x14, 0,
6678 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02006679 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
6680 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006681 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
6682 present ? 1 : 3);
Kailang Yang272a5272007-05-14 11:00:38 +02006683}
6684
6685static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
6686{
6687 /* Looks like the unsol event is incompatible with the standard
6688 * definition. 4bit tag is placed at 26 bit!
6689 */
6690 if (((res >> 26) == ALC880_HP_EVENT)) {
6691 alc882_targa_automute(codec);
6692 }
6693}
6694
6695static struct hda_verb alc882_asus_a7j_verbs[] = {
6696 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6697 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6698
6699 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6700 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6701 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006702
Kailang Yang272a5272007-05-14 11:00:38 +02006703 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6704 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6705 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6706
6707 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6708 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6709 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6710 { } /* end */
6711};
6712
Takashi Iwai914759b2007-09-06 14:52:04 +02006713static struct hda_verb alc882_asus_a7m_verbs[] = {
6714 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6715 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6716
6717 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6718 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6719 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006720
Takashi Iwai914759b2007-09-06 14:52:04 +02006721 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6722 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6723 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6724
6725 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6726 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6727 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6728 { } /* end */
6729};
6730
Tobin Davis9102cd12006-12-15 10:02:12 +01006731static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
6732{
6733 unsigned int gpiostate, gpiomask, gpiodir;
6734
6735 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
6736 AC_VERB_GET_GPIO_DATA, 0);
6737
6738 if (!muted)
6739 gpiostate |= (1 << pin);
6740 else
6741 gpiostate &= ~(1 << pin);
6742
6743 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
6744 AC_VERB_GET_GPIO_MASK, 0);
6745 gpiomask |= (1 << pin);
6746
6747 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
6748 AC_VERB_GET_GPIO_DIRECTION, 0);
6749 gpiodir |= (1 << pin);
6750
6751
6752 snd_hda_codec_write(codec, codec->afg, 0,
6753 AC_VERB_SET_GPIO_MASK, gpiomask);
6754 snd_hda_codec_write(codec, codec->afg, 0,
6755 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
6756
6757 msleep(1);
6758
6759 snd_hda_codec_write(codec, codec->afg, 0,
6760 AC_VERB_SET_GPIO_DATA, gpiostate);
6761}
6762
Takashi Iwai7debbe52007-08-16 15:01:03 +02006763/* set up GPIO at initialization */
6764static void alc885_macpro_init_hook(struct hda_codec *codec)
6765{
6766 alc882_gpio_mute(codec, 0, 0);
6767 alc882_gpio_mute(codec, 1, 0);
6768}
6769
6770/* set up GPIO and update auto-muting at initialization */
6771static void alc885_imac24_init_hook(struct hda_codec *codec)
6772{
6773 alc885_macpro_init_hook(codec);
6774 alc885_imac24_automute(codec);
6775}
6776
Kailang Yangdf694da2005-12-05 19:42:22 +01006777/*
6778 * generic initialization of ADC, input mixers and output mixers
6779 */
6780static struct hda_verb alc882_auto_init_verbs[] = {
6781 /*
6782 * Unmute ADC0-2 and set the default input to mic-in
6783 */
6784 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6785 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6786 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6787 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6788 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6789 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6790
Takashi Iwaicb53c622007-08-10 17:21:45 +02006791 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01006792 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006793 * Note: PASD motherboards uses the Line In 2 as the input for
6794 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006795 */
6796 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006797 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6798 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6799 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6800 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6801 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006802
6803 /*
6804 * Set up output mixers (0x0c - 0x0f)
6805 */
6806 /* set vol=0 to output mixers */
6807 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6808 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6809 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6810 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6811 /* set up input amps for analog loopback */
6812 /* Amp Indices: DAC = 0, mixer = 1 */
6813 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6814 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6815 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6816 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6817 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6818 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6819 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6820 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6821 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6822 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6823
6824 /* FIXME: use matrix-type input source selection */
6825 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6826 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6827 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6828 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6829 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6830 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6831 /* Input mixer2 */
6832 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6833 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6834 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6835 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6836 /* Input mixer3 */
6837 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6838 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6839 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6840 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6841
6842 { }
6843};
6844
Takashi Iwaicb53c622007-08-10 17:21:45 +02006845#ifdef CONFIG_SND_HDA_POWER_SAVE
6846#define alc882_loopbacks alc880_loopbacks
6847#endif
6848
Kailang Yangdf694da2005-12-05 19:42:22 +01006849/* pcm configuration: identiacal with ALC880 */
6850#define alc882_pcm_analog_playback alc880_pcm_analog_playback
6851#define alc882_pcm_analog_capture alc880_pcm_analog_capture
6852#define alc882_pcm_digital_playback alc880_pcm_digital_playback
6853#define alc882_pcm_digital_capture alc880_pcm_digital_capture
6854
6855/*
6856 * configuration and preset
6857 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006858static const char *alc882_models[ALC882_MODEL_LAST] = {
6859 [ALC882_3ST_DIG] = "3stack-dig",
6860 [ALC882_6ST_DIG] = "6stack-dig",
6861 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02006862 [ALC882_W2JC] = "w2jc",
Takashi Iwai0438a002007-09-06 14:54:11 +02006863 [ALC882_TARGA] = "targa",
6864 [ALC882_ASUS_A7J] = "asus-a7j",
6865 [ALC882_ASUS_A7M] = "asus-a7m",
Tobin Davis9102cd12006-12-15 10:02:12 +01006866 [ALC885_MACPRO] = "macpro",
Takashi Iwai87350ad2007-08-16 18:19:38 +02006867 [ALC885_MBP3] = "mbp3",
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006868 [ALC885_IMAC24] = "imac24",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006869 [ALC882_AUTO] = "auto",
6870};
6871
6872static struct snd_pci_quirk alc882_cfg_tbl[] = {
6873 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02006874 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Kailang Yangac8842a2007-09-20 12:51:39 +02006875 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
Takashi Iwai914759b2007-09-06 14:52:04 +02006876 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006877 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Claudio Matsuokac5d9f1c2007-07-19 23:18:32 +02006878 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
Tobin Davis7b9470d2006-12-28 13:56:48 +01006879 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006880 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Jiang zhe44447042008-01-28 12:28:24 +01006881 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006882 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
6883 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
6884 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yangdf694da2005-12-05 19:42:22 +01006885 {}
6886};
6887
6888static struct alc_config_preset alc882_presets[] = {
6889 [ALC882_3ST_DIG] = {
6890 .mixers = { alc882_base_mixer },
6891 .init_verbs = { alc882_init_verbs },
6892 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6893 .dac_nids = alc882_dac_nids,
6894 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006895 .dig_in_nid = ALC882_DIGIN_NID,
6896 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6897 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006898 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01006899 .input_mux = &alc882_capture_source,
6900 },
6901 [ALC882_6ST_DIG] = {
6902 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6903 .init_verbs = { alc882_init_verbs },
6904 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6905 .dac_nids = alc882_dac_nids,
6906 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006907 .dig_in_nid = ALC882_DIGIN_NID,
6908 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6909 .channel_mode = alc882_sixstack_modes,
6910 .input_mux = &alc882_capture_source,
6911 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006912 [ALC882_ARIMA] = {
6913 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6914 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
6915 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6916 .dac_nids = alc882_dac_nids,
6917 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6918 .channel_mode = alc882_sixstack_modes,
6919 .input_mux = &alc882_capture_source,
6920 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02006921 [ALC882_W2JC] = {
6922 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
6923 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6924 alc880_gpio1_init_verbs },
6925 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6926 .dac_nids = alc882_dac_nids,
6927 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6928 .channel_mode = alc880_threestack_modes,
6929 .need_dac_fix = 1,
6930 .input_mux = &alc882_capture_source,
6931 .dig_out_nid = ALC882_DIGOUT_NID,
6932 },
Takashi Iwai87350ad2007-08-16 18:19:38 +02006933 [ALC885_MBP3] = {
6934 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
6935 .init_verbs = { alc885_mbp3_init_verbs,
6936 alc880_gpio1_init_verbs },
6937 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6938 .dac_nids = alc882_dac_nids,
6939 .channel_mode = alc885_mbp_6ch_modes,
6940 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
6941 .input_mux = &alc882_capture_source,
6942 .dig_out_nid = ALC882_DIGOUT_NID,
6943 .dig_in_nid = ALC882_DIGIN_NID,
6944 .unsol_event = alc885_mbp3_unsol_event,
6945 .init_hook = alc885_mbp3_automute,
6946 },
Tobin Davis9102cd12006-12-15 10:02:12 +01006947 [ALC885_MACPRO] = {
6948 .mixers = { alc882_macpro_mixer },
6949 .init_verbs = { alc882_macpro_init_verbs },
6950 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6951 .dac_nids = alc882_dac_nids,
6952 .dig_out_nid = ALC882_DIGOUT_NID,
6953 .dig_in_nid = ALC882_DIGIN_NID,
6954 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6955 .channel_mode = alc882_ch_modes,
6956 .input_mux = &alc882_capture_source,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006957 .init_hook = alc885_macpro_init_hook,
Tobin Davis9102cd12006-12-15 10:02:12 +01006958 },
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006959 [ALC885_IMAC24] = {
6960 .mixers = { alc885_imac24_mixer },
6961 .init_verbs = { alc885_imac24_init_verbs },
6962 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6963 .dac_nids = alc882_dac_nids,
6964 .dig_out_nid = ALC882_DIGOUT_NID,
6965 .dig_in_nid = ALC882_DIGIN_NID,
6966 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6967 .channel_mode = alc882_ch_modes,
6968 .input_mux = &alc882_capture_source,
6969 .unsol_event = alc885_imac24_unsol_event,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006970 .init_hook = alc885_imac24_init_hook,
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006971 },
Kailang Yang272a5272007-05-14 11:00:38 +02006972 [ALC882_TARGA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006973 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Kailang Yang272a5272007-05-14 11:00:38 +02006974 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
6975 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6976 .dac_nids = alc882_dac_nids,
6977 .dig_out_nid = ALC882_DIGOUT_NID,
6978 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6979 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01006980 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02006981 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6982 .channel_mode = alc882_3ST_6ch_modes,
6983 .need_dac_fix = 1,
6984 .input_mux = &alc882_capture_source,
6985 .unsol_event = alc882_targa_unsol_event,
6986 .init_hook = alc882_targa_automute,
6987 },
6988 [ALC882_ASUS_A7J] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006989 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Kailang Yang272a5272007-05-14 11:00:38 +02006990 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
6991 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6992 .dac_nids = alc882_dac_nids,
6993 .dig_out_nid = ALC882_DIGOUT_NID,
6994 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6995 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01006996 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02006997 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6998 .channel_mode = alc882_3ST_6ch_modes,
6999 .need_dac_fix = 1,
7000 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02007001 },
Takashi Iwai914759b2007-09-06 14:52:04 +02007002 [ALC882_ASUS_A7M] = {
7003 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
7004 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
7005 alc880_gpio1_init_verbs,
7006 alc882_asus_a7m_verbs },
7007 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7008 .dac_nids = alc882_dac_nids,
7009 .dig_out_nid = ALC882_DIGOUT_NID,
7010 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
7011 .channel_mode = alc880_threestack_modes,
7012 .need_dac_fix = 1,
7013 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02007014 },
Kailang Yangdf694da2005-12-05 19:42:22 +01007015};
7016
7017
7018/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02007019 * Pin config fixes
7020 */
Kailang Yangea1fb292008-08-26 12:58:38 +02007021enum {
Takashi Iwaif95474e2007-07-10 00:47:43 +02007022 PINFIX_ABIT_AW9D_MAX
7023};
7024
7025static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
7026 { 0x15, 0x01080104 }, /* side */
7027 { 0x16, 0x01011012 }, /* rear */
7028 { 0x17, 0x01016011 }, /* clfe */
7029 { }
7030};
7031
7032static const struct alc_pincfg *alc882_pin_fixes[] = {
7033 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
7034};
7035
7036static struct snd_pci_quirk alc882_pinfix_tbl[] = {
7037 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
7038 {}
7039};
7040
7041/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007042 * BIOS auto configuration
7043 */
7044static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
7045 hda_nid_t nid, int pin_type,
7046 int dac_idx)
7047{
7048 /* set as output */
7049 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007050 int idx;
7051
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007052 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01007053 if (spec->multiout.dac_nids[dac_idx] == 0x25)
7054 idx = 4;
7055 else
7056 idx = spec->multiout.dac_nids[dac_idx] - 2;
Kailang Yangdf694da2005-12-05 19:42:22 +01007057 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
7058
7059}
7060
7061static void alc882_auto_init_multi_out(struct hda_codec *codec)
7062{
7063 struct alc_spec *spec = codec->spec;
7064 int i;
7065
7066 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007067 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007068 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01007069 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007070 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007071 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01007072 }
7073}
7074
7075static void alc882_auto_init_hp_out(struct hda_codec *codec)
7076{
7077 struct alc_spec *spec = codec->spec;
7078 hda_nid_t pin;
7079
Takashi Iwaieb06ed82006-09-20 17:10:27 +02007080 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007081 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007082 /* use dac 0 */
7083 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007084 pin = spec->autocfg.speaker_pins[0];
7085 if (pin)
7086 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01007087}
7088
7089#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
7090#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
7091
7092static void alc882_auto_init_analog_input(struct hda_codec *codec)
7093{
7094 struct alc_spec *spec = codec->spec;
7095 int i;
7096
7097 for (i = 0; i < AUTO_PIN_LAST; i++) {
7098 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai7194cae2008-03-06 16:58:17 +01007099 if (!nid)
7100 continue;
Takashi Iwai23f0c042009-02-26 13:03:58 +01007101 alc_set_input_pin(codec, nid, AUTO_PIN_FRONT_MIC /*i*/);
Takashi Iwai7194cae2008-03-06 16:58:17 +01007102 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
7103 snd_hda_codec_write(codec, nid, 0,
7104 AC_VERB_SET_AMP_GAIN_MUTE,
7105 AMP_OUT_MUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01007106 }
7107}
7108
Takashi Iwaif511b012008-08-15 16:46:42 +02007109static void alc882_auto_init_input_src(struct hda_codec *codec)
7110{
7111 struct alc_spec *spec = codec->spec;
Takashi Iwaif511b012008-08-15 16:46:42 +02007112 int c;
7113
7114 for (c = 0; c < spec->num_adc_nids; c++) {
7115 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
7116 hda_nid_t nid = spec->capsrc_nids[c];
Herton Ronaldo Krzesinskib98b7b32009-01-29 13:18:31 -02007117 unsigned int mux_idx;
7118 const struct hda_input_mux *imux;
Takashi Iwaif511b012008-08-15 16:46:42 +02007119 int conns, mute, idx, item;
7120
7121 conns = snd_hda_get_connections(codec, nid, conn_list,
7122 ARRAY_SIZE(conn_list));
7123 if (conns < 0)
7124 continue;
Herton Ronaldo Krzesinskib98b7b32009-01-29 13:18:31 -02007125 mux_idx = c >= spec->num_mux_defs ? 0 : c;
7126 imux = &spec->input_mux[mux_idx];
Takashi Iwaif511b012008-08-15 16:46:42 +02007127 for (idx = 0; idx < conns; idx++) {
7128 /* if the current connection is the selected one,
7129 * unmute it as default - otherwise mute it
7130 */
7131 mute = AMP_IN_MUTE(idx);
7132 for (item = 0; item < imux->num_items; item++) {
7133 if (imux->items[item].index == idx) {
7134 if (spec->cur_mux[c] == item)
7135 mute = AMP_IN_UNMUTE(idx);
7136 break;
7137 }
7138 }
Herton Ronaldo Krzesinskib98b7b32009-01-29 13:18:31 -02007139 /* check if we have a selector or mixer
7140 * we could check for the widget type instead, but
7141 * just check for Amp-In presence (in case of mixer
7142 * without amp-in there is something wrong, this
7143 * function shouldn't be used or capsrc nid is wrong)
7144 */
7145 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
7146 snd_hda_codec_write(codec, nid, 0,
7147 AC_VERB_SET_AMP_GAIN_MUTE,
7148 mute);
7149 else if (mute != AMP_IN_MUTE(idx))
7150 snd_hda_codec_write(codec, nid, 0,
7151 AC_VERB_SET_CONNECT_SEL,
7152 idx);
Takashi Iwaif511b012008-08-15 16:46:42 +02007153 }
7154 }
7155}
7156
Takashi Iwai776e1842007-08-29 15:07:11 +02007157/* add mic boosts if needed */
7158static int alc_auto_add_mic_boost(struct hda_codec *codec)
7159{
7160 struct alc_spec *spec = codec->spec;
7161 int err;
7162 hda_nid_t nid;
7163
7164 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01007165 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02007166 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7167 "Mic Boost",
7168 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
7169 if (err < 0)
7170 return err;
7171 }
7172 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01007173 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02007174 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7175 "Front Mic Boost",
7176 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
7177 if (err < 0)
7178 return err;
7179 }
7180 return 0;
7181}
7182
Kailang Yangdf694da2005-12-05 19:42:22 +01007183/* almost identical with ALC880 parser... */
7184static int alc882_parse_auto_config(struct hda_codec *codec)
7185{
7186 struct alc_spec *spec = codec->spec;
7187 int err = alc880_parse_auto_config(codec);
7188
7189 if (err < 0)
7190 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02007191 else if (!err)
7192 return 0; /* no config found */
7193
7194 err = alc_auto_add_mic_boost(codec);
7195 if (err < 0)
7196 return err;
7197
7198 /* hack - override the init verbs */
7199 spec->init_verbs[0] = alc882_auto_init_verbs;
7200
7201 return 1; /* config found */
Kailang Yangdf694da2005-12-05 19:42:22 +01007202}
7203
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007204/* additional initialization for auto-configuration model */
7205static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01007206{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007207 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007208 alc882_auto_init_multi_out(codec);
7209 alc882_auto_init_hp_out(codec);
7210 alc882_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02007211 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007212 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02007213 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01007214}
7215
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007216static int patch_alc883(struct hda_codec *codec); /* called in patch_alc882() */
7217
Linus Torvalds1da177e2005-04-16 15:20:36 -07007218static int patch_alc882(struct hda_codec *codec)
7219{
7220 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007221 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007222
Takashi Iwaie560d8d2005-09-09 14:21:46 +02007223 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007224 if (spec == NULL)
7225 return -ENOMEM;
7226
Linus Torvalds1da177e2005-04-16 15:20:36 -07007227 codec->spec = spec;
7228
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007229 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
7230 alc882_models,
7231 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007232
Kailang Yangdf694da2005-12-05 19:42:22 +01007233 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01007234 /* Pick up systems that don't supply PCI SSID */
7235 switch (codec->subsystem_id) {
7236 case 0x106b0c00: /* Mac Pro */
7237 board_config = ALC885_MACPRO;
7238 break;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007239 case 0x106b1000: /* iMac 24 */
Peter Korsgaardf3911c52008-09-27 09:13:45 +02007240 case 0x106b2800: /* AppleTV */
Mark Eggleston3077e442009-01-31 17:57:54 +01007241 case 0x106b3e00: /* iMac 24 Aluminium */
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007242 board_config = ALC885_IMAC24;
7243 break;
Luke Yelavich2d466382009-02-23 13:00:33 +11007244 case 0x106b00a0: /* MacBookPro3,1 - Another revision */
Takashi Iwaic7e07572008-06-26 14:42:51 +02007245 case 0x106b00a1: /* Macbook (might be wrong - PCI SSID?) */
David Woodhouse9c95c432008-09-18 13:37:13 -07007246 case 0x106b00a4: /* MacbookPro4,1 */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007247 case 0x106b2c00: /* Macbook Pro rev3 */
Takashi Iwaic7e07572008-06-26 14:42:51 +02007248 case 0x106b3600: /* Macbook 3.1 */
Luke Yelavich2a884642009-01-28 15:58:38 +11007249 case 0x106b3800: /* MacbookPro4,1 - latter revision */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007250 board_config = ALC885_MBP3;
7251 break;
Tobin Davis081d17c2007-02-15 17:46:18 +01007252 default:
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007253 /* ALC889A is handled better as ALC888-compatible */
Clive Messer669faba2008-09-30 15:49:13 +02007254 if (codec->revision_id == 0x100101 ||
7255 codec->revision_id == 0x100103) {
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007256 alc_free(codec);
7257 return patch_alc883(codec);
7258 }
Tobin Davis081d17c2007-02-15 17:46:18 +01007259 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
7260 "trying auto-probe from BIOS...\n");
7261 board_config = ALC882_AUTO;
7262 }
Kailang Yangdf694da2005-12-05 19:42:22 +01007263 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007264
Takashi Iwaif95474e2007-07-10 00:47:43 +02007265 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
7266
Kailang Yangdf694da2005-12-05 19:42:22 +01007267 if (board_config == ALC882_AUTO) {
7268 /* automatic parse from the BIOS config */
7269 err = alc882_parse_auto_config(codec);
7270 if (err < 0) {
7271 alc_free(codec);
7272 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007273 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007274 printk(KERN_INFO
7275 "hda_codec: Cannot set up configuration "
7276 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007277 board_config = ALC882_3ST_DIG;
7278 }
7279 }
7280
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09007281 err = snd_hda_attach_beep_device(codec, 0x1);
7282 if (err < 0) {
7283 alc_free(codec);
7284 return err;
7285 }
7286
Kailang Yangdf694da2005-12-05 19:42:22 +01007287 if (board_config != ALC882_AUTO)
7288 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007289
Kailang Yang2f893282008-05-27 12:14:47 +02007290 if (codec->vendor_id == 0x10ec0885) {
7291 spec->stream_name_analog = "ALC885 Analog";
7292 spec->stream_name_digital = "ALC885 Digital";
7293 } else {
7294 spec->stream_name_analog = "ALC882 Analog";
7295 spec->stream_name_digital = "ALC882 Digital";
7296 }
7297
Kailang Yangdf694da2005-12-05 19:42:22 +01007298 spec->stream_analog_playback = &alc882_pcm_analog_playback;
7299 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01007300 /* FIXME: setup DAC5 */
7301 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
7302 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007303
Kailang Yangdf694da2005-12-05 19:42:22 +01007304 spec->stream_digital_playback = &alc882_pcm_digital_playback;
7305 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007306
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007307 spec->capture_style = CAPT_MIX; /* matrix-style capture */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007308 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01007309 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01007310 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007311 /* get type */
7312 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01007313 if (wcap != AC_WID_AUD_IN) {
7314 spec->adc_nids = alc882_adc_nids_alt;
7315 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
Takashi Iwaie1406342008-02-11 18:32:32 +01007316 spec->capsrc_nids = alc882_capsrc_nids_alt;
Kailang Yangdf694da2005-12-05 19:42:22 +01007317 } else {
7318 spec->adc_nids = alc882_adc_nids;
7319 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +01007320 spec->capsrc_nids = alc882_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +01007321 }
7322 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007323 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007324 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007325
Takashi Iwai2134ea42008-01-10 16:53:55 +01007326 spec->vmaster_nid = 0x0c;
7327
Linus Torvalds1da177e2005-04-16 15:20:36 -07007328 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01007329 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007330 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02007331#ifdef CONFIG_SND_HDA_POWER_SAVE
7332 if (!spec->loopback.amplist)
7333 spec->loopback.amplist = alc882_loopbacks;
7334#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01007335 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007336
7337 return 0;
7338}
7339
7340/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007341 * ALC883 support
7342 *
7343 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
7344 * configuration. Each pin widget can choose any input DACs and a mixer.
7345 * Each ADC is connected from a mixer of all inputs. This makes possible
7346 * 6-channel independent captures.
7347 *
7348 * In addition, an independent DAC for the multi-playback (not used in this
7349 * driver yet).
7350 */
7351#define ALC883_DIGOUT_NID 0x06
7352#define ALC883_DIGIN_NID 0x0a
7353
Wu Fengguang3ab90932008-11-17 09:51:09 +01007354#define ALC1200_DIGOUT_NID 0x10
7355
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007356static hda_nid_t alc883_dac_nids[4] = {
7357 /* front, rear, clfe, rear_surr */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01007358 0x02, 0x03, 0x04, 0x05
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007359};
7360
7361static hda_nid_t alc883_adc_nids[2] = {
7362 /* ADC1-2 */
7363 0x08, 0x09,
7364};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007365
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007366static hda_nid_t alc883_adc_nids_alt[1] = {
7367 /* ADC1 */
7368 0x08,
7369};
7370
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08007371static hda_nid_t alc883_adc_nids_rev[2] = {
7372 /* ADC2-1 */
7373 0x09, 0x08
7374};
7375
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007376#define alc889_adc_nids alc880_adc_nids
7377
Takashi Iwaie1406342008-02-11 18:32:32 +01007378static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 };
7379
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08007380static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
7381
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007382#define alc889_capsrc_nids alc882_capsrc_nids
7383
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007384/* input MUX */
7385/* FIXME: should be a matrix-type input source selection */
7386
7387static struct hda_input_mux alc883_capture_source = {
7388 .num_items = 4,
7389 .items = {
7390 { "Mic", 0x0 },
7391 { "Front Mic", 0x1 },
7392 { "Line", 0x2 },
7393 { "CD", 0x4 },
7394 },
7395};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007396
Jiang zhe17bba1b2008-06-04 12:11:07 +02007397static struct hda_input_mux alc883_3stack_6ch_intel = {
7398 .num_items = 4,
7399 .items = {
7400 { "Mic", 0x1 },
7401 { "Front Mic", 0x0 },
7402 { "Line", 0x2 },
7403 { "CD", 0x4 },
7404 },
7405};
7406
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007407static struct hda_input_mux alc883_lenovo_101e_capture_source = {
7408 .num_items = 2,
7409 .items = {
7410 { "Mic", 0x1 },
7411 { "Line", 0x2 },
7412 },
7413};
7414
Kailang Yang272a5272007-05-14 11:00:38 +02007415static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
7416 .num_items = 4,
7417 .items = {
7418 { "Mic", 0x0 },
7419 { "iMic", 0x1 },
7420 { "Line", 0x2 },
7421 { "CD", 0x4 },
7422 },
7423};
7424
Jiang zhefb97dc62008-03-06 11:07:11 +01007425static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
7426 .num_items = 2,
7427 .items = {
7428 { "Mic", 0x0 },
7429 { "Int Mic", 0x1 },
7430 },
7431};
7432
Kailang Yange2757d52008-08-26 13:17:46 +02007433static struct hda_input_mux alc883_lenovo_sky_capture_source = {
7434 .num_items = 3,
7435 .items = {
7436 { "Mic", 0x0 },
7437 { "Front Mic", 0x1 },
7438 { "Line", 0x4 },
7439 },
7440};
7441
7442static struct hda_input_mux alc883_asus_eee1601_capture_source = {
7443 .num_items = 2,
7444 .items = {
7445 { "Mic", 0x0 },
7446 { "Line", 0x2 },
7447 },
7448};
7449
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007450/*
7451 * 2ch mode
7452 */
7453static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
7454 { 2, NULL }
7455};
7456
7457/*
7458 * 2ch mode
7459 */
7460static struct hda_verb alc883_3ST_ch2_init[] = {
7461 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7462 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7463 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7464 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7465 { } /* end */
7466};
7467
7468/*
Tobin Davisb2011312007-09-17 12:45:11 +02007469 * 4ch mode
7470 */
7471static struct hda_verb alc883_3ST_ch4_init[] = {
7472 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7473 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7474 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7475 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7476 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7477 { } /* end */
7478};
7479
7480/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007481 * 6ch mode
7482 */
7483static struct hda_verb alc883_3ST_ch6_init[] = {
7484 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7485 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7486 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7487 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7488 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7489 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7490 { } /* end */
7491};
7492
Tobin Davisb2011312007-09-17 12:45:11 +02007493static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007494 { 2, alc883_3ST_ch2_init },
Tobin Davisb2011312007-09-17 12:45:11 +02007495 { 4, alc883_3ST_ch4_init },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007496 { 6, alc883_3ST_ch6_init },
7497};
7498
7499/*
Jiang zhe17bba1b2008-06-04 12:11:07 +02007500 * 2ch mode
7501 */
7502static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7503 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7504 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7505 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7506 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7507 { } /* end */
7508};
7509
7510/*
7511 * 4ch mode
7512 */
7513static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7514 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7515 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7516 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7517 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7518 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7519 { } /* end */
7520};
7521
7522/*
7523 * 6ch mode
7524 */
7525static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7526 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7527 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7528 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7529 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7530 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7531 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7532 { } /* end */
7533};
7534
7535static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7536 { 2, alc883_3ST_ch2_intel_init },
7537 { 4, alc883_3ST_ch4_intel_init },
7538 { 6, alc883_3ST_ch6_intel_init },
7539};
7540
7541/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007542 * 6ch mode
7543 */
7544static struct hda_verb alc883_sixstack_ch6_init[] = {
7545 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7546 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7547 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7548 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7549 { } /* end */
7550};
7551
7552/*
7553 * 8ch mode
7554 */
7555static struct hda_verb alc883_sixstack_ch8_init[] = {
7556 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7557 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7558 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7559 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7560 { } /* end */
7561};
7562
7563static struct hda_channel_mode alc883_sixstack_modes[2] = {
7564 { 6, alc883_sixstack_ch6_init },
7565 { 8, alc883_sixstack_ch8_init },
7566};
7567
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007568static struct hda_verb alc883_medion_eapd_verbs[] = {
7569 /* eanable EAPD on medion laptop */
7570 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7571 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7572 { }
7573};
7574
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007575/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7576 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7577 */
7578
7579static struct snd_kcontrol_new alc883_base_mixer[] = {
7580 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7581 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7582 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7583 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7584 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7585 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7586 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7587 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7588 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7589 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7590 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7591 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7592 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7593 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7594 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7595 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007596 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007597 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7598 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007599 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007600 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007601 { } /* end */
7602};
7603
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007604static struct snd_kcontrol_new alc883_mitac_mixer[] = {
7605 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7606 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7607 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7608 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7609 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7610 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7611 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7612 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7613 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7614 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7615 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7616 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7617 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007618 { } /* end */
7619};
7620
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007621static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007622 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7623 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7624 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7625 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7626 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7627 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7628 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7629 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7630 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7631 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01007632 { } /* end */
7633};
7634
Jiang zhefb97dc62008-03-06 11:07:11 +01007635static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
7636 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7637 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7638 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7639 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7640 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7641 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7642 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7643 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7644 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7645 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01007646 { } /* end */
7647};
7648
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007649static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
7650 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7651 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7652 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7653 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7654 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7655 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7656 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7657 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007658 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007659 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7660 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007661 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007662 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007663 { } /* end */
7664};
7665
7666static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
7667 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7668 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7669 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7670 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7671 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7672 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7673 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7674 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7675 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7676 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7677 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7678 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7679 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7680 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007681 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007682 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7683 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007684 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007685 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007686 { } /* end */
7687};
7688
Jiang zhe17bba1b2008-06-04 12:11:07 +02007689static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
7690 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7691 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7692 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7693 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7694 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7695 HDA_OUTPUT),
7696 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7697 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7698 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7699 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7700 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7701 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7702 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7703 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7704 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7705 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
7706 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7707 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7708 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7709 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02007710 { } /* end */
7711};
7712
Takashi Iwaid1d985f2006-11-23 19:27:12 +01007713static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02007714 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007715 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007716 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007717 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007718 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7719 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007720 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7721 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007722 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7723 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7724 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7725 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7726 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7727 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007728 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007729 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7730 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007731 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007732 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007733 { } /* end */
7734};
7735
Kailang Yangccc656c2006-10-17 12:32:26 +02007736static struct snd_kcontrol_new alc883_tagra_mixer[] = {
7737 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7738 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7739 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7740 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7741 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7742 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7743 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7744 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7745 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7746 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7747 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7748 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7749 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7750 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007751 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007752 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007753 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007754};
Kailang Yangccc656c2006-10-17 12:32:26 +02007755
7756static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
7757 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7758 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7759 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7760 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7761 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7762 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007763 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007764 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02007765 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7766 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7767 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007768 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007769};
Kailang Yangccc656c2006-10-17 12:32:26 +02007770
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007771static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
7772 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7773 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01007774 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7775 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007776 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7777 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7778 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7779 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007780 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007781};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007782
Kailang Yang272a5272007-05-14 11:00:38 +02007783static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
7784 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7785 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
7786 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7787 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7788 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7789 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7790 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7791 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7792 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007793 { } /* end */
7794};
7795
7796static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
7797 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7798 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7799 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7800 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7801 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7802 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7803 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7804 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7805 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007806 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02007807};
Kailang Yang272a5272007-05-14 11:00:38 +02007808
Tobin Davis2880a862007-08-07 11:50:26 +02007809static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02007810 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7811 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007812 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007813 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7814 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02007815 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7816 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7817 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007818 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02007819};
Tobin Davis2880a862007-08-07 11:50:26 +02007820
Kailang Yange2757d52008-08-26 13:17:46 +02007821static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
7822 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7823 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7824 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
7825 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
7826 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
7827 0x0d, 1, 0x0, HDA_OUTPUT),
7828 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
7829 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
7830 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
7831 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7832 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7833 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7834 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
7835 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7836 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7837 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7838 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7839 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7840 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7841 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7842 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7843 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7844 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02007845 { } /* end */
7846};
7847
7848static struct hda_bind_ctls alc883_bind_cap_vol = {
7849 .ops = &snd_hda_bind_vol,
7850 .values = {
7851 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
7852 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7853 0
7854 },
7855};
7856
7857static struct hda_bind_ctls alc883_bind_cap_switch = {
7858 .ops = &snd_hda_bind_sw,
7859 .values = {
7860 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
7861 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7862 0
7863 },
7864};
7865
7866static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
7867 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7868 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7869 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7870 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7871 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7872 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7873 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7874 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007875 { } /* end */
7876};
7877
7878static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02007879 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
7880 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
7881 {
7882 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7883 /* .name = "Capture Source", */
7884 .name = "Input Source",
7885 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01007886 .info = alc_mux_enum_info,
7887 .get = alc_mux_enum_get,
7888 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02007889 },
7890 { } /* end */
7891};
7892
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007893static struct snd_kcontrol_new alc883_chmode_mixer[] = {
7894 {
7895 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7896 .name = "Channel Mode",
7897 .info = alc_ch_mode_info,
7898 .get = alc_ch_mode_get,
7899 .put = alc_ch_mode_put,
7900 },
7901 { } /* end */
7902};
7903
7904static struct hda_verb alc883_init_verbs[] = {
7905 /* ADC1: mute amp left and right */
Kailang Yange2757d52008-08-26 13:17:46 +02007906 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007907 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7908 /* ADC2: mute amp left and right */
7909 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7910 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7911 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7912 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7913 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7914 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7915 /* Rear mixer */
7916 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7917 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7918 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7919 /* CLFE mixer */
7920 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7921 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7922 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7923 /* Side mixer */
7924 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7925 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7926 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7927
Takashi Iwaicb53c622007-08-10 17:21:45 +02007928 /* mute analog input loopbacks */
7929 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7930 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7931 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7932 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7933 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007934
7935 /* Front Pin: output 0 (0x0c) */
7936 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7937 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7938 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7939 /* Rear Pin: output 1 (0x0d) */
7940 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7941 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7942 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7943 /* CLFE Pin: output 2 (0x0e) */
7944 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7945 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7946 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7947 /* Side Pin: output 3 (0x0f) */
7948 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7949 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7950 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7951 /* Mic (rear) pin: input vref at 80% */
7952 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7953 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7954 /* Front Mic pin: input vref at 80% */
7955 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7956 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7957 /* Line In pin: input */
7958 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7959 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7960 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7961 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7962 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7963 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7964 /* CD pin widget for input */
7965 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7966
7967 /* FIXME: use matrix-type input source selection */
7968 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7969 /* Input mixer2 */
7970 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yange2757d52008-08-26 13:17:46 +02007971 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7972 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7973 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007974 /* Input mixer3 */
7975 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yange2757d52008-08-26 13:17:46 +02007976 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7977 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7978 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007979 { }
7980};
7981
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007982/* toggle speaker-output according to the hp-jack state */
7983static void alc883_mitac_hp_automute(struct hda_codec *codec)
7984{
7985 unsigned int present;
7986
7987 present = snd_hda_codec_read(codec, 0x15, 0,
7988 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7989 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7990 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7991 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7992 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7993}
7994
7995/* auto-toggle front mic */
7996/*
7997static void alc883_mitac_mic_automute(struct hda_codec *codec)
7998{
7999 unsigned int present;
8000 unsigned char bits;
8001
8002 present = snd_hda_codec_read(codec, 0x18, 0,
8003 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8004 bits = present ? HDA_AMP_MUTE : 0;
8005 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
8006}
8007*/
8008
8009static void alc883_mitac_automute(struct hda_codec *codec)
8010{
8011 alc883_mitac_hp_automute(codec);
8012 /* alc883_mitac_mic_automute(codec); */
8013}
8014
8015static void alc883_mitac_unsol_event(struct hda_codec *codec,
8016 unsigned int res)
8017{
8018 switch (res >> 26) {
8019 case ALC880_HP_EVENT:
8020 alc883_mitac_hp_automute(codec);
8021 break;
8022 case ALC880_MIC_EVENT:
8023 /* alc883_mitac_mic_automute(codec); */
8024 break;
8025 }
8026}
8027
8028static struct hda_verb alc883_mitac_verbs[] = {
8029 /* HP */
8030 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8031 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8032 /* Subwoofer */
8033 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8034 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8035
8036 /* enable unsolicited event */
8037 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8038 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
8039
8040 { } /* end */
8041};
8042
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008043static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008044 /* HP */
8045 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8046 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8047 /* Int speaker */
8048 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
8049 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8050
8051 /* enable unsolicited event */
8052 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008053 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01008054
8055 { } /* end */
8056};
8057
Jiang zhefb97dc62008-03-06 11:07:11 +01008058static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
8059 /* HP */
8060 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8061 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8062 /* Subwoofer */
8063 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8064 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8065
8066 /* enable unsolicited event */
8067 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8068
8069 { } /* end */
8070};
8071
Kailang Yangccc656c2006-10-17 12:32:26 +02008072static struct hda_verb alc883_tagra_verbs[] = {
8073 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8074 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8075
8076 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8077 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008078
Kailang Yangccc656c2006-10-17 12:32:26 +02008079 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8080 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8081 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8082
8083 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008084 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
8085 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
8086 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
Kailang Yangccc656c2006-10-17 12:32:26 +02008087
8088 { } /* end */
8089};
8090
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008091static struct hda_verb alc883_lenovo_101e_verbs[] = {
8092 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8093 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
8094 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
8095 { } /* end */
8096};
8097
Kailang Yang272a5272007-05-14 11:00:38 +02008098static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
8099 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8100 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8101 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8102 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8103 { } /* end */
8104};
8105
8106static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
8107 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8108 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8109 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8110 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
8111 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8112 { } /* end */
8113};
8114
Kailang Yang189609a2007-08-20 11:31:23 +02008115static struct hda_verb alc883_haier_w66_verbs[] = {
8116 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8117 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8118
8119 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8120
8121 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8122 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8123 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8124 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8125 { } /* end */
8126};
8127
Kailang Yange2757d52008-08-26 13:17:46 +02008128static struct hda_verb alc888_lenovo_sky_verbs[] = {
8129 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8130 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8131 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8132 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8133 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8134 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8135 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8136 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8137 { } /* end */
8138};
8139
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008140static struct hda_verb alc888_6st_dell_verbs[] = {
8141 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8142 { }
8143};
8144
8145static void alc888_3st_hp_front_automute(struct hda_codec *codec)
8146{
8147 unsigned int present, bits;
8148
8149 present = snd_hda_codec_read(codec, 0x1b, 0,
8150 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8151 bits = present ? HDA_AMP_MUTE : 0;
8152 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8153 HDA_AMP_MUTE, bits);
8154 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8155 HDA_AMP_MUTE, bits);
8156 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
8157 HDA_AMP_MUTE, bits);
8158}
8159
8160static void alc888_3st_hp_unsol_event(struct hda_codec *codec,
8161 unsigned int res)
8162{
8163 switch (res >> 26) {
8164 case ALC880_HP_EVENT:
8165 alc888_3st_hp_front_automute(codec);
8166 break;
8167 }
8168}
8169
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008170static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008171 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01008172 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
8173 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008174 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008175 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008176};
8177
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008178/*
8179 * 2ch mode
8180 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008181static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008182 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8183 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8184 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
8185 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008186 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008187};
8188
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008189/*
8190 * 4ch mode
8191 */
8192static struct hda_verb alc888_3st_hp_4ch_init[] = {
8193 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8194 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8195 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8196 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8197 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8198 { } /* end */
8199};
8200
8201/*
8202 * 6ch mode
8203 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008204static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008205 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8206 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008207 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008208 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8209 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008210 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8211 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008212};
8213
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008214static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008215 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008216 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008217 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008218};
8219
Kailang Yang272a5272007-05-14 11:00:38 +02008220/* toggle front-jack and RCA according to the hp-jack state */
8221static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
8222{
8223 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008224
Kailang Yang272a5272007-05-14 11:00:38 +02008225 present = snd_hda_codec_read(codec, 0x1b, 0,
8226 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008227 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8228 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8229 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8230 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008231}
8232
8233/* toggle RCA according to the front-jack state */
8234static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
8235{
8236 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008237
Kailang Yang272a5272007-05-14 11:00:38 +02008238 present = snd_hda_codec_read(codec, 0x14, 0,
8239 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008240 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8241 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008242}
Takashi Iwai47fd8302007-08-10 17:11:07 +02008243
Kailang Yang272a5272007-05-14 11:00:38 +02008244static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
8245 unsigned int res)
8246{
8247 if ((res >> 26) == ALC880_HP_EVENT)
8248 alc888_lenovo_ms7195_front_automute(codec);
8249 if ((res >> 26) == ALC880_FRONT_EVENT)
8250 alc888_lenovo_ms7195_rca_automute(codec);
8251}
8252
8253static struct hda_verb alc883_medion_md2_verbs[] = {
8254 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8255 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8256
8257 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8258
8259 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8260 { } /* end */
8261};
8262
8263/* toggle speaker-output according to the hp-jack state */
8264static void alc883_medion_md2_automute(struct hda_codec *codec)
8265{
8266 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008267
Kailang Yang272a5272007-05-14 11:00:38 +02008268 present = snd_hda_codec_read(codec, 0x14, 0,
8269 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008270 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8271 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008272}
8273
8274static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
8275 unsigned int res)
8276{
8277 if ((res >> 26) == ALC880_HP_EVENT)
8278 alc883_medion_md2_automute(codec);
8279}
8280
Kailang Yangccc656c2006-10-17 12:32:26 +02008281/* toggle speaker-output according to the hp-jack state */
8282static void alc883_tagra_automute(struct hda_codec *codec)
8283{
8284 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008285 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02008286
8287 present = snd_hda_codec_read(codec, 0x14, 0,
8288 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008289 bits = present ? HDA_AMP_MUTE : 0;
8290 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
8291 HDA_AMP_MUTE, bits);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008292 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
8293 present ? 1 : 3);
Kailang Yangccc656c2006-10-17 12:32:26 +02008294}
8295
8296static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
8297{
8298 if ((res >> 26) == ALC880_HP_EVENT)
8299 alc883_tagra_automute(codec);
8300}
8301
Jiang zhe368c7a92008-03-04 11:20:33 +01008302/* toggle speaker-output according to the hp-jack state */
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008303static void alc883_clevo_m720_hp_automute(struct hda_codec *codec)
Jiang zhe368c7a92008-03-04 11:20:33 +01008304{
8305 unsigned int present;
8306 unsigned char bits;
8307
8308 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
8309 & AC_PINSENSE_PRESENCE;
8310 bits = present ? HDA_AMP_MUTE : 0;
8311 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8312 HDA_AMP_MUTE, bits);
8313}
8314
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008315static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
8316{
8317 unsigned int present;
8318
8319 present = snd_hda_codec_read(codec, 0x18, 0,
8320 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8321 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
8322 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8323}
8324
8325static void alc883_clevo_m720_automute(struct hda_codec *codec)
8326{
8327 alc883_clevo_m720_hp_automute(codec);
8328 alc883_clevo_m720_mic_automute(codec);
8329}
8330
8331static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01008332 unsigned int res)
8333{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008334 switch (res >> 26) {
8335 case ALC880_HP_EVENT:
8336 alc883_clevo_m720_hp_automute(codec);
8337 break;
8338 case ALC880_MIC_EVENT:
8339 alc883_clevo_m720_mic_automute(codec);
8340 break;
8341 }
Jiang zhe368c7a92008-03-04 11:20:33 +01008342}
8343
Jiang zhefb97dc62008-03-06 11:07:11 +01008344/* toggle speaker-output according to the hp-jack state */
8345static void alc883_2ch_fujitsu_pi2515_automute(struct hda_codec *codec)
8346{
8347 unsigned int present;
8348 unsigned char bits;
8349
8350 present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0)
8351 & AC_PINSENSE_PRESENCE;
8352 bits = present ? HDA_AMP_MUTE : 0;
8353 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8354 HDA_AMP_MUTE, bits);
8355}
8356
8357static void alc883_2ch_fujitsu_pi2515_unsol_event(struct hda_codec *codec,
8358 unsigned int res)
8359{
8360 if ((res >> 26) == ALC880_HP_EVENT)
8361 alc883_2ch_fujitsu_pi2515_automute(codec);
8362}
8363
Kailang Yang189609a2007-08-20 11:31:23 +02008364static void alc883_haier_w66_automute(struct hda_codec *codec)
8365{
8366 unsigned int present;
8367 unsigned char bits;
8368
8369 present = snd_hda_codec_read(codec, 0x1b, 0,
8370 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8371 bits = present ? 0x80 : 0;
8372 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8373 0x80, bits);
8374}
8375
8376static void alc883_haier_w66_unsol_event(struct hda_codec *codec,
8377 unsigned int res)
8378{
8379 if ((res >> 26) == ALC880_HP_EVENT)
8380 alc883_haier_w66_automute(codec);
8381}
8382
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008383static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
8384{
8385 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008386 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008387
8388 present = snd_hda_codec_read(codec, 0x14, 0,
8389 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008390 bits = present ? HDA_AMP_MUTE : 0;
8391 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8392 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008393}
8394
8395static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
8396{
8397 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008398 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008399
8400 present = snd_hda_codec_read(codec, 0x1b, 0,
8401 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008402 bits = present ? HDA_AMP_MUTE : 0;
8403 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8404 HDA_AMP_MUTE, bits);
8405 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8406 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008407}
8408
8409static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
8410 unsigned int res)
8411{
8412 if ((res >> 26) == ALC880_HP_EVENT)
8413 alc883_lenovo_101e_all_automute(codec);
8414 if ((res >> 26) == ALC880_FRONT_EVENT)
8415 alc883_lenovo_101e_ispeaker_automute(codec);
8416}
8417
Takashi Iwai676a9b52007-08-16 15:23:35 +02008418/* toggle speaker-output according to the hp-jack state */
8419static void alc883_acer_aspire_automute(struct hda_codec *codec)
8420{
8421 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008422
Takashi Iwai676a9b52007-08-16 15:23:35 +02008423 present = snd_hda_codec_read(codec, 0x14, 0,
8424 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8425 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8426 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8427 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8428 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8429}
8430
8431static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
8432 unsigned int res)
8433{
8434 if ((res >> 26) == ALC880_HP_EVENT)
8435 alc883_acer_aspire_automute(codec);
8436}
8437
Kailang Yangd1a991a2007-08-15 16:21:59 +02008438static struct hda_verb alc883_acer_eapd_verbs[] = {
8439 /* HP Pin: output 0 (0x0c) */
8440 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8441 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8442 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8443 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02008444 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8445 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008446 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008447 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
8448 /* eanable EAPD on medion laptop */
8449 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8450 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02008451 /* enable unsolicited event */
8452 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008453 { }
8454};
8455
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008456static void alc888_6st_dell_front_automute(struct hda_codec *codec)
8457{
8458 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008459
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008460 present = snd_hda_codec_read(codec, 0x1b, 0,
8461 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8462 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8463 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8464 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8465 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8466 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8467 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8468 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
8469 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8470}
8471
8472static void alc888_6st_dell_unsol_event(struct hda_codec *codec,
8473 unsigned int res)
8474{
8475 switch (res >> 26) {
8476 case ALC880_HP_EVENT:
Takashi Iwai939778a2009-02-05 15:57:55 +01008477 /* printk(KERN_DEBUG "hp_event\n"); */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008478 alc888_6st_dell_front_automute(codec);
8479 break;
8480 }
8481}
8482
Kailang Yange2757d52008-08-26 13:17:46 +02008483static void alc888_lenovo_sky_front_automute(struct hda_codec *codec)
8484{
8485 unsigned int mute;
8486 unsigned int present;
8487
8488 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
8489 present = snd_hda_codec_read(codec, 0x1b, 0,
8490 AC_VERB_GET_PIN_SENSE, 0);
8491 present = (present & 0x80000000) != 0;
8492 if (present) {
8493 /* mute internal speaker */
8494 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8495 HDA_AMP_MUTE, HDA_AMP_MUTE);
8496 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8497 HDA_AMP_MUTE, HDA_AMP_MUTE);
8498 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8499 HDA_AMP_MUTE, HDA_AMP_MUTE);
8500 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
8501 HDA_AMP_MUTE, HDA_AMP_MUTE);
8502 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
8503 HDA_AMP_MUTE, HDA_AMP_MUTE);
8504 } else {
8505 /* unmute internal speaker if necessary */
8506 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
8507 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8508 HDA_AMP_MUTE, mute);
8509 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8510 HDA_AMP_MUTE, mute);
8511 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8512 HDA_AMP_MUTE, mute);
8513 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
8514 HDA_AMP_MUTE, mute);
8515 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
8516 HDA_AMP_MUTE, mute);
8517 }
8518}
8519
8520static void alc883_lenovo_sky_unsol_event(struct hda_codec *codec,
8521 unsigned int res)
8522{
8523 if ((res >> 26) == ALC880_HP_EVENT)
8524 alc888_lenovo_sky_front_automute(codec);
8525}
8526
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008527/*
8528 * generic initialization of ADC, input mixers and output mixers
8529 */
8530static struct hda_verb alc883_auto_init_verbs[] = {
8531 /*
8532 * Unmute ADC0-2 and set the default input to mic-in
8533 */
8534 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8535 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8536 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8537 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8538
Takashi Iwaicb53c622007-08-10 17:21:45 +02008539 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008540 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008541 * Note: PASD motherboards uses the Line In 2 as the input for
8542 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008543 */
8544 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008545 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8546 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8547 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8548 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8549 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008550
8551 /*
8552 * Set up output mixers (0x0c - 0x0f)
8553 */
8554 /* set vol=0 to output mixers */
8555 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8556 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8557 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8558 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8559 /* set up input amps for analog loopback */
8560 /* Amp Indices: DAC = 0, mixer = 1 */
8561 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8562 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8563 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8564 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8565 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8566 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8567 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8568 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8569 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8570 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8571
8572 /* FIXME: use matrix-type input source selection */
8573 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8574 /* Input mixer1 */
8575 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8576 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8577 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008578 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008579 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
8580 /* Input mixer2 */
8581 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8582 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8583 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008584 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Andy Shevchenkoe3cde642007-12-03 16:50:58 +01008585 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008586
8587 { }
8588};
8589
Kailang Yange2757d52008-08-26 13:17:46 +02008590static struct hda_verb alc888_asus_m90v_verbs[] = {
8591 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8592 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8593 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8594 /* enable unsolicited event */
8595 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8596 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8597 { } /* end */
8598};
8599
8600static void alc883_nb_mic_automute(struct hda_codec *codec)
8601{
8602 unsigned int present;
8603
8604 present = snd_hda_codec_read(codec, 0x18, 0,
8605 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8606 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8607 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
8608 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8609 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
8610}
8611
8612static void alc883_M90V_speaker_automute(struct hda_codec *codec)
8613{
8614 unsigned int present;
8615 unsigned char bits;
8616
8617 present = snd_hda_codec_read(codec, 0x1b, 0,
8618 AC_VERB_GET_PIN_SENSE, 0)
8619 & AC_PINSENSE_PRESENCE;
8620 bits = present ? 0 : PIN_OUT;
8621 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8622 bits);
8623 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8624 bits);
8625 snd_hda_codec_write(codec, 0x16, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8626 bits);
8627}
8628
8629static void alc883_mode2_unsol_event(struct hda_codec *codec,
8630 unsigned int res)
8631{
8632 switch (res >> 26) {
8633 case ALC880_HP_EVENT:
8634 alc883_M90V_speaker_automute(codec);
8635 break;
8636 case ALC880_MIC_EVENT:
8637 alc883_nb_mic_automute(codec);
8638 break;
8639 }
8640}
8641
8642static void alc883_mode2_inithook(struct hda_codec *codec)
8643{
8644 alc883_M90V_speaker_automute(codec);
8645 alc883_nb_mic_automute(codec);
8646}
8647
8648static struct hda_verb alc888_asus_eee1601_verbs[] = {
8649 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8650 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8651 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8652 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8653 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8654 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
8655 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
8656 /* enable unsolicited event */
8657 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8658 { } /* end */
8659};
8660
8661static void alc883_eee1601_speaker_automute(struct hda_codec *codec)
8662{
8663 unsigned int present;
8664 unsigned char bits;
8665
8666 present = snd_hda_codec_read(codec, 0x14, 0,
8667 AC_VERB_GET_PIN_SENSE, 0)
8668 & AC_PINSENSE_PRESENCE;
8669 bits = present ? 0 : PIN_OUT;
8670 snd_hda_codec_write(codec, 0x1b, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8671 bits);
8672}
8673
8674static void alc883_eee1601_unsol_event(struct hda_codec *codec,
8675 unsigned int res)
8676{
8677 switch (res >> 26) {
8678 case ALC880_HP_EVENT:
8679 alc883_eee1601_speaker_automute(codec);
8680 break;
8681 }
8682}
8683
8684static void alc883_eee1601_inithook(struct hda_codec *codec)
8685{
8686 alc883_eee1601_speaker_automute(codec);
8687}
8688
Takashi Iwaicb53c622007-08-10 17:21:45 +02008689#ifdef CONFIG_SND_HDA_POWER_SAVE
8690#define alc883_loopbacks alc880_loopbacks
8691#endif
8692
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008693/* pcm configuration: identiacal with ALC880 */
8694#define alc883_pcm_analog_playback alc880_pcm_analog_playback
8695#define alc883_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +01008696#define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008697#define alc883_pcm_digital_playback alc880_pcm_digital_playback
8698#define alc883_pcm_digital_capture alc880_pcm_digital_capture
8699
8700/*
8701 * configuration and preset
8702 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008703static const char *alc883_models[ALC883_MODEL_LAST] = {
8704 [ALC883_3ST_2ch_DIG] = "3stack-dig",
8705 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
8706 [ALC883_3ST_6ch] = "3stack-6ch",
8707 [ALC883_6ST_DIG] = "6stack-dig",
8708 [ALC883_TARGA_DIG] = "targa-dig",
8709 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008710 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02008711 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008712 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008713 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02008714 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008715 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008716 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02008717 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
8718 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02008719 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02008720 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008721 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008722 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008723 [ALC883_MITAC] = "mitac",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008724 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01008725 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008726 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02008727 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Wu Fengguang3ab90932008-11-17 09:51:09 +01008728 [ALC1200_ASUS_P5Q] = "asus-p5q",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008729 [ALC883_AUTO] = "auto",
8730};
8731
8732static struct snd_pci_quirk alc883_cfg_tbl[] = {
8733 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008734 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01008735 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01008736 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008737 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
8738 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02008739 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008740 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
8741 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008742 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
8743 ALC888_ACER_ASPIRE_4930G),
Takashi Iwaib3bdb302009-02-18 13:16:26 +01008744 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC883_AUTO),
Takashi Iwai94683502009-02-13 09:31:20 +01008745 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC883_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008746 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
8747 ALC888_ACER_ASPIRE_4930G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01008748 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
8749 ALC888_ACER_ASPIRE_4930G),
Takashi Iwaidea0a502009-02-09 17:14:52 +01008750 /* default Acer */
8751 SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER),
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008752 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Tobin Davisfebe3372007-06-12 11:27:46 +02008753 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008754 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
8755 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01008756 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01008757 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03008758 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Kailang Yanga01c30c2008-10-15 11:14:58 +02008759 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008760 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01008761 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01008762 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02008763 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Travis Place97ec7102008-05-23 18:31:46 +02008764 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008765 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008766 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008767 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
8768 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02008769 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008770 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Tobin Davis57b14f22007-04-18 23:05:36 +02008771 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008772 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
8773 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
8774 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Jiang zhe4383fae2008-04-14 12:58:57 +02008775 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008776 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01008777 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008778 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
8779 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
8780 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
8781 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
8782 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
8783 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
8784 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
8785 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
8786 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008787 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
8788 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02008789 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01008790 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01008791 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01008792 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02008793 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008794 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008795 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008796 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
8797 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
Takashi Iwaidea0a502009-02-09 17:14:52 +01008798 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04008799 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008800 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02008801 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01008802 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02008803 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008804 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02008805 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02008806 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008807 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
8808 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02008809 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02008810 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01008811 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01008812 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02008813 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008814 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
8815 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008816 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Wu Fengguang4b558992009-01-12 09:18:58 +08008817 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC883_3ST_6ch_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008818 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008819 {}
8820};
8821
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08008822static hda_nid_t alc883_slave_dig_outs[] = {
8823 ALC1200_DIGOUT_NID, 0,
8824};
8825
Wu Fengguangb25c9da2009-02-06 15:02:27 +08008826static hda_nid_t alc1200_slave_dig_outs[] = {
8827 ALC883_DIGOUT_NID, 0,
8828};
8829
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008830static struct alc_config_preset alc883_presets[] = {
8831 [ALC883_3ST_2ch_DIG] = {
8832 .mixers = { alc883_3ST_2ch_mixer },
8833 .init_verbs = { alc883_init_verbs },
8834 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8835 .dac_nids = alc883_dac_nids,
8836 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008837 .dig_in_nid = ALC883_DIGIN_NID,
8838 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8839 .channel_mode = alc883_3ST_2ch_modes,
8840 .input_mux = &alc883_capture_source,
8841 },
8842 [ALC883_3ST_6ch_DIG] = {
8843 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8844 .init_verbs = { alc883_init_verbs },
8845 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8846 .dac_nids = alc883_dac_nids,
8847 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008848 .dig_in_nid = ALC883_DIGIN_NID,
8849 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8850 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008851 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008852 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008853 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008854 [ALC883_3ST_6ch] = {
8855 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8856 .init_verbs = { alc883_init_verbs },
8857 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8858 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008859 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8860 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008861 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008862 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008863 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02008864 [ALC883_3ST_6ch_INTEL] = {
8865 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
8866 .init_verbs = { alc883_init_verbs },
8867 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8868 .dac_nids = alc883_dac_nids,
8869 .dig_out_nid = ALC883_DIGOUT_NID,
8870 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08008871 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +02008872 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
8873 .channel_mode = alc883_3ST_6ch_intel_modes,
8874 .need_dac_fix = 1,
8875 .input_mux = &alc883_3stack_6ch_intel,
8876 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008877 [ALC883_6ST_DIG] = {
8878 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
8879 .init_verbs = { alc883_init_verbs },
8880 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8881 .dac_nids = alc883_dac_nids,
8882 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008883 .dig_in_nid = ALC883_DIGIN_NID,
8884 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8885 .channel_mode = alc883_sixstack_modes,
8886 .input_mux = &alc883_capture_source,
8887 },
Kailang Yangccc656c2006-10-17 12:32:26 +02008888 [ALC883_TARGA_DIG] = {
8889 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
8890 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8891 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8892 .dac_nids = alc883_dac_nids,
8893 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008894 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8895 .channel_mode = alc883_3ST_6ch_modes,
8896 .need_dac_fix = 1,
8897 .input_mux = &alc883_capture_source,
8898 .unsol_event = alc883_tagra_unsol_event,
8899 .init_hook = alc883_tagra_automute,
8900 },
8901 [ALC883_TARGA_2ch_DIG] = {
8902 .mixers = { alc883_tagra_2ch_mixer},
8903 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8904 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8905 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008906 .adc_nids = alc883_adc_nids_alt,
8907 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangccc656c2006-10-17 12:32:26 +02008908 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008909 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8910 .channel_mode = alc883_3ST_2ch_modes,
8911 .input_mux = &alc883_capture_source,
8912 .unsol_event = alc883_tagra_unsol_event,
8913 .init_hook = alc883_tagra_automute,
8914 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008915 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008916 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008917 /* On TravelMate laptops, GPIO 0 enables the internal speaker
8918 * and the headphone jack. Turn this on and rely on the
8919 * standard mute methods whenever the user wants to turn
8920 * these outputs off.
8921 */
8922 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
8923 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8924 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008925 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8926 .channel_mode = alc883_3ST_2ch_modes,
8927 .input_mux = &alc883_capture_source,
8928 },
Tobin Davis2880a862007-08-07 11:50:26 +02008929 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008930 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02008931 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02008932 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8933 .dac_nids = alc883_dac_nids,
8934 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02008935 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8936 .channel_mode = alc883_3ST_2ch_modes,
8937 .input_mux = &alc883_capture_source,
Takashi Iwai676a9b52007-08-16 15:23:35 +02008938 .unsol_event = alc883_acer_aspire_unsol_event,
8939 .init_hook = alc883_acer_aspire_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +02008940 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008941 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008942 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008943 alc883_chmode_mixer },
8944 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
8945 alc888_acer_aspire_4930g_verbs },
8946 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8947 .dac_nids = alc883_dac_nids,
8948 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
8949 .adc_nids = alc883_adc_nids_rev,
8950 .capsrc_nids = alc883_capsrc_nids_rev,
8951 .dig_out_nid = ALC883_DIGOUT_NID,
8952 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8953 .channel_mode = alc883_3ST_6ch_modes,
8954 .need_dac_fix = 1,
8955 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008956 ARRAY_SIZE(alc888_2_capture_sources),
8957 .input_mux = alc888_2_capture_sources,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008958 .unsol_event = alc888_acer_aspire_4930g_unsol_event,
8959 .init_hook = alc888_acer_aspire_4930g_automute,
8960 },
Tobin Davisc07584c2006-10-13 12:32:16 +02008961 [ALC883_MEDION] = {
8962 .mixers = { alc883_fivestack_mixer,
8963 alc883_chmode_mixer },
8964 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008965 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02008966 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8967 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008968 .adc_nids = alc883_adc_nids_alt,
8969 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Tobin Davisc07584c2006-10-13 12:32:16 +02008970 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8971 .channel_mode = alc883_sixstack_modes,
8972 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008973 },
Kailang Yang272a5272007-05-14 11:00:38 +02008974 [ALC883_MEDION_MD2] = {
8975 .mixers = { alc883_medion_md2_mixer},
8976 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
8977 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8978 .dac_nids = alc883_dac_nids,
8979 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008980 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8981 .channel_mode = alc883_3ST_2ch_modes,
8982 .input_mux = &alc883_capture_source,
8983 .unsol_event = alc883_medion_md2_unsol_event,
8984 .init_hook = alc883_medion_md2_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +02008985 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008986 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008987 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008988 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
8989 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8990 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008991 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8992 .channel_mode = alc883_3ST_2ch_modes,
8993 .input_mux = &alc883_capture_source,
8994 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008995 [ALC883_CLEVO_M720] = {
8996 .mixers = { alc883_clevo_m720_mixer },
8997 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01008998 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8999 .dac_nids = alc883_dac_nids,
9000 .dig_out_nid = ALC883_DIGOUT_NID,
9001 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9002 .channel_mode = alc883_3ST_2ch_modes,
9003 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009004 .unsol_event = alc883_clevo_m720_unsol_event,
9005 .init_hook = alc883_clevo_m720_automute,
Jiang zhe368c7a92008-03-04 11:20:33 +01009006 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009007 [ALC883_LENOVO_101E_2ch] = {
9008 .mixers = { alc883_lenovo_101e_2ch_mixer},
9009 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
9010 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9011 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009012 .adc_nids = alc883_adc_nids_alt,
9013 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009014 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9015 .channel_mode = alc883_3ST_2ch_modes,
9016 .input_mux = &alc883_lenovo_101e_capture_source,
9017 .unsol_event = alc883_lenovo_101e_unsol_event,
9018 .init_hook = alc883_lenovo_101e_all_automute,
9019 },
Kailang Yang272a5272007-05-14 11:00:38 +02009020 [ALC883_LENOVO_NB0763] = {
9021 .mixers = { alc883_lenovo_nb0763_mixer },
9022 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
9023 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9024 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02009025 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9026 .channel_mode = alc883_3ST_2ch_modes,
9027 .need_dac_fix = 1,
9028 .input_mux = &alc883_lenovo_nb0763_capture_source,
9029 .unsol_event = alc883_medion_md2_unsol_event,
9030 .init_hook = alc883_medion_md2_automute,
9031 },
9032 [ALC888_LENOVO_MS7195_DIG] = {
9033 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9034 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
9035 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9036 .dac_nids = alc883_dac_nids,
9037 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009038 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9039 .channel_mode = alc883_3ST_6ch_modes,
9040 .need_dac_fix = 1,
9041 .input_mux = &alc883_capture_source,
9042 .unsol_event = alc883_lenovo_ms7195_unsol_event,
9043 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02009044 },
9045 [ALC883_HAIER_W66] = {
9046 .mixers = { alc883_tagra_2ch_mixer},
9047 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
9048 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9049 .dac_nids = alc883_dac_nids,
9050 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02009051 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9052 .channel_mode = alc883_3ST_2ch_modes,
9053 .input_mux = &alc883_capture_source,
9054 .unsol_event = alc883_haier_w66_unsol_event,
9055 .init_hook = alc883_haier_w66_automute,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009056 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009057 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009058 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009059 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009060 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9061 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009062 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
9063 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009064 .need_dac_fix = 1,
9065 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009066 .unsol_event = alc888_3st_hp_unsol_event,
9067 .init_hook = alc888_3st_hp_front_automute,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009068 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009069 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01009070 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009071 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
9072 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9073 .dac_nids = alc883_dac_nids,
9074 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009075 .dig_in_nid = ALC883_DIGIN_NID,
9076 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9077 .channel_mode = alc883_sixstack_modes,
9078 .input_mux = &alc883_capture_source,
9079 .unsol_event = alc888_6st_dell_unsol_event,
9080 .init_hook = alc888_6st_dell_front_automute,
9081 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009082 [ALC883_MITAC] = {
9083 .mixers = { alc883_mitac_mixer },
9084 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
9085 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9086 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009087 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9088 .channel_mode = alc883_3ST_2ch_modes,
9089 .input_mux = &alc883_capture_source,
9090 .unsol_event = alc883_mitac_unsol_event,
9091 .init_hook = alc883_mitac_automute,
9092 },
Jiang zhefb97dc62008-03-06 11:07:11 +01009093 [ALC883_FUJITSU_PI2515] = {
9094 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
9095 .init_verbs = { alc883_init_verbs,
9096 alc883_2ch_fujitsu_pi2515_verbs},
9097 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9098 .dac_nids = alc883_dac_nids,
9099 .dig_out_nid = ALC883_DIGOUT_NID,
9100 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9101 .channel_mode = alc883_3ST_2ch_modes,
9102 .input_mux = &alc883_fujitsu_pi2515_capture_source,
9103 .unsol_event = alc883_2ch_fujitsu_pi2515_unsol_event,
9104 .init_hook = alc883_2ch_fujitsu_pi2515_automute,
9105 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009106 [ALC888_FUJITSU_XA3530] = {
9107 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
9108 .init_verbs = { alc883_init_verbs,
9109 alc888_fujitsu_xa3530_verbs },
9110 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9111 .dac_nids = alc883_dac_nids,
9112 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9113 .adc_nids = alc883_adc_nids_rev,
9114 .capsrc_nids = alc883_capsrc_nids_rev,
9115 .dig_out_nid = ALC883_DIGOUT_NID,
9116 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
9117 .channel_mode = alc888_4ST_8ch_intel_modes,
9118 .num_mux_defs =
9119 ARRAY_SIZE(alc888_2_capture_sources),
9120 .input_mux = alc888_2_capture_sources,
9121 .unsol_event = alc888_fujitsu_xa3530_unsol_event,
9122 .init_hook = alc888_fujitsu_xa3530_automute,
9123 },
Kailang Yange2757d52008-08-26 13:17:46 +02009124 [ALC888_LENOVO_SKY] = {
9125 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
9126 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
9127 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9128 .dac_nids = alc883_dac_nids,
9129 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +02009130 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9131 .channel_mode = alc883_sixstack_modes,
9132 .need_dac_fix = 1,
9133 .input_mux = &alc883_lenovo_sky_capture_source,
9134 .unsol_event = alc883_lenovo_sky_unsol_event,
9135 .init_hook = alc888_lenovo_sky_front_automute,
9136 },
9137 [ALC888_ASUS_M90V] = {
9138 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9139 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
9140 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9141 .dac_nids = alc883_dac_nids,
9142 .dig_out_nid = ALC883_DIGOUT_NID,
9143 .dig_in_nid = ALC883_DIGIN_NID,
9144 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9145 .channel_mode = alc883_3ST_6ch_modes,
9146 .need_dac_fix = 1,
9147 .input_mux = &alc883_fujitsu_pi2515_capture_source,
9148 .unsol_event = alc883_mode2_unsol_event,
9149 .init_hook = alc883_mode2_inithook,
9150 },
9151 [ALC888_ASUS_EEE1601] = {
9152 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009153 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +02009154 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
9155 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9156 .dac_nids = alc883_dac_nids,
9157 .dig_out_nid = ALC883_DIGOUT_NID,
9158 .dig_in_nid = ALC883_DIGIN_NID,
9159 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9160 .channel_mode = alc883_3ST_2ch_modes,
9161 .need_dac_fix = 1,
9162 .input_mux = &alc883_asus_eee1601_capture_source,
9163 .unsol_event = alc883_eee1601_unsol_event,
9164 .init_hook = alc883_eee1601_inithook,
9165 },
Wu Fengguang3ab90932008-11-17 09:51:09 +01009166 [ALC1200_ASUS_P5Q] = {
9167 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9168 .init_verbs = { alc883_init_verbs },
9169 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9170 .dac_nids = alc883_dac_nids,
9171 .dig_out_nid = ALC1200_DIGOUT_NID,
9172 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +08009173 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +01009174 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9175 .channel_mode = alc883_sixstack_modes,
9176 .input_mux = &alc883_capture_source,
9177 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009178};
9179
9180
9181/*
9182 * BIOS auto configuration
9183 */
9184static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
9185 hda_nid_t nid, int pin_type,
9186 int dac_idx)
9187{
9188 /* set as output */
9189 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009190 int idx;
9191
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009192 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009193 if (spec->multiout.dac_nids[dac_idx] == 0x25)
9194 idx = 4;
9195 else
9196 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009197 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
9198
9199}
9200
9201static void alc883_auto_init_multi_out(struct hda_codec *codec)
9202{
9203 struct alc_spec *spec = codec->spec;
9204 int i;
9205
9206 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009207 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009208 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009209 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009210 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009211 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009212 }
9213}
9214
9215static void alc883_auto_init_hp_out(struct hda_codec *codec)
9216{
9217 struct alc_spec *spec = codec->spec;
9218 hda_nid_t pin;
9219
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009220 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009221 if (pin) /* connect to front */
9222 /* use dac 0 */
9223 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009224 pin = spec->autocfg.speaker_pins[0];
9225 if (pin)
9226 alc883_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009227}
9228
9229#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
9230#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
9231
9232static void alc883_auto_init_analog_input(struct hda_codec *codec)
9233{
9234 struct alc_spec *spec = codec->spec;
9235 int i;
9236
9237 for (i = 0; i < AUTO_PIN_LAST; i++) {
9238 hda_nid_t nid = spec->autocfg.input_pins[i];
9239 if (alc883_is_input_pin(nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01009240 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01009241 if (nid != ALC883_PIN_CD_NID &&
9242 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009243 snd_hda_codec_write(codec, nid, 0,
9244 AC_VERB_SET_AMP_GAIN_MUTE,
9245 AMP_OUT_MUTE);
9246 }
9247 }
9248}
9249
Takashi Iwaif511b012008-08-15 16:46:42 +02009250#define alc883_auto_init_input_src alc882_auto_init_input_src
9251
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009252/* almost identical with ALC880 parser... */
9253static int alc883_parse_auto_config(struct hda_codec *codec)
9254{
9255 struct alc_spec *spec = codec->spec;
9256 int err = alc880_parse_auto_config(codec);
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009257 struct auto_pin_cfg *cfg = &spec->autocfg;
9258 int i;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009259
9260 if (err < 0)
9261 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02009262 else if (!err)
9263 return 0; /* no config found */
9264
9265 err = alc_auto_add_mic_boost(codec);
9266 if (err < 0)
9267 return err;
9268
9269 /* hack - override the init verbs */
9270 spec->init_verbs[0] = alc883_auto_init_verbs;
Takashi Iwai776e1842007-08-29 15:07:11 +02009271
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009272 /* setup input_mux for ALC889 */
9273 if (codec->vendor_id == 0x10ec0889) {
9274 /* digital-mic input pin is excluded in alc880_auto_create..()
9275 * because it's under 0x18
9276 */
9277 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
9278 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
9279 struct hda_input_mux *imux = &spec->private_imux[0];
9280 for (i = 1; i < 3; i++)
9281 memcpy(&spec->private_imux[i],
9282 &spec->private_imux[0],
9283 sizeof(spec->private_imux[0]));
9284 imux->items[imux->num_items].label = "Int DMic";
9285 imux->items[imux->num_items].index = 0x0b;
9286 imux->num_items++;
9287 spec->num_mux_defs = 3;
9288 spec->input_mux = spec->private_imux;
9289 }
9290 }
9291
Takashi Iwai776e1842007-08-29 15:07:11 +02009292 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009293}
9294
9295/* additional initialization for auto-configuration model */
9296static void alc883_auto_init(struct hda_codec *codec)
9297{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009298 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009299 alc883_auto_init_multi_out(codec);
9300 alc883_auto_init_hp_out(codec);
9301 alc883_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02009302 alc883_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009303 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02009304 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009305}
9306
9307static int patch_alc883(struct hda_codec *codec)
9308{
9309 struct alc_spec *spec;
9310 int err, board_config;
9311
9312 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
9313 if (spec == NULL)
9314 return -ENOMEM;
9315
9316 codec->spec = spec;
9317
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02009318 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
9319
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009320 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
9321 alc883_models,
9322 alc883_cfg_tbl);
9323 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009324 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
9325 "trying auto-probe from BIOS...\n");
9326 board_config = ALC883_AUTO;
9327 }
9328
9329 if (board_config == ALC883_AUTO) {
9330 /* automatic parse from the BIOS config */
9331 err = alc883_parse_auto_config(codec);
9332 if (err < 0) {
9333 alc_free(codec);
9334 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009335 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009336 printk(KERN_INFO
9337 "hda_codec: Cannot set up configuration "
9338 "from BIOS. Using base mode...\n");
9339 board_config = ALC883_3ST_2ch_DIG;
9340 }
9341 }
9342
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09009343 err = snd_hda_attach_beep_device(codec, 0x1);
9344 if (err < 0) {
9345 alc_free(codec);
9346 return err;
9347 }
9348
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009349 if (board_config != ALC883_AUTO)
9350 setup_preset(spec, &alc883_presets[board_config]);
9351
Kailang Yang2f893282008-05-27 12:14:47 +02009352 switch (codec->vendor_id) {
9353 case 0x10ec0888:
Kailang Yang44426082008-10-15 11:18:05 +02009354 if (codec->revision_id == 0x100101) {
9355 spec->stream_name_analog = "ALC1200 Analog";
9356 spec->stream_name_digital = "ALC1200 Digital";
9357 } else {
9358 spec->stream_name_analog = "ALC888 Analog";
9359 spec->stream_name_digital = "ALC888 Digital";
9360 }
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009361 if (!spec->num_adc_nids) {
9362 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
9363 spec->adc_nids = alc883_adc_nids;
9364 }
9365 if (!spec->capsrc_nids)
9366 spec->capsrc_nids = alc883_capsrc_nids;
9367 spec->capture_style = CAPT_MIX; /* matrix-style capture */
Takashi Iwai4a79ba32009-04-22 16:31:35 +02009368 spec->init_amp = ALC_INIT_DEFAULT; /* always initialize */
Kailang Yang2f893282008-05-27 12:14:47 +02009369 break;
9370 case 0x10ec0889:
9371 spec->stream_name_analog = "ALC889 Analog";
9372 spec->stream_name_digital = "ALC889 Digital";
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009373 if (!spec->num_adc_nids) {
9374 spec->num_adc_nids = ARRAY_SIZE(alc889_adc_nids);
9375 spec->adc_nids = alc889_adc_nids;
9376 }
9377 if (!spec->capsrc_nids)
9378 spec->capsrc_nids = alc889_capsrc_nids;
9379 spec->capture_style = CAPT_1MUX_MIX; /* 1mux/Nmix-style
9380 capture */
Kailang Yang2f893282008-05-27 12:14:47 +02009381 break;
9382 default:
9383 spec->stream_name_analog = "ALC883 Analog";
9384 spec->stream_name_digital = "ALC883 Digital";
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009385 if (!spec->num_adc_nids) {
9386 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
9387 spec->adc_nids = alc883_adc_nids;
9388 }
9389 if (!spec->capsrc_nids)
9390 spec->capsrc_nids = alc883_capsrc_nids;
9391 spec->capture_style = CAPT_MIX; /* matrix-style capture */
Kailang Yang2f893282008-05-27 12:14:47 +02009392 break;
9393 }
9394
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009395 spec->stream_analog_playback = &alc883_pcm_analog_playback;
9396 spec->stream_analog_capture = &alc883_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01009397 spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009398
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009399 spec->stream_digital_playback = &alc883_pcm_digital_playback;
9400 spec->stream_digital_capture = &alc883_pcm_digital_capture;
9401
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009402 if (!spec->cap_mixer)
9403 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01009404 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009405
Takashi Iwai2134ea42008-01-10 16:53:55 +01009406 spec->vmaster_nid = 0x0c;
9407
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009408 codec->patch_ops = alc_patch_ops;
9409 if (board_config == ALC883_AUTO)
9410 spec->init_hook = alc883_auto_init;
Kailang Yangf9423e72008-05-27 12:32:25 +02009411
Takashi Iwaicb53c622007-08-10 17:21:45 +02009412#ifdef CONFIG_SND_HDA_POWER_SAVE
9413 if (!spec->loopback.amplist)
9414 spec->loopback.amplist = alc883_loopbacks;
9415#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01009416 codec->proc_widget_hook = print_realtek_coef;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009417
9418 return 0;
9419}
9420
9421/*
Kailang Yangdf694da2005-12-05 19:42:22 +01009422 * ALC262 support
9423 */
9424
9425#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
9426#define ALC262_DIGIN_NID ALC880_DIGIN_NID
9427
9428#define alc262_dac_nids alc260_dac_nids
9429#define alc262_adc_nids alc882_adc_nids
9430#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +01009431#define alc262_capsrc_nids alc882_capsrc_nids
9432#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +01009433
9434#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01009435#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01009436
Kailang Yang4e555fe2008-08-26 13:05:55 +02009437static hda_nid_t alc262_dmic_adc_nids[1] = {
9438 /* ADC0 */
9439 0x09
9440};
9441
9442static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
9443
Kailang Yangdf694da2005-12-05 19:42:22 +01009444static struct snd_kcontrol_new alc262_base_mixer[] = {
9445 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9446 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9447 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9448 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9449 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9450 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9451 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9452 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009453 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009454 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9455 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009456 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009457 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
9458 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9459 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
9460 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009461 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01009462};
9463
Kailang Yangccc656c2006-10-17 12:32:26 +02009464static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
9465 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9466 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9467 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9468 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9469 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9470 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9471 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9472 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009473 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009474 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9475 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009476 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009477 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
9478 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9479 { } /* end */
9480};
9481
Takashi Iwaice875f02008-01-28 18:17:43 +01009482/* update HP, line and mono-out pins according to the master switch */
9483static void alc262_hp_master_update(struct hda_codec *codec)
9484{
9485 struct alc_spec *spec = codec->spec;
9486 int val = spec->master_sw;
9487
9488 /* HP & line-out */
9489 snd_hda_codec_write_cache(codec, 0x1b, 0,
9490 AC_VERB_SET_PIN_WIDGET_CONTROL,
9491 val ? PIN_HP : 0);
9492 snd_hda_codec_write_cache(codec, 0x15, 0,
9493 AC_VERB_SET_PIN_WIDGET_CONTROL,
9494 val ? PIN_HP : 0);
9495 /* mono (speaker) depending on the HP jack sense */
9496 val = val && !spec->jack_present;
9497 snd_hda_codec_write_cache(codec, 0x16, 0,
9498 AC_VERB_SET_PIN_WIDGET_CONTROL,
9499 val ? PIN_OUT : 0);
9500}
9501
9502static void alc262_hp_bpc_automute(struct hda_codec *codec)
9503{
9504 struct alc_spec *spec = codec->spec;
9505 unsigned int presence;
9506 presence = snd_hda_codec_read(codec, 0x1b, 0,
9507 AC_VERB_GET_PIN_SENSE, 0);
9508 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9509 alc262_hp_master_update(codec);
9510}
9511
9512static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
9513{
9514 if ((res >> 26) != ALC880_HP_EVENT)
9515 return;
9516 alc262_hp_bpc_automute(codec);
9517}
9518
9519static void alc262_hp_wildwest_automute(struct hda_codec *codec)
9520{
9521 struct alc_spec *spec = codec->spec;
9522 unsigned int presence;
9523 presence = snd_hda_codec_read(codec, 0x15, 0,
9524 AC_VERB_GET_PIN_SENSE, 0);
9525 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9526 alc262_hp_master_update(codec);
9527}
9528
9529static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
9530 unsigned int res)
9531{
9532 if ((res >> 26) != ALC880_HP_EVENT)
9533 return;
9534 alc262_hp_wildwest_automute(codec);
9535}
9536
9537static int alc262_hp_master_sw_get(struct snd_kcontrol *kcontrol,
9538 struct snd_ctl_elem_value *ucontrol)
9539{
9540 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9541 struct alc_spec *spec = codec->spec;
9542 *ucontrol->value.integer.value = spec->master_sw;
9543 return 0;
9544}
9545
9546static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
9547 struct snd_ctl_elem_value *ucontrol)
9548{
9549 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9550 struct alc_spec *spec = codec->spec;
9551 int val = !!*ucontrol->value.integer.value;
9552
9553 if (val == spec->master_sw)
9554 return 0;
9555 spec->master_sw = val;
9556 alc262_hp_master_update(codec);
9557 return 1;
9558}
9559
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009560static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01009561 {
9562 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9563 .name = "Master Playback Switch",
9564 .info = snd_ctl_boolean_mono_info,
9565 .get = alc262_hp_master_sw_get,
9566 .put = alc262_hp_master_sw_put,
9567 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009568 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9569 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9570 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009571 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9572 HDA_OUTPUT),
9573 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9574 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009575 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9576 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009577 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009578 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9579 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009580 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009581 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9582 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9583 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9584 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009585 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
9586 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
9587 { } /* end */
9588};
9589
Kailang Yangcd7509a2007-01-26 18:33:17 +01009590static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01009591 {
9592 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9593 .name = "Master Playback Switch",
9594 .info = snd_ctl_boolean_mono_info,
9595 .get = alc262_hp_master_sw_get,
9596 .put = alc262_hp_master_sw_put,
9597 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01009598 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9599 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9600 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9601 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009602 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9603 HDA_OUTPUT),
9604 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9605 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009606 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
9607 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009608 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009609 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9610 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9611 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9612 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009613 { } /* end */
9614};
9615
9616static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
9617 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9618 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009619 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009620 { } /* end */
9621};
9622
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009623/* mute/unmute internal speaker according to the hp jack and mute state */
9624static void alc262_hp_t5735_automute(struct hda_codec *codec, int force)
9625{
9626 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009627
9628 if (force || !spec->sense_updated) {
9629 unsigned int present;
9630 present = snd_hda_codec_read(codec, 0x15, 0,
9631 AC_VERB_GET_PIN_SENSE, 0);
Takashi Iwai4bb26132008-01-28 18:12:42 +01009632 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009633 spec->sense_updated = 1;
9634 }
Takashi Iwai4bb26132008-01-28 18:12:42 +01009635 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, HDA_AMP_MUTE,
9636 spec->jack_present ? HDA_AMP_MUTE : 0);
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009637}
9638
9639static void alc262_hp_t5735_unsol_event(struct hda_codec *codec,
9640 unsigned int res)
9641{
9642 if ((res >> 26) != ALC880_HP_EVENT)
9643 return;
9644 alc262_hp_t5735_automute(codec, 1);
9645}
9646
9647static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
9648{
9649 alc262_hp_t5735_automute(codec, 1);
9650}
9651
9652static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +01009653 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9654 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009655 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9656 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9657 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9658 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9659 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9660 { } /* end */
9661};
9662
9663static struct hda_verb alc262_hp_t5735_verbs[] = {
9664 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9665 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9666
9667 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9668 { }
9669};
9670
Kailang Yang8c427222008-01-10 13:03:59 +01009671static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +01009672 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9673 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01009674 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
9675 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +01009676 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9677 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9678 { } /* end */
9679};
9680
9681static struct hda_verb alc262_hp_rp5700_verbs[] = {
9682 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9683 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9684 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9685 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9686 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9687 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9688 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9689 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9690 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9691 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9692 {}
9693};
9694
9695static struct hda_input_mux alc262_hp_rp5700_capture_source = {
9696 .num_items = 1,
9697 .items = {
9698 { "Line", 0x1 },
9699 },
9700};
9701
Takashi Iwai0724ea22007-08-23 00:31:43 +02009702/* bind hp and internal speaker mute (with plug check) */
9703static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
9704 struct snd_ctl_elem_value *ucontrol)
9705{
9706 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9707 long *valp = ucontrol->value.integer.value;
9708 int change;
9709
9710 /* change hp mute */
9711 change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
9712 HDA_AMP_MUTE,
9713 valp[0] ? 0 : HDA_AMP_MUTE);
9714 change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
9715 HDA_AMP_MUTE,
9716 valp[1] ? 0 : HDA_AMP_MUTE);
9717 if (change) {
9718 /* change speaker according to HP jack state */
9719 struct alc_spec *spec = codec->spec;
9720 unsigned int mute;
9721 if (spec->jack_present)
9722 mute = HDA_AMP_MUTE;
9723 else
9724 mute = snd_hda_codec_amp_read(codec, 0x15, 0,
9725 HDA_OUTPUT, 0);
9726 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9727 HDA_AMP_MUTE, mute);
9728 }
9729 return change;
9730}
Takashi Iwai5b319542007-07-26 11:49:22 +02009731
Kailang Yang272a5272007-05-14 11:00:38 +02009732static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +02009733 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9734 {
9735 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9736 .name = "Master Playback Switch",
9737 .info = snd_hda_mixer_amp_switch_info,
9738 .get = snd_hda_mixer_amp_switch_get,
9739 .put = alc262_sony_master_sw_put,
9740 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
9741 },
Kailang Yang272a5272007-05-14 11:00:38 +02009742 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9743 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9744 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9745 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9746 { } /* end */
9747};
9748
Kailang Yang83c34212007-07-05 11:43:05 +02009749static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
9750 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9751 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9752 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9753 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9754 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9755 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9756 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9757 { } /* end */
9758};
Kailang Yang272a5272007-05-14 11:00:38 +02009759
Tony Vroonba340e82009-02-02 19:01:30 +00009760static struct snd_kcontrol_new alc262_tyan_mixer[] = {
9761 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9762 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
9763 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
9764 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
9765 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9766 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9767 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9768 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9769 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9770 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9771 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9772 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9773 { } /* end */
9774};
9775
9776static struct hda_verb alc262_tyan_verbs[] = {
9777 /* Headphone automute */
9778 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9779 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9780 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9781
9782 /* P11 AUX_IN, white 4-pin connector */
9783 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9784 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
9785 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
9786 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
9787
9788 {}
9789};
9790
9791/* unsolicited event for HP jack sensing */
9792static void alc262_tyan_automute(struct hda_codec *codec)
9793{
9794 unsigned int mute;
9795 unsigned int present;
9796
9797 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9798 present = snd_hda_codec_read(codec, 0x1b, 0,
9799 AC_VERB_GET_PIN_SENSE, 0);
9800 present = (present & 0x80000000) != 0;
9801 if (present) {
9802 /* mute line output on ATX panel */
9803 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9804 HDA_AMP_MUTE, HDA_AMP_MUTE);
9805 } else {
9806 /* unmute line output if necessary */
9807 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
9808 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9809 HDA_AMP_MUTE, mute);
9810 }
9811}
9812
9813static void alc262_tyan_unsol_event(struct hda_codec *codec,
9814 unsigned int res)
9815{
9816 if ((res >> 26) != ALC880_HP_EVENT)
9817 return;
9818 alc262_tyan_automute(codec);
9819}
9820
Kailang Yangdf694da2005-12-05 19:42:22 +01009821#define alc262_capture_mixer alc882_capture_mixer
9822#define alc262_capture_alt_mixer alc882_capture_alt_mixer
9823
9824/*
9825 * generic initialization of ADC, input mixers and output mixers
9826 */
9827static struct hda_verb alc262_init_verbs[] = {
9828 /*
9829 * Unmute ADC0-2 and set the default input to mic-in
9830 */
9831 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9832 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9833 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9834 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9835 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9836 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9837
Takashi Iwaicb53c622007-08-10 17:21:45 +02009838 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01009839 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009840 * Note: PASD motherboards uses the Line In 2 as the input for
9841 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01009842 */
9843 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009844 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9845 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9846 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9847 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9848 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009849
9850 /*
9851 * Set up output mixers (0x0c - 0x0e)
9852 */
9853 /* set vol=0 to output mixers */
9854 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9855 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9856 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9857 /* set up input amps for analog loopback */
9858 /* Amp Indices: DAC = 0, mixer = 1 */
9859 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9860 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9861 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9862 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9863 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9864 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9865
9866 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9867 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9868 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9869 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9870 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9871 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9872
9873 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9874 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9875 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9876 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9877 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +02009878
Kailang Yangdf694da2005-12-05 19:42:22 +01009879 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9880 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +02009881
Kailang Yangdf694da2005-12-05 19:42:22 +01009882 /* FIXME: use matrix-type input source selection */
9883 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9884 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9885 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9886 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9887 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9888 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9889 /* Input mixer2 */
9890 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9891 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9892 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9893 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9894 /* Input mixer3 */
9895 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9896 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9897 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009898 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +01009899
9900 { }
9901};
9902
Kailang Yang4e555fe2008-08-26 13:05:55 +02009903static struct hda_verb alc262_eapd_verbs[] = {
9904 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
9905 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
9906 { }
9907};
9908
Kailang Yangccc656c2006-10-17 12:32:26 +02009909static struct hda_verb alc262_hippo_unsol_verbs[] = {
9910 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9911 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9912 {}
9913};
9914
9915static struct hda_verb alc262_hippo1_unsol_verbs[] = {
9916 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9917 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9918 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9919
9920 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9921 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9922 {}
9923};
9924
Kailang Yang272a5272007-05-14 11:00:38 +02009925static struct hda_verb alc262_sony_unsol_verbs[] = {
9926 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9927 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9928 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
9929
9930 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9931 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +09009932 {}
Kailang Yang272a5272007-05-14 11:00:38 +02009933};
9934
Kailang Yang4e555fe2008-08-26 13:05:55 +02009935static struct hda_input_mux alc262_dmic_capture_source = {
9936 .num_items = 2,
9937 .items = {
9938 { "Int DMic", 0x9 },
9939 { "Mic", 0x0 },
9940 },
9941};
9942
9943static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
9944 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9945 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9946 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9947 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9948 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +02009949 { } /* end */
9950};
9951
9952static struct hda_verb alc262_toshiba_s06_verbs[] = {
9953 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9954 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9955 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9956 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9957 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
9958 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9959 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
9960 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9961 {}
9962};
9963
9964static void alc262_dmic_automute(struct hda_codec *codec)
9965{
9966 unsigned int present;
9967
9968 present = snd_hda_codec_read(codec, 0x18, 0,
9969 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9970 snd_hda_codec_write(codec, 0x22, 0,
9971 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x09);
9972}
9973
9974/* toggle speaker-output according to the hp-jack state */
9975static void alc262_toshiba_s06_speaker_automute(struct hda_codec *codec)
9976{
9977 unsigned int present;
9978 unsigned char bits;
9979
9980 present = snd_hda_codec_read(codec, 0x15, 0,
9981 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9982 bits = present ? 0 : PIN_OUT;
9983 snd_hda_codec_write(codec, 0x14, 0,
9984 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
9985}
9986
9987
9988
9989/* unsolicited event for HP jack sensing */
9990static void alc262_toshiba_s06_unsol_event(struct hda_codec *codec,
9991 unsigned int res)
9992{
9993 if ((res >> 26) == ALC880_HP_EVENT)
9994 alc262_toshiba_s06_speaker_automute(codec);
9995 if ((res >> 26) == ALC880_MIC_EVENT)
9996 alc262_dmic_automute(codec);
9997
9998}
9999
10000static void alc262_toshiba_s06_init_hook(struct hda_codec *codec)
10001{
10002 alc262_toshiba_s06_speaker_automute(codec);
10003 alc262_dmic_automute(codec);
10004}
10005
Kailang Yangccc656c2006-10-17 12:32:26 +020010006/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai5b319542007-07-26 11:49:22 +020010007static void alc262_hippo_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +020010008{
10009 struct alc_spec *spec = codec->spec;
10010 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +020010011 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +020010012
Takashi Iwai5b319542007-07-26 11:49:22 +020010013 /* need to execute and sync at first */
10014 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
10015 present = snd_hda_codec_read(codec, 0x15, 0,
10016 AC_VERB_GET_PIN_SENSE, 0);
10017 spec->jack_present = (present & 0x80000000) != 0;
Kailang Yangccc656c2006-10-17 12:32:26 +020010018 if (spec->jack_present) {
10019 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +020010020 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10021 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +020010022 } else {
10023 /* unmute internal speaker if necessary */
10024 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +020010025 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10026 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +020010027 }
10028}
10029
10030/* unsolicited event for HP jack sensing */
10031static void alc262_hippo_unsol_event(struct hda_codec *codec,
10032 unsigned int res)
10033{
10034 if ((res >> 26) != ALC880_HP_EVENT)
10035 return;
Takashi Iwai5b319542007-07-26 11:49:22 +020010036 alc262_hippo_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +020010037}
10038
Takashi Iwai5b319542007-07-26 11:49:22 +020010039static void alc262_hippo1_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +020010040{
Kailang Yangccc656c2006-10-17 12:32:26 +020010041 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +020010042 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +020010043
Takashi Iwai5b319542007-07-26 11:49:22 +020010044 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10045 present = snd_hda_codec_read(codec, 0x1b, 0,
10046 AC_VERB_GET_PIN_SENSE, 0);
10047 present = (present & 0x80000000) != 0;
10048 if (present) {
Kailang Yangccc656c2006-10-17 12:32:26 +020010049 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +020010050 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10051 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +020010052 } else {
10053 /* unmute internal speaker if necessary */
10054 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +020010055 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10056 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +020010057 }
10058}
10059
10060/* unsolicited event for HP jack sensing */
10061static void alc262_hippo1_unsol_event(struct hda_codec *codec,
10062 unsigned int res)
10063{
10064 if ((res >> 26) != ALC880_HP_EVENT)
10065 return;
Takashi Iwai5b319542007-07-26 11:49:22 +020010066 alc262_hippo1_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +020010067}
10068
Takashi Iwai834be882006-03-01 14:16:17 +010010069/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010070 * nec model
10071 * 0x15 = headphone
10072 * 0x16 = internal speaker
10073 * 0x18 = external mic
10074 */
10075
10076static struct snd_kcontrol_new alc262_nec_mixer[] = {
10077 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
10078 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
10079
10080 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10081 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10082 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10083
10084 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10085 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10086 { } /* end */
10087};
10088
10089static struct hda_verb alc262_nec_verbs[] = {
10090 /* Unmute Speaker */
10091 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10092
10093 /* Headphone */
10094 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10095 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10096
10097 /* External mic to headphone */
10098 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10099 /* External mic to speaker */
10100 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10101 {}
10102};
10103
10104/*
Takashi Iwai834be882006-03-01 14:16:17 +010010105 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010010106 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
10107 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010010108 */
10109
10110#define ALC_HP_EVENT 0x37
10111
10112static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
10113 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10114 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010010115 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10116 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010010117 {}
10118};
10119
Jiang zhe0e31daf2008-03-20 12:12:39 +010010120static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
10121 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10122 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10123 {}
10124};
10125
Takashi Iwai834be882006-03-01 14:16:17 +010010126static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010127 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010010128 .items = {
10129 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010130 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010010131 { "CD", 0x4 },
10132 },
10133};
10134
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010135static struct hda_input_mux alc262_HP_capture_source = {
10136 .num_items = 5,
10137 .items = {
10138 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020010139 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010140 { "Line", 0x2 },
10141 { "CD", 0x4 },
10142 { "AUX IN", 0x6 },
10143 },
10144};
10145
zhejiangaccbe492007-08-31 12:36:05 +020010146static struct hda_input_mux alc262_HP_D7000_capture_source = {
10147 .num_items = 4,
10148 .items = {
10149 { "Mic", 0x0 },
10150 { "Front Mic", 0x2 },
10151 { "Line", 0x1 },
10152 { "CD", 0x4 },
10153 },
10154};
10155
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010156/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010010157static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
10158{
10159 struct alc_spec *spec = codec->spec;
10160 unsigned int mute;
10161
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010162 if (force || !spec->sense_updated) {
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010163 unsigned int present;
Takashi Iwai834be882006-03-01 14:16:17 +010010164 /* need to execute and sync at first */
10165 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010166 /* check laptop HP jack */
10167 present = snd_hda_codec_read(codec, 0x14, 0,
10168 AC_VERB_GET_PIN_SENSE, 0);
10169 /* need to execute and sync at first */
10170 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10171 /* check docking HP jack */
10172 present |= snd_hda_codec_read(codec, 0x1b, 0,
10173 AC_VERB_GET_PIN_SENSE, 0);
10174 if (present & AC_PINSENSE_PRESENCE)
10175 spec->jack_present = 1;
10176 else
10177 spec->jack_present = 0;
Takashi Iwai834be882006-03-01 14:16:17 +010010178 spec->sense_updated = 1;
10179 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010180 /* unmute internal speaker only if both HPs are unplugged and
10181 * master switch is on
10182 */
10183 if (spec->jack_present)
10184 mute = HDA_AMP_MUTE;
10185 else
Takashi Iwai834be882006-03-01 14:16:17 +010010186 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010187 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10188 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010010189}
10190
10191/* unsolicited event for HP jack sensing */
10192static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
10193 unsigned int res)
10194{
10195 if ((res >> 26) != ALC_HP_EVENT)
10196 return;
10197 alc262_fujitsu_automute(codec, 1);
10198}
10199
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010200static void alc262_fujitsu_init_hook(struct hda_codec *codec)
10201{
10202 alc262_fujitsu_automute(codec, 1);
10203}
10204
Takashi Iwai834be882006-03-01 14:16:17 +010010205/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020010206static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
10207 .ops = &snd_hda_bind_vol,
10208 .values = {
10209 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
10210 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
10211 0
10212 },
10213};
Takashi Iwai834be882006-03-01 14:16:17 +010010214
Jiang zhe0e31daf2008-03-20 12:12:39 +010010215/* mute/unmute internal speaker according to the hp jack and mute state */
10216static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
10217{
10218 struct alc_spec *spec = codec->spec;
10219 unsigned int mute;
10220
10221 if (force || !spec->sense_updated) {
10222 unsigned int present_int_hp;
10223 /* need to execute and sync at first */
10224 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10225 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
10226 AC_VERB_GET_PIN_SENSE, 0);
10227 spec->jack_present = (present_int_hp & 0x80000000) != 0;
10228 spec->sense_updated = 1;
10229 }
10230 if (spec->jack_present) {
10231 /* mute internal speaker */
10232 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10233 HDA_AMP_MUTE, HDA_AMP_MUTE);
10234 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10235 HDA_AMP_MUTE, HDA_AMP_MUTE);
10236 } else {
10237 /* unmute internal speaker if necessary */
10238 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
10239 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10240 HDA_AMP_MUTE, mute);
10241 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10242 HDA_AMP_MUTE, mute);
10243 }
10244}
10245
10246/* unsolicited event for HP jack sensing */
10247static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
10248 unsigned int res)
10249{
10250 if ((res >> 26) != ALC_HP_EVENT)
10251 return;
10252 alc262_lenovo_3000_automute(codec, 1);
10253}
10254
Takashi Iwai834be882006-03-01 14:16:17 +010010255/* bind hp and internal speaker mute (with plug check) */
10256static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
10257 struct snd_ctl_elem_value *ucontrol)
10258{
10259 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10260 long *valp = ucontrol->value.integer.value;
10261 int change;
10262
Tony Vroon5d9fab22008-03-14 17:09:18 +010010263 change = snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10264 HDA_AMP_MUTE,
10265 valp ? 0 : HDA_AMP_MUTE);
10266 change |= snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
10267 HDA_AMP_MUTE,
10268 valp ? 0 : HDA_AMP_MUTE);
10269
Takashi Iwai82beb8f2007-08-10 17:09:26 +020010270 if (change)
10271 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010010272 return change;
10273}
10274
10275static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020010276 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010010277 {
10278 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10279 .name = "Master Playback Switch",
10280 .info = snd_hda_mixer_amp_switch_info,
10281 .get = snd_hda_mixer_amp_switch_get,
10282 .put = alc262_fujitsu_master_sw_put,
10283 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10284 },
10285 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10286 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10287 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10288 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10289 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010290 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10291 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10292 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010010293 { } /* end */
10294};
10295
Jiang zhe0e31daf2008-03-20 12:12:39 +010010296/* bind hp and internal speaker mute (with plug check) */
10297static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
10298 struct snd_ctl_elem_value *ucontrol)
10299{
10300 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10301 long *valp = ucontrol->value.integer.value;
10302 int change;
10303
10304 change = snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
10305 HDA_AMP_MUTE,
10306 valp ? 0 : HDA_AMP_MUTE);
10307
10308 if (change)
10309 alc262_lenovo_3000_automute(codec, 0);
10310 return change;
10311}
10312
10313static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
10314 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10315 {
10316 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10317 .name = "Master Playback Switch",
10318 .info = snd_hda_mixer_amp_switch_info,
10319 .get = snd_hda_mixer_amp_switch_get,
10320 .put = alc262_lenovo_3000_master_sw_put,
10321 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
10322 },
10323 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10324 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10325 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10326 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10327 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10328 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10329 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10330 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10331 { } /* end */
10332};
10333
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010334static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
10335 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10336 {
10337 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10338 .name = "Master Playback Switch",
10339 .info = snd_hda_mixer_amp_switch_info,
10340 .get = snd_hda_mixer_amp_switch_get,
10341 .put = alc262_sony_master_sw_put,
10342 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
10343 },
10344 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10345 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10346 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10347 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10348 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10349 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10350 { } /* end */
10351};
10352
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010353/* additional init verbs for Benq laptops */
10354static struct hda_verb alc262_EAPD_verbs[] = {
10355 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10356 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
10357 {}
10358};
10359
Kailang Yang83c34212007-07-05 11:43:05 +020010360static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
10361 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10362 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10363
10364 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10365 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
10366 {}
10367};
10368
Tobin Davisf651b502007-10-26 12:40:47 +020010369/* Samsung Q1 Ultra Vista model setup */
10370static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010371 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10372 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010373 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10374 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10375 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010376 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010377 { } /* end */
10378};
10379
10380static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010381 /* output mixer */
10382 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10383 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10384 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10385 /* speaker */
10386 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10387 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10388 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10389 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10390 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020010391 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010392 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10393 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10394 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10395 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10396 /* internal mic */
10397 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10398 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10399 /* ADC, choose mic */
10400 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10401 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10402 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10403 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10404 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10405 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10406 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10407 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10408 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
10409 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020010410 {}
10411};
10412
Tobin Davisf651b502007-10-26 12:40:47 +020010413/* mute/unmute internal speaker according to the hp jack and mute state */
10414static void alc262_ultra_automute(struct hda_codec *codec)
10415{
10416 struct alc_spec *spec = codec->spec;
10417 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020010418
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010419 mute = 0;
10420 /* auto-mute only when HP is used as HP */
10421 if (!spec->cur_mux[0]) {
10422 unsigned int present;
10423 /* need to execute and sync at first */
10424 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
10425 present = snd_hda_codec_read(codec, 0x15, 0,
10426 AC_VERB_GET_PIN_SENSE, 0);
10427 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
10428 if (spec->jack_present)
10429 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020010430 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010431 /* mute/unmute internal speaker */
10432 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10433 HDA_AMP_MUTE, mute);
10434 /* mute/unmute HP */
10435 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10436 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020010437}
10438
10439/* unsolicited event for HP jack sensing */
10440static void alc262_ultra_unsol_event(struct hda_codec *codec,
10441 unsigned int res)
10442{
10443 if ((res >> 26) != ALC880_HP_EVENT)
10444 return;
10445 alc262_ultra_automute(codec);
10446}
10447
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010448static struct hda_input_mux alc262_ultra_capture_source = {
10449 .num_items = 2,
10450 .items = {
10451 { "Mic", 0x1 },
10452 { "Headphone", 0x7 },
10453 },
10454};
10455
10456static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
10457 struct snd_ctl_elem_value *ucontrol)
10458{
10459 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10460 struct alc_spec *spec = codec->spec;
10461 int ret;
10462
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010463 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010464 if (!ret)
10465 return 0;
10466 /* reprogram the HP pin as mic or HP according to the input source */
10467 snd_hda_codec_write_cache(codec, 0x15, 0,
10468 AC_VERB_SET_PIN_WIDGET_CONTROL,
10469 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
10470 alc262_ultra_automute(codec); /* mute/unmute HP */
10471 return ret;
10472}
10473
10474static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
10475 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10476 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10477 {
10478 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10479 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010480 .info = alc_mux_enum_info,
10481 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010482 .put = alc262_ultra_mux_enum_put,
10483 },
10484 { } /* end */
10485};
10486
Kailang Yangdf694da2005-12-05 19:42:22 +010010487/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010488static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
10489 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010010490{
10491 hda_nid_t nid;
10492 int err;
10493
10494 spec->multiout.num_dacs = 1; /* only use one dac */
10495 spec->multiout.dac_nids = spec->private_dac_nids;
10496 spec->multiout.dac_nids[0] = 2;
10497
10498 nid = cfg->line_out_pins[0];
10499 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010500 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10501 "Front Playback Volume",
10502 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
10503 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010504 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010505 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10506 "Front Playback Switch",
10507 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
10508 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010509 return err;
10510 }
10511
Takashi Iwai82bc9552006-03-21 11:24:42 +010010512 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010513 if (nid) {
10514 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010515 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10516 "Speaker Playback Volume",
10517 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10518 HDA_OUTPUT));
10519 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010520 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010521 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10522 "Speaker Playback Switch",
10523 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10524 HDA_OUTPUT));
10525 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010526 return err;
10527 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010528 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10529 "Speaker Playback Switch",
10530 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10531 HDA_OUTPUT));
10532 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010533 return err;
10534 }
10535 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +020010536 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010537 if (nid) {
10538 /* spec->multiout.hp_nid = 2; */
10539 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010540 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10541 "Headphone Playback Volume",
10542 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10543 HDA_OUTPUT));
10544 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010545 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010546 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10547 "Headphone Playback Switch",
10548 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10549 HDA_OUTPUT));
10550 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010551 return err;
10552 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010553 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10554 "Headphone Playback Switch",
10555 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10556 HDA_OUTPUT));
10557 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010558 return err;
10559 }
10560 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010561 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010010562}
10563
10564/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010565#define alc262_auto_create_analog_input_ctls \
10566 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010010567
10568/*
10569 * generic initialization of ADC, input mixers and output mixers
10570 */
10571static struct hda_verb alc262_volume_init_verbs[] = {
10572 /*
10573 * Unmute ADC0-2 and set the default input to mic-in
10574 */
10575 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10576 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10577 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10578 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10579 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10580 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10581
Takashi Iwaicb53c622007-08-10 17:21:45 +020010582 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010583 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010584 * Note: PASD motherboards uses the Line In 2 as the input for
10585 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010586 */
10587 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010588 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10589 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10590 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10591 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10592 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010593
10594 /*
10595 * Set up output mixers (0x0c - 0x0f)
10596 */
10597 /* set vol=0 to output mixers */
10598 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10599 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10600 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020010601
Kailang Yangdf694da2005-12-05 19:42:22 +010010602 /* set up input amps for analog loopback */
10603 /* Amp Indices: DAC = 0, mixer = 1 */
10604 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10605 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10606 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10607 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10608 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10609 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10610
10611 /* FIXME: use matrix-type input source selection */
10612 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10613 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10614 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10615 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10616 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10617 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10618 /* Input mixer2 */
10619 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10620 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10621 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10622 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10623 /* Input mixer3 */
10624 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10625 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10626 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10627 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10628
10629 { }
10630};
10631
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010632static struct hda_verb alc262_HP_BPC_init_verbs[] = {
10633 /*
10634 * Unmute ADC0-2 and set the default input to mic-in
10635 */
10636 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10637 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10638 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10639 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10640 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10641 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10642
Takashi Iwaicb53c622007-08-10 17:21:45 +020010643 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010644 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010645 * Note: PASD motherboards uses the Line In 2 as the input for
10646 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010647 */
10648 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010649 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10650 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10651 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10652 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10653 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10654 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10655 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020010656
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010657 /*
10658 * Set up output mixers (0x0c - 0x0e)
10659 */
10660 /* set vol=0 to output mixers */
10661 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10662 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10663 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10664
10665 /* set up input amps for analog loopback */
10666 /* Amp Indices: DAC = 0, mixer = 1 */
10667 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10668 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10669 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10670 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10671 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10672 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10673
Takashi Iwaice875f02008-01-28 18:17:43 +010010674 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010675 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10676 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10677
10678 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10679 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10680
10681 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10682 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10683
10684 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10685 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10686 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10687 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10688 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10689
10690 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10691 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10692 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10693 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10694 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10695 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10696
10697
10698 /* FIXME: use matrix-type input source selection */
10699 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10700 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10701 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10702 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10703 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10704 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10705 /* Input mixer2 */
10706 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10707 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10708 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10709 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10710 /* Input mixer3 */
10711 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10712 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10713 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10714 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10715
Takashi Iwaice875f02008-01-28 18:17:43 +010010716 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10717
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010718 { }
10719};
10720
Kailang Yangcd7509a2007-01-26 18:33:17 +010010721static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
10722 /*
10723 * Unmute ADC0-2 and set the default input to mic-in
10724 */
10725 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10726 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10727 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10728 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10729 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10730 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10731
Takashi Iwaicb53c622007-08-10 17:21:45 +020010732 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010010733 * mixer widget
10734 * Note: PASD motherboards uses the Line In 2 as the input for front
10735 * panel mic (mic 2)
10736 */
10737 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010738 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10739 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10740 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10741 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10742 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10743 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10744 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10745 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010010746 /*
10747 * Set up output mixers (0x0c - 0x0e)
10748 */
10749 /* set vol=0 to output mixers */
10750 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10751 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10752 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10753
10754 /* set up input amps for analog loopback */
10755 /* Amp Indices: DAC = 0, mixer = 1 */
10756 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10757 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10758 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10759 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10760 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10761 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10762
10763
10764 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
10765 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
10766 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
10767 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
10768 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10769 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
10770 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
10771
10772 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10773 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10774
10775 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10776 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
10777
10778 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
10779 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10780 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10781 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10782 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10783 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10784
10785 /* FIXME: use matrix-type input source selection */
10786 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10787 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10788 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
10789 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
10790 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
10791 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
10792 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
10793 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10794 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
10795 /* Input mixer2 */
10796 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10797 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10798 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10799 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10800 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10801 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10802 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10803 /* Input mixer3 */
10804 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10805 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10806 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10807 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10808 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10809 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10810 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10811
Takashi Iwaice875f02008-01-28 18:17:43 +010010812 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10813
Kailang Yangcd7509a2007-01-26 18:33:17 +010010814 { }
10815};
10816
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010817static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
10818
10819 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
10820 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10821 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
10822
10823 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
10824 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10825 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10826 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10827
10828 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
10829 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10830 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10831 {}
10832};
10833
10834
Takashi Iwaicb53c622007-08-10 17:21:45 +020010835#ifdef CONFIG_SND_HDA_POWER_SAVE
10836#define alc262_loopbacks alc880_loopbacks
10837#endif
10838
Kailang Yangdf694da2005-12-05 19:42:22 +010010839/* pcm configuration: identiacal with ALC880 */
10840#define alc262_pcm_analog_playback alc880_pcm_analog_playback
10841#define alc262_pcm_analog_capture alc880_pcm_analog_capture
10842#define alc262_pcm_digital_playback alc880_pcm_digital_playback
10843#define alc262_pcm_digital_capture alc880_pcm_digital_capture
10844
10845/*
10846 * BIOS auto configuration
10847 */
10848static int alc262_parse_auto_config(struct hda_codec *codec)
10849{
10850 struct alc_spec *spec = codec->spec;
10851 int err;
10852 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
10853
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010854 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10855 alc262_ignore);
10856 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010857 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010858 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010010859 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010860 spec->multiout.max_channels = 2;
10861 spec->no_analog = 1;
10862 goto dig_only;
10863 }
Kailang Yangdf694da2005-12-05 19:42:22 +010010864 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010865 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010866 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
10867 if (err < 0)
10868 return err;
10869 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
10870 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010871 return err;
10872
10873 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10874
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010875 dig_only:
Takashi Iwai0852d7a2009-02-11 11:35:15 +010010876 if (spec->autocfg.dig_outs) {
Kailang Yangdf694da2005-12-05 19:42:22 +010010877 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
Takashi Iwai0852d7a2009-02-11 11:35:15 +010010878 spec->dig_out_type = spec->autocfg.dig_out_type[0];
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010879 }
Kailang Yangdf694da2005-12-05 19:42:22 +010010880 if (spec->autocfg.dig_in_pin)
10881 spec->dig_in_nid = ALC262_DIGIN_NID;
10882
Takashi Iwai603c4012008-07-30 15:01:44 +020010883 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010010884 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010010885
Takashi Iwaid88897e2008-10-31 15:01:37 +010010886 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020010887 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020010888 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010889
Takashi Iwai776e1842007-08-29 15:07:11 +020010890 err = alc_auto_add_mic_boost(codec);
10891 if (err < 0)
10892 return err;
10893
Takashi Iwai4a79ba32009-04-22 16:31:35 +020010894 alc_ssid_check(codec, 0x15, 0x14, 0x1b);
10895
Kailang Yangdf694da2005-12-05 19:42:22 +010010896 return 1;
10897}
10898
10899#define alc262_auto_init_multi_out alc882_auto_init_multi_out
10900#define alc262_auto_init_hp_out alc882_auto_init_hp_out
10901#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020010902#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010010903
10904
10905/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010906static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010010907{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010908 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010010909 alc262_auto_init_multi_out(codec);
10910 alc262_auto_init_hp_out(codec);
10911 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020010912 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010913 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020010914 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010010915}
10916
10917/*
10918 * configuration and preset
10919 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010920static const char *alc262_models[ALC262_MODEL_LAST] = {
10921 [ALC262_BASIC] = "basic",
10922 [ALC262_HIPPO] = "hippo",
10923 [ALC262_HIPPO_1] = "hippo_1",
10924 [ALC262_FUJITSU] = "fujitsu",
10925 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010010926 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010010927 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010010928 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010929 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020010930 [ALC262_BENQ_T31] = "benq-t31",
10931 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020010932 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010933 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020010934 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010010935 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010936 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000010937 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010938 [ALC262_AUTO] = "auto",
10939};
10940
10941static struct snd_pci_quirk alc262_cfg_tbl[] = {
10942 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010943 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010010944 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
10945 ALC262_HP_BPC),
10946 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
10947 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010010948 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
10949 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010950 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010951 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010952 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010953 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010954 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010955 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010956 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010957 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010958 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
10959 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
10960 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010961 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
10962 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010010963 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010964 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010965 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010966 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010010967 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwaif872a912009-02-26 00:57:01 +010010968 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
10969 ALC262_SONY_ASSAMD),
Akio Idehara36ca6e12008-06-09 22:57:40 +090010970 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010971 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020010972 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010973 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010010974 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000010975 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010010976 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
10977 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110010978 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010010979 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010980 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020010981 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010982 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010010983 {}
10984};
10985
10986static struct alc_config_preset alc262_presets[] = {
10987 [ALC262_BASIC] = {
10988 .mixers = { alc262_base_mixer },
10989 .init_verbs = { alc262_init_verbs },
10990 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10991 .dac_nids = alc262_dac_nids,
10992 .hp_nid = 0x03,
10993 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10994 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010010995 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010010996 },
Kailang Yangccc656c2006-10-17 12:32:26 +020010997 [ALC262_HIPPO] = {
10998 .mixers = { alc262_base_mixer },
10999 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
11000 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11001 .dac_nids = alc262_dac_nids,
11002 .hp_nid = 0x03,
11003 .dig_out_nid = ALC262_DIGOUT_NID,
11004 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11005 .channel_mode = alc262_modes,
11006 .input_mux = &alc262_capture_source,
11007 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020011008 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020011009 },
11010 [ALC262_HIPPO_1] = {
11011 .mixers = { alc262_hippo1_mixer },
11012 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
11013 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11014 .dac_nids = alc262_dac_nids,
11015 .hp_nid = 0x02,
11016 .dig_out_nid = ALC262_DIGOUT_NID,
11017 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11018 .channel_mode = alc262_modes,
11019 .input_mux = &alc262_capture_source,
11020 .unsol_event = alc262_hippo1_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020011021 .init_hook = alc262_hippo1_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020011022 },
Takashi Iwai834be882006-03-01 14:16:17 +010011023 [ALC262_FUJITSU] = {
11024 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011025 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11026 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010011027 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11028 .dac_nids = alc262_dac_nids,
11029 .hp_nid = 0x03,
11030 .dig_out_nid = ALC262_DIGOUT_NID,
11031 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11032 .channel_mode = alc262_modes,
11033 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011034 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011035 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010011036 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011037 [ALC262_HP_BPC] = {
11038 .mixers = { alc262_HP_BPC_mixer },
11039 .init_verbs = { alc262_HP_BPC_init_verbs },
11040 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11041 .dac_nids = alc262_dac_nids,
11042 .hp_nid = 0x03,
11043 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11044 .channel_mode = alc262_modes,
11045 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011046 .unsol_event = alc262_hp_bpc_unsol_event,
11047 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011048 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011049 [ALC262_HP_BPC_D7000_WF] = {
11050 .mixers = { alc262_HP_BPC_WildWest_mixer },
11051 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11052 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11053 .dac_nids = alc262_dac_nids,
11054 .hp_nid = 0x03,
11055 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11056 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011057 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011058 .unsol_event = alc262_hp_wildwest_unsol_event,
11059 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011060 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011061 [ALC262_HP_BPC_D7000_WL] = {
11062 .mixers = { alc262_HP_BPC_WildWest_mixer,
11063 alc262_HP_BPC_WildWest_option_mixer },
11064 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11065 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11066 .dac_nids = alc262_dac_nids,
11067 .hp_nid = 0x03,
11068 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11069 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011070 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011071 .unsol_event = alc262_hp_wildwest_unsol_event,
11072 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011073 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011074 [ALC262_HP_TC_T5735] = {
11075 .mixers = { alc262_hp_t5735_mixer },
11076 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
11077 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11078 .dac_nids = alc262_dac_nids,
11079 .hp_nid = 0x03,
11080 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11081 .channel_mode = alc262_modes,
11082 .input_mux = &alc262_capture_source,
11083 .unsol_event = alc262_hp_t5735_unsol_event,
11084 .init_hook = alc262_hp_t5735_init_hook,
Kailang Yang8c427222008-01-10 13:03:59 +010011085 },
11086 [ALC262_HP_RP5700] = {
11087 .mixers = { alc262_hp_rp5700_mixer },
11088 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
11089 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11090 .dac_nids = alc262_dac_nids,
11091 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11092 .channel_mode = alc262_modes,
11093 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011094 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011095 [ALC262_BENQ_ED8] = {
11096 .mixers = { alc262_base_mixer },
11097 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
11098 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11099 .dac_nids = alc262_dac_nids,
11100 .hp_nid = 0x03,
11101 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11102 .channel_mode = alc262_modes,
11103 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011104 },
Kailang Yang272a5272007-05-14 11:00:38 +020011105 [ALC262_SONY_ASSAMD] = {
11106 .mixers = { alc262_sony_mixer },
11107 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
11108 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11109 .dac_nids = alc262_dac_nids,
11110 .hp_nid = 0x02,
11111 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11112 .channel_mode = alc262_modes,
11113 .input_mux = &alc262_capture_source,
11114 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020011115 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020011116 },
11117 [ALC262_BENQ_T31] = {
11118 .mixers = { alc262_benq_t31_mixer },
11119 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
11120 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11121 .dac_nids = alc262_dac_nids,
11122 .hp_nid = 0x03,
11123 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11124 .channel_mode = alc262_modes,
11125 .input_mux = &alc262_capture_source,
11126 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020011127 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020011128 },
Tobin Davisf651b502007-10-26 12:40:47 +020011129 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011130 .mixers = { alc262_ultra_mixer },
11131 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011132 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020011133 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11134 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020011135 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11136 .channel_mode = alc262_modes,
11137 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011138 .adc_nids = alc262_adc_nids, /* ADC0 */
11139 .capsrc_nids = alc262_capsrc_nids,
11140 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020011141 .unsol_event = alc262_ultra_unsol_event,
11142 .init_hook = alc262_ultra_automute,
11143 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010011144 [ALC262_LENOVO_3000] = {
11145 .mixers = { alc262_lenovo_3000_mixer },
11146 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11147 alc262_lenovo_3000_unsol_verbs },
11148 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11149 .dac_nids = alc262_dac_nids,
11150 .hp_nid = 0x03,
11151 .dig_out_nid = ALC262_DIGOUT_NID,
11152 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11153 .channel_mode = alc262_modes,
11154 .input_mux = &alc262_fujitsu_capture_source,
11155 .unsol_event = alc262_lenovo_3000_unsol_event,
11156 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011157 [ALC262_NEC] = {
11158 .mixers = { alc262_nec_mixer },
11159 .init_verbs = { alc262_nec_verbs },
11160 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11161 .dac_nids = alc262_dac_nids,
11162 .hp_nid = 0x03,
11163 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11164 .channel_mode = alc262_modes,
11165 .input_mux = &alc262_capture_source,
11166 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020011167 [ALC262_TOSHIBA_S06] = {
11168 .mixers = { alc262_toshiba_s06_mixer },
11169 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
11170 alc262_eapd_verbs },
11171 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11172 .capsrc_nids = alc262_dmic_capsrc_nids,
11173 .dac_nids = alc262_dac_nids,
11174 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
11175 .dig_out_nid = ALC262_DIGOUT_NID,
11176 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11177 .channel_mode = alc262_modes,
11178 .input_mux = &alc262_dmic_capture_source,
11179 .unsol_event = alc262_toshiba_s06_unsol_event,
11180 .init_hook = alc262_toshiba_s06_init_hook,
11181 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011182 [ALC262_TOSHIBA_RX1] = {
11183 .mixers = { alc262_toshiba_rx1_mixer },
11184 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
11185 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11186 .dac_nids = alc262_dac_nids,
11187 .hp_nid = 0x03,
11188 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11189 .channel_mode = alc262_modes,
11190 .input_mux = &alc262_capture_source,
11191 .unsol_event = alc262_hippo_unsol_event,
11192 .init_hook = alc262_hippo_automute,
11193 },
Tony Vroonba340e82009-02-02 19:01:30 +000011194 [ALC262_TYAN] = {
11195 .mixers = { alc262_tyan_mixer },
11196 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
11197 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11198 .dac_nids = alc262_dac_nids,
11199 .hp_nid = 0x02,
11200 .dig_out_nid = ALC262_DIGOUT_NID,
11201 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11202 .channel_mode = alc262_modes,
11203 .input_mux = &alc262_capture_source,
11204 .unsol_event = alc262_tyan_unsol_event,
11205 .init_hook = alc262_tyan_automute,
11206 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011207};
11208
11209static int patch_alc262(struct hda_codec *codec)
11210{
11211 struct alc_spec *spec;
11212 int board_config;
11213 int err;
11214
Robert P. J. Daydc041e02006-12-19 14:44:15 +010011215 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010011216 if (spec == NULL)
11217 return -ENOMEM;
11218
11219 codec->spec = spec;
11220#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011221 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
11222 * under-run
11223 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011224 {
11225 int tmp;
11226 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11227 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
11228 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11229 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
11230 }
11231#endif
11232
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020011233 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
11234
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011235 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
11236 alc262_models,
11237 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010011238
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011239 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011240 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
11241 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011242 board_config = ALC262_AUTO;
11243 }
11244
11245 if (board_config == ALC262_AUTO) {
11246 /* automatic parse from the BIOS config */
11247 err = alc262_parse_auto_config(codec);
11248 if (err < 0) {
11249 alc_free(codec);
11250 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011251 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011252 printk(KERN_INFO
11253 "hda_codec: Cannot set up configuration "
11254 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011255 board_config = ALC262_BASIC;
11256 }
11257 }
11258
Takashi Iwai07eba612009-02-19 08:06:35 +010011259 if (!spec->no_analog) {
11260 err = snd_hda_attach_beep_device(codec, 0x1);
11261 if (err < 0) {
11262 alc_free(codec);
11263 return err;
11264 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090011265 }
11266
Kailang Yangdf694da2005-12-05 19:42:22 +010011267 if (board_config != ALC262_AUTO)
11268 setup_preset(spec, &alc262_presets[board_config]);
11269
11270 spec->stream_name_analog = "ALC262 Analog";
11271 spec->stream_analog_playback = &alc262_pcm_analog_playback;
11272 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020011273
Kailang Yangdf694da2005-12-05 19:42:22 +010011274 spec->stream_name_digital = "ALC262 Digital";
11275 spec->stream_digital_playback = &alc262_pcm_digital_playback;
11276 spec->stream_digital_capture = &alc262_pcm_digital_capture;
11277
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011278 spec->capture_style = CAPT_MIX;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011279 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011280 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +010011281 unsigned int wcap = get_wcaps(codec, 0x07);
11282
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011283 /* get type */
11284 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +010011285 if (wcap != AC_WID_AUD_IN) {
11286 spec->adc_nids = alc262_adc_nids_alt;
11287 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwai88c71a92008-02-14 17:27:17 +010011288 spec->capsrc_nids = alc262_capsrc_nids_alt;
Kailang Yangdf694da2005-12-05 19:42:22 +010011289 } else {
11290 spec->adc_nids = alc262_adc_nids;
11291 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
Takashi Iwai88c71a92008-02-14 17:27:17 +010011292 spec->capsrc_nids = alc262_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010011293 }
11294 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011295 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011296 set_capture_mixer(spec);
Takashi Iwai07eba612009-02-19 08:06:35 +010011297 if (!spec->no_analog)
11298 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010011299
Takashi Iwai2134ea42008-01-10 16:53:55 +010011300 spec->vmaster_nid = 0x0c;
11301
Kailang Yangdf694da2005-12-05 19:42:22 +010011302 codec->patch_ops = alc_patch_ops;
11303 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011304 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011305#ifdef CONFIG_SND_HDA_POWER_SAVE
11306 if (!spec->loopback.amplist)
11307 spec->loopback.amplist = alc262_loopbacks;
11308#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010011309 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020011310
Kailang Yangdf694da2005-12-05 19:42:22 +010011311 return 0;
11312}
11313
Kailang Yangdf694da2005-12-05 19:42:22 +010011314/*
Kailang Yanga361d842007-06-05 12:30:55 +020011315 * ALC268 channel source setting (2 channel)
11316 */
11317#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
11318#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020011319
Kailang Yanga361d842007-06-05 12:30:55 +020011320static hda_nid_t alc268_dac_nids[2] = {
11321 /* front, hp */
11322 0x02, 0x03
11323};
11324
11325static hda_nid_t alc268_adc_nids[2] = {
11326 /* ADC0-1 */
11327 0x08, 0x07
11328};
11329
11330static hda_nid_t alc268_adc_nids_alt[1] = {
11331 /* ADC0 */
11332 0x08
11333};
11334
Takashi Iwaie1406342008-02-11 18:32:32 +010011335static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
11336
Kailang Yanga361d842007-06-05 12:30:55 +020011337static struct snd_kcontrol_new alc268_base_mixer[] = {
11338 /* output mixer control */
11339 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11340 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11341 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11342 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011343 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11344 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11345 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020011346 { }
11347};
11348
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011349/* bind Beep switches of both NID 0x0f and 0x10 */
11350static struct hda_bind_ctls alc268_bind_beep_sw = {
11351 .ops = &snd_hda_bind_sw,
11352 .values = {
11353 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
11354 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
11355 0
11356 },
11357};
11358
11359static struct snd_kcontrol_new alc268_beep_mixer[] = {
11360 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
11361 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
11362 { }
11363};
11364
Kailang Yangd1a991a2007-08-15 16:21:59 +020011365static struct hda_verb alc268_eapd_verbs[] = {
11366 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11367 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11368 { }
11369};
11370
Takashi Iwaid2738092007-08-16 14:59:45 +020011371/* Toshiba specific */
11372#define alc268_toshiba_automute alc262_hippo_automute
11373
11374static struct hda_verb alc268_toshiba_verbs[] = {
11375 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11376 { } /* end */
11377};
11378
Kailang Yang8ef355d2008-08-26 13:10:22 +020011379static struct hda_input_mux alc268_acer_lc_capture_source = {
11380 .num_items = 2,
11381 .items = {
11382 { "i-Mic", 0x6 },
11383 { "E-Mic", 0x0 },
11384 },
11385};
11386
Takashi Iwaid2738092007-08-16 14:59:45 +020011387/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020011388/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020011389static struct hda_bind_ctls alc268_acer_bind_master_vol = {
11390 .ops = &snd_hda_bind_vol,
11391 .values = {
11392 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
11393 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
11394 0
11395 },
11396};
11397
Takashi Iwai889c4392007-08-23 18:56:52 +020011398/* mute/unmute internal speaker according to the hp jack and mute state */
11399static void alc268_acer_automute(struct hda_codec *codec, int force)
11400{
11401 struct alc_spec *spec = codec->spec;
11402 unsigned int mute;
11403
11404 if (force || !spec->sense_updated) {
11405 unsigned int present;
11406 present = snd_hda_codec_read(codec, 0x14, 0,
11407 AC_VERB_GET_PIN_SENSE, 0);
11408 spec->jack_present = (present & 0x80000000) != 0;
11409 spec->sense_updated = 1;
11410 }
11411 if (spec->jack_present)
11412 mute = HDA_AMP_MUTE; /* mute internal speaker */
11413 else /* unmute internal speaker if necessary */
11414 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
11415 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11416 HDA_AMP_MUTE, mute);
11417}
11418
11419
11420/* bind hp and internal speaker mute (with plug check) */
11421static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
11422 struct snd_ctl_elem_value *ucontrol)
11423{
11424 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11425 long *valp = ucontrol->value.integer.value;
11426 int change;
11427
11428 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
11429 HDA_AMP_MUTE,
11430 valp[0] ? 0 : HDA_AMP_MUTE);
11431 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
11432 HDA_AMP_MUTE,
11433 valp[1] ? 0 : HDA_AMP_MUTE);
11434 if (change)
11435 alc268_acer_automute(codec, 0);
11436 return change;
11437}
Takashi Iwaid2738092007-08-16 14:59:45 +020011438
Kailang Yang8ef355d2008-08-26 13:10:22 +020011439static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
11440 /* output mixer control */
11441 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11442 {
11443 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11444 .name = "Master Playback Switch",
11445 .info = snd_hda_mixer_amp_switch_info,
11446 .get = snd_hda_mixer_amp_switch_get,
11447 .put = alc268_acer_master_sw_put,
11448 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11449 },
11450 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
11451 { }
11452};
11453
Takashi Iwaid2738092007-08-16 14:59:45 +020011454static struct snd_kcontrol_new alc268_acer_mixer[] = {
11455 /* output mixer control */
11456 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11457 {
11458 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11459 .name = "Master Playback Switch",
11460 .info = snd_hda_mixer_amp_switch_info,
11461 .get = snd_hda_mixer_amp_switch_get,
11462 .put = alc268_acer_master_sw_put,
11463 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11464 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011465 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11466 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11467 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020011468 { }
11469};
11470
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011471static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
11472 /* output mixer control */
11473 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11474 {
11475 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11476 .name = "Master Playback Switch",
11477 .info = snd_hda_mixer_amp_switch_info,
11478 .get = snd_hda_mixer_amp_switch_get,
11479 .put = alc268_acer_master_sw_put,
11480 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11481 },
11482 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11483 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11484 { }
11485};
11486
Kailang Yang8ef355d2008-08-26 13:10:22 +020011487static struct hda_verb alc268_acer_aspire_one_verbs[] = {
11488 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11489 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11490 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11491 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11492 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
11493 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
11494 { }
11495};
11496
Takashi Iwaid2738092007-08-16 14:59:45 +020011497static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011498 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
11499 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020011500 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11501 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011502 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11503 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020011504 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11505 { }
11506};
11507
11508/* unsolicited event for HP jack sensing */
11509static void alc268_toshiba_unsol_event(struct hda_codec *codec,
11510 unsigned int res)
11511{
Takashi Iwai889c4392007-08-23 18:56:52 +020011512 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020011513 return;
11514 alc268_toshiba_automute(codec);
11515}
11516
11517static void alc268_acer_unsol_event(struct hda_codec *codec,
11518 unsigned int res)
11519{
Takashi Iwai889c4392007-08-23 18:56:52 +020011520 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020011521 return;
11522 alc268_acer_automute(codec, 1);
11523}
11524
Takashi Iwai889c4392007-08-23 18:56:52 +020011525static void alc268_acer_init_hook(struct hda_codec *codec)
11526{
11527 alc268_acer_automute(codec, 1);
11528}
11529
Kailang Yang8ef355d2008-08-26 13:10:22 +020011530/* toggle speaker-output according to the hp-jack state */
11531static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
11532{
11533 unsigned int present;
11534 unsigned char bits;
11535
11536 present = snd_hda_codec_read(codec, 0x15, 0,
11537 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11538 bits = present ? AMP_IN_MUTE(0) : 0;
11539 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
11540 AMP_IN_MUTE(0), bits);
11541 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
11542 AMP_IN_MUTE(0), bits);
11543}
11544
11545
11546static void alc268_acer_mic_automute(struct hda_codec *codec)
11547{
11548 unsigned int present;
11549
11550 present = snd_hda_codec_read(codec, 0x18, 0,
11551 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11552 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_CONNECT_SEL,
11553 present ? 0x0 : 0x6);
11554}
11555
11556static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
11557 unsigned int res)
11558{
11559 if ((res >> 26) == ALC880_HP_EVENT)
11560 alc268_aspire_one_speaker_automute(codec);
11561 if ((res >> 26) == ALC880_MIC_EVENT)
11562 alc268_acer_mic_automute(codec);
11563}
11564
11565static void alc268_acer_lc_init_hook(struct hda_codec *codec)
11566{
11567 alc268_aspire_one_speaker_automute(codec);
11568 alc268_acer_mic_automute(codec);
11569}
11570
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011571static struct snd_kcontrol_new alc268_dell_mixer[] = {
11572 /* output mixer control */
11573 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11574 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11575 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11576 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11577 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11578 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11579 { }
11580};
11581
11582static struct hda_verb alc268_dell_verbs[] = {
11583 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11584 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11585 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11586 { }
11587};
11588
11589/* mute/unmute internal speaker according to the hp jack and mute state */
11590static void alc268_dell_automute(struct hda_codec *codec)
11591{
11592 unsigned int present;
11593 unsigned int mute;
11594
11595 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0);
11596 if (present & 0x80000000)
11597 mute = HDA_AMP_MUTE;
11598 else
11599 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
11600 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11601 HDA_AMP_MUTE, mute);
11602}
11603
11604static void alc268_dell_unsol_event(struct hda_codec *codec,
11605 unsigned int res)
11606{
11607 if ((res >> 26) != ALC880_HP_EVENT)
11608 return;
11609 alc268_dell_automute(codec);
11610}
11611
11612#define alc268_dell_init_hook alc268_dell_automute
11613
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011614static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
11615 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11616 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11617 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11618 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11619 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11620 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
11621 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
11622 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11623 { }
11624};
11625
11626static struct hda_verb alc267_quanta_il1_verbs[] = {
11627 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11628 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
11629 { }
11630};
11631
11632static void alc267_quanta_il1_hp_automute(struct hda_codec *codec)
11633{
11634 unsigned int present;
11635
11636 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
11637 & AC_PINSENSE_PRESENCE;
11638 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
11639 present ? 0 : PIN_OUT);
11640}
11641
11642static void alc267_quanta_il1_mic_automute(struct hda_codec *codec)
11643{
11644 unsigned int present;
11645
11646 present = snd_hda_codec_read(codec, 0x18, 0,
11647 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11648 snd_hda_codec_write(codec, 0x23, 0,
11649 AC_VERB_SET_CONNECT_SEL,
11650 present ? 0x00 : 0x01);
11651}
11652
11653static void alc267_quanta_il1_automute(struct hda_codec *codec)
11654{
11655 alc267_quanta_il1_hp_automute(codec);
11656 alc267_quanta_il1_mic_automute(codec);
11657}
11658
11659static void alc267_quanta_il1_unsol_event(struct hda_codec *codec,
11660 unsigned int res)
11661{
11662 switch (res >> 26) {
11663 case ALC880_HP_EVENT:
11664 alc267_quanta_il1_hp_automute(codec);
11665 break;
11666 case ALC880_MIC_EVENT:
11667 alc267_quanta_il1_mic_automute(codec);
11668 break;
11669 }
11670}
11671
Kailang Yanga361d842007-06-05 12:30:55 +020011672/*
11673 * generic initialization of ADC, input mixers and output mixers
11674 */
11675static struct hda_verb alc268_base_init_verbs[] = {
11676 /* Unmute DAC0-1 and set vol = 0 */
11677 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011678 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011679
11680 /*
11681 * Set up output mixers (0x0c - 0x0e)
11682 */
11683 /* set vol=0 to output mixers */
11684 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020011685 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
11686
11687 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11688 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11689
11690 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11691 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11692 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11693 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11694 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11695 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11696 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11697 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11698
11699 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11700 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11701 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11702 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011703 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011704
11705 /* set PCBEEP vol = 0, mute connections */
11706 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11707 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11708 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020011709
Jiang Zhea9b3aa82007-12-20 13:13:13 +010011710 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020011711
Jiang Zhea9b3aa82007-12-20 13:13:13 +010011712 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
11713 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11714 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
11715 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011716
Kailang Yanga361d842007-06-05 12:30:55 +020011717 { }
11718};
11719
11720/*
11721 * generic initialization of ADC, input mixers and output mixers
11722 */
11723static struct hda_verb alc268_volume_init_verbs[] = {
11724 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010011725 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11726 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011727
11728 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11729 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11730 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11731 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11732 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11733
Kailang Yanga361d842007-06-05 12:30:55 +020011734 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020011735 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11736 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11737
11738 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011739 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011740
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011741 /* set PCBEEP vol = 0, mute connections */
11742 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11743 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11744 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020011745
11746 { }
11747};
11748
Kailang Yanga361d842007-06-05 12:30:55 +020011749static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
11750 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11751 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11752 {
11753 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11754 /* The multiple "Capture Source" controls confuse alsamixer
11755 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020011756 */
11757 /* .name = "Capture Source", */
11758 .name = "Input Source",
11759 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011760 .info = alc_mux_enum_info,
11761 .get = alc_mux_enum_get,
11762 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020011763 },
11764 { } /* end */
11765};
11766
11767static struct snd_kcontrol_new alc268_capture_mixer[] = {
11768 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11769 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11770 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
11771 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
11772 {
11773 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11774 /* The multiple "Capture Source" controls confuse alsamixer
11775 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020011776 */
11777 /* .name = "Capture Source", */
11778 .name = "Input Source",
11779 .count = 2,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011780 .info = alc_mux_enum_info,
11781 .get = alc_mux_enum_get,
11782 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020011783 },
11784 { } /* end */
11785};
11786
11787static struct hda_input_mux alc268_capture_source = {
11788 .num_items = 4,
11789 .items = {
11790 { "Mic", 0x0 },
11791 { "Front Mic", 0x1 },
11792 { "Line", 0x2 },
11793 { "CD", 0x3 },
11794 },
11795};
11796
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011797static struct hda_input_mux alc268_acer_capture_source = {
11798 .num_items = 3,
11799 .items = {
11800 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011801 { "Internal Mic", 0x1 },
11802 { "Line", 0x2 },
11803 },
11804};
11805
11806static struct hda_input_mux alc268_acer_dmic_capture_source = {
11807 .num_items = 3,
11808 .items = {
11809 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011810 { "Internal Mic", 0x6 },
11811 { "Line", 0x2 },
11812 },
11813};
11814
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011815#ifdef CONFIG_SND_DEBUG
11816static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011817 /* Volume widgets */
11818 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11819 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11820 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
11821 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
11822 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
11823 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
11824 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
11825 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
11826 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
11827 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
11828 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
11829 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
11830 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010011831 /* The below appears problematic on some hardwares */
11832 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011833 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11834 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
11835 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
11836 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
11837
11838 /* Modes for retasking pin widgets */
11839 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
11840 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
11841 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
11842 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
11843
11844 /* Controls for GPIO pins, assuming they are configured as outputs */
11845 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
11846 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
11847 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
11848 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
11849
11850 /* Switches to allow the digital SPDIF output pin to be enabled.
11851 * The ALC268 does not have an SPDIF input.
11852 */
11853 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
11854
11855 /* A switch allowing EAPD to be enabled. Some laptops seem to use
11856 * this output to turn on an external amplifier.
11857 */
11858 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
11859 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
11860
11861 { } /* end */
11862};
11863#endif
11864
Kailang Yanga361d842007-06-05 12:30:55 +020011865/* create input playback/capture controls for the given pin */
11866static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
11867 const char *ctlname, int idx)
11868{
11869 char name[32];
11870 int err;
11871
11872 sprintf(name, "%s Playback Volume", ctlname);
11873 if (nid == 0x14) {
11874 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11875 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
11876 HDA_OUTPUT));
11877 if (err < 0)
11878 return err;
11879 } else if (nid == 0x15) {
11880 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11881 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
11882 HDA_OUTPUT));
11883 if (err < 0)
11884 return err;
11885 } else
11886 return -1;
11887 sprintf(name, "%s Playback Switch", ctlname);
11888 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
11889 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
11890 if (err < 0)
11891 return err;
11892 return 0;
11893}
11894
11895/* add playback controls from the parsed DAC table */
11896static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
11897 const struct auto_pin_cfg *cfg)
11898{
11899 hda_nid_t nid;
11900 int err;
11901
11902 spec->multiout.num_dacs = 2; /* only use one dac */
11903 spec->multiout.dac_nids = spec->private_dac_nids;
11904 spec->multiout.dac_nids[0] = 2;
11905 spec->multiout.dac_nids[1] = 3;
11906
11907 nid = cfg->line_out_pins[0];
11908 if (nid)
Kailang Yangea1fb292008-08-26 12:58:38 +020011909 alc268_new_analog_output(spec, nid, "Front", 0);
Kailang Yanga361d842007-06-05 12:30:55 +020011910
11911 nid = cfg->speaker_pins[0];
11912 if (nid == 0x1d) {
11913 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11914 "Speaker Playback Volume",
11915 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
11916 if (err < 0)
11917 return err;
11918 }
11919 nid = cfg->hp_pins[0];
11920 if (nid)
11921 alc268_new_analog_output(spec, nid, "Headphone", 0);
11922
11923 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
11924 if (nid == 0x16) {
11925 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11926 "Mono Playback Switch",
11927 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
11928 if (err < 0)
11929 return err;
11930 }
Kailang Yangea1fb292008-08-26 12:58:38 +020011931 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020011932}
11933
11934/* create playback/capture controls for input pins */
11935static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
11936 const struct auto_pin_cfg *cfg)
11937{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011938 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020011939 int i, idx1;
11940
11941 for (i = 0; i < AUTO_PIN_LAST; i++) {
11942 switch(cfg->input_pins[i]) {
11943 case 0x18:
11944 idx1 = 0; /* Mic 1 */
11945 break;
11946 case 0x19:
11947 idx1 = 1; /* Mic 2 */
11948 break;
11949 case 0x1a:
11950 idx1 = 2; /* Line In */
11951 break;
Kailang Yangea1fb292008-08-26 12:58:38 +020011952 case 0x1c:
Kailang Yanga361d842007-06-05 12:30:55 +020011953 idx1 = 3; /* CD */
11954 break;
Takashi Iwai7194cae2008-03-06 16:58:17 +010011955 case 0x12:
11956 case 0x13:
11957 idx1 = 6; /* digital mics */
11958 break;
Kailang Yanga361d842007-06-05 12:30:55 +020011959 default:
11960 continue;
11961 }
11962 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
11963 imux->items[imux->num_items].index = idx1;
Kailang Yangea1fb292008-08-26 12:58:38 +020011964 imux->num_items++;
Kailang Yanga361d842007-06-05 12:30:55 +020011965 }
11966 return 0;
11967}
11968
11969static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
11970{
11971 struct alc_spec *spec = codec->spec;
11972 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
11973 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
11974 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
11975 unsigned int dac_vol1, dac_vol2;
11976
11977 if (speaker_nid) {
11978 snd_hda_codec_write(codec, speaker_nid, 0,
11979 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
11980 snd_hda_codec_write(codec, 0x0f, 0,
11981 AC_VERB_SET_AMP_GAIN_MUTE,
11982 AMP_IN_UNMUTE(1));
11983 snd_hda_codec_write(codec, 0x10, 0,
11984 AC_VERB_SET_AMP_GAIN_MUTE,
11985 AMP_IN_UNMUTE(1));
11986 } else {
11987 snd_hda_codec_write(codec, 0x0f, 0,
11988 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
11989 snd_hda_codec_write(codec, 0x10, 0,
11990 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
11991 }
11992
11993 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020011994 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020011995 dac_vol2 = AMP_OUT_ZERO;
11996 else if (line_nid == 0x15)
11997 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020011998 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020011999 dac_vol2 = AMP_OUT_ZERO;
12000 else if (hp_nid == 0x15)
12001 dac_vol1 = AMP_OUT_ZERO;
12002 if (line_nid != 0x16 || hp_nid != 0x16 ||
12003 spec->autocfg.line_out_pins[1] != 0x16 ||
12004 spec->autocfg.line_out_pins[2] != 0x16)
12005 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
12006
12007 snd_hda_codec_write(codec, 0x02, 0,
12008 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
12009 snd_hda_codec_write(codec, 0x03, 0,
12010 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
12011}
12012
12013/* pcm configuration: identiacal with ALC880 */
12014#define alc268_pcm_analog_playback alc880_pcm_analog_playback
12015#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010012016#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020012017#define alc268_pcm_digital_playback alc880_pcm_digital_playback
12018
12019/*
12020 * BIOS auto configuration
12021 */
12022static int alc268_parse_auto_config(struct hda_codec *codec)
12023{
12024 struct alc_spec *spec = codec->spec;
12025 int err;
12026 static hda_nid_t alc268_ignore[] = { 0 };
12027
12028 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12029 alc268_ignore);
12030 if (err < 0)
12031 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012032 if (!spec->autocfg.line_outs) {
12033 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
12034 spec->multiout.max_channels = 2;
12035 spec->no_analog = 1;
12036 goto dig_only;
12037 }
Kailang Yanga361d842007-06-05 12:30:55 +020012038 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012039 }
Kailang Yanga361d842007-06-05 12:30:55 +020012040 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
12041 if (err < 0)
12042 return err;
12043 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
12044 if (err < 0)
12045 return err;
12046
12047 spec->multiout.max_channels = 2;
12048
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012049 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020012050 /* digital only support output */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012051 if (spec->autocfg.dig_outs) {
Kailang Yanga361d842007-06-05 12:30:55 +020012052 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012053 spec->dig_out_type = spec->autocfg.dig_out_type[0];
12054 }
Takashi Iwai603c4012008-07-30 15:01:44 +020012055 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012056 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020012057
Takashi Iwai892981f2009-03-02 08:04:35 +010012058 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012059 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012060
Takashi Iwaid88897e2008-10-31 15:01:37 +010012061 add_verb(spec, alc268_volume_init_verbs);
Kailang Yanga361d842007-06-05 12:30:55 +020012062 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012063 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020012064
Takashi Iwai776e1842007-08-29 15:07:11 +020012065 err = alc_auto_add_mic_boost(codec);
12066 if (err < 0)
12067 return err;
12068
Kailang Yanga361d842007-06-05 12:30:55 +020012069 return 1;
12070}
12071
12072#define alc268_auto_init_multi_out alc882_auto_init_multi_out
12073#define alc268_auto_init_hp_out alc882_auto_init_hp_out
12074#define alc268_auto_init_analog_input alc882_auto_init_analog_input
12075
12076/* init callback for auto-configuration model -- overriding the default init */
12077static void alc268_auto_init(struct hda_codec *codec)
12078{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012079 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020012080 alc268_auto_init_multi_out(codec);
12081 alc268_auto_init_hp_out(codec);
12082 alc268_auto_init_mono_speaker_out(codec);
12083 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012084 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012085 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020012086}
12087
12088/*
12089 * configuration and preset
12090 */
12091static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012092 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020012093 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012094 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020012095 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012096 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020012097 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012098 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012099 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012100#ifdef CONFIG_SND_DEBUG
12101 [ALC268_TEST] = "test",
12102#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012103 [ALC268_AUTO] = "auto",
12104};
12105
12106static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020012107 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012108 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010012109 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012110 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010012111 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020012112 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
12113 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012114 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Takashi Iwai57d13922009-01-08 15:52:09 +010012115 SND_PCI_QUIRK(0x1028, 0x02b0, "Dell Inspiron Mini9", ALC268_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012116 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
Kailang Yanga361d842007-06-05 12:30:55 +020012117 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Kailang Yangd1a991a2007-08-15 16:21:59 +020012118 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
Takashi Iwai8e7f00f2007-09-07 10:58:58 +020012119 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
Travis Place2346d0c2008-09-01 08:24:00 +020012120 SND_PCI_QUIRK(0x1179, 0xff64, "TOSHIBA L305", ALC268_TOSHIBA),
Tony Vroon378bd6a2008-06-04 12:08:30 +020012121 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020012122 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012123 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012124 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Kailang Yanga361d842007-06-05 12:30:55 +020012125 {}
12126};
12127
12128static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012129 [ALC267_QUANTA_IL1] = {
Takashi Iwai22971e32009-02-10 11:56:44 +010012130 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012131 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12132 alc267_quanta_il1_verbs },
12133 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12134 .dac_nids = alc268_dac_nids,
12135 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12136 .adc_nids = alc268_adc_nids_alt,
12137 .hp_nid = 0x03,
12138 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12139 .channel_mode = alc268_modes,
12140 .input_mux = &alc268_capture_source,
12141 .unsol_event = alc267_quanta_il1_unsol_event,
12142 .init_hook = alc267_quanta_il1_automute,
12143 },
Kailang Yanga361d842007-06-05 12:30:55 +020012144 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012145 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12146 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020012147 .init_verbs = { alc268_base_init_verbs },
12148 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12149 .dac_nids = alc268_dac_nids,
12150 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12151 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012152 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020012153 .hp_nid = 0x03,
12154 .dig_out_nid = ALC268_DIGOUT_NID,
12155 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12156 .channel_mode = alc268_modes,
12157 .input_mux = &alc268_capture_source,
12158 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012159 [ALC268_TOSHIBA] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012160 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12161 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012162 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12163 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012164 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12165 .dac_nids = alc268_dac_nids,
12166 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12167 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012168 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012169 .hp_nid = 0x03,
12170 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12171 .channel_mode = alc268_modes,
12172 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012173 .unsol_event = alc268_toshiba_unsol_event,
12174 .init_hook = alc268_toshiba_automute,
12175 },
12176 [ALC268_ACER] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012177 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
12178 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012179 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12180 alc268_acer_verbs },
12181 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12182 .dac_nids = alc268_dac_nids,
12183 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12184 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012185 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020012186 .hp_nid = 0x02,
12187 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12188 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012189 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012190 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020012191 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012192 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012193 [ALC268_ACER_DMIC] = {
12194 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
12195 alc268_beep_mixer },
12196 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12197 alc268_acer_verbs },
12198 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12199 .dac_nids = alc268_dac_nids,
12200 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12201 .adc_nids = alc268_adc_nids_alt,
12202 .capsrc_nids = alc268_capsrc_nids,
12203 .hp_nid = 0x02,
12204 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12205 .channel_mode = alc268_modes,
12206 .input_mux = &alc268_acer_dmic_capture_source,
12207 .unsol_event = alc268_acer_unsol_event,
12208 .init_hook = alc268_acer_init_hook,
12209 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012210 [ALC268_ACER_ASPIRE_ONE] = {
12211 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010012212 alc268_beep_mixer,
12213 alc268_capture_alt_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012214 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12215 alc268_acer_aspire_one_verbs },
12216 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12217 .dac_nids = alc268_dac_nids,
12218 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12219 .adc_nids = alc268_adc_nids_alt,
12220 .capsrc_nids = alc268_capsrc_nids,
12221 .hp_nid = 0x03,
12222 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12223 .channel_mode = alc268_modes,
12224 .input_mux = &alc268_acer_lc_capture_source,
12225 .unsol_event = alc268_acer_lc_unsol_event,
12226 .init_hook = alc268_acer_lc_init_hook,
12227 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012228 [ALC268_DELL] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012229 .mixers = { alc268_dell_mixer, alc268_beep_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012230 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12231 alc268_dell_verbs },
12232 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12233 .dac_nids = alc268_dac_nids,
12234 .hp_nid = 0x02,
12235 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12236 .channel_mode = alc268_modes,
12237 .unsol_event = alc268_dell_unsol_event,
12238 .init_hook = alc268_dell_init_hook,
12239 .input_mux = &alc268_capture_source,
12240 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012241 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012242 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12243 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012244 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12245 alc268_toshiba_verbs },
12246 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12247 .dac_nids = alc268_dac_nids,
12248 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12249 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012250 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012251 .hp_nid = 0x03,
12252 .dig_out_nid = ALC268_DIGOUT_NID,
12253 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12254 .channel_mode = alc268_modes,
12255 .input_mux = &alc268_capture_source,
12256 .unsol_event = alc268_toshiba_unsol_event,
12257 .init_hook = alc268_toshiba_automute
12258 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012259#ifdef CONFIG_SND_DEBUG
12260 [ALC268_TEST] = {
12261 .mixers = { alc268_test_mixer, alc268_capture_mixer },
12262 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12263 alc268_volume_init_verbs },
12264 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12265 .dac_nids = alc268_dac_nids,
12266 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12267 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012268 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012269 .hp_nid = 0x03,
12270 .dig_out_nid = ALC268_DIGOUT_NID,
12271 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12272 .channel_mode = alc268_modes,
12273 .input_mux = &alc268_capture_source,
12274 },
12275#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012276};
12277
12278static int patch_alc268(struct hda_codec *codec)
12279{
12280 struct alc_spec *spec;
12281 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010012282 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020012283
12284 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
12285 if (spec == NULL)
12286 return -ENOMEM;
12287
12288 codec->spec = spec;
12289
12290 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
12291 alc268_models,
12292 alc268_cfg_tbl);
12293
12294 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
12295 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
12296 "trying auto-probe from BIOS...\n");
12297 board_config = ALC268_AUTO;
12298 }
12299
12300 if (board_config == ALC268_AUTO) {
12301 /* automatic parse from the BIOS config */
12302 err = alc268_parse_auto_config(codec);
12303 if (err < 0) {
12304 alc_free(codec);
12305 return err;
12306 } else if (!err) {
12307 printk(KERN_INFO
12308 "hda_codec: Cannot set up configuration "
12309 "from BIOS. Using base mode...\n");
12310 board_config = ALC268_3ST;
12311 }
12312 }
12313
12314 if (board_config != ALC268_AUTO)
12315 setup_preset(spec, &alc268_presets[board_config]);
12316
Kailang Yang2f893282008-05-27 12:14:47 +020012317 if (codec->vendor_id == 0x10ec0267) {
12318 spec->stream_name_analog = "ALC267 Analog";
12319 spec->stream_name_digital = "ALC267 Digital";
12320 } else {
12321 spec->stream_name_analog = "ALC268 Analog";
12322 spec->stream_name_digital = "ALC268 Digital";
12323 }
12324
Kailang Yanga361d842007-06-05 12:30:55 +020012325 spec->stream_analog_playback = &alc268_pcm_analog_playback;
12326 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010012327 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020012328
Kailang Yanga361d842007-06-05 12:30:55 +020012329 spec->stream_digital_playback = &alc268_pcm_digital_playback;
12330
Takashi Iwai22971e32009-02-10 11:56:44 +010012331 has_beep = 0;
12332 for (i = 0; i < spec->num_mixers; i++) {
12333 if (spec->mixers[i] == alc268_beep_mixer) {
12334 has_beep = 1;
12335 break;
12336 }
12337 }
12338
12339 if (has_beep) {
12340 err = snd_hda_attach_beep_device(codec, 0x1);
12341 if (err < 0) {
12342 alc_free(codec);
12343 return err;
12344 }
12345 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
12346 /* override the amp caps for beep generator */
12347 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012348 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
12349 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
12350 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
12351 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010012352 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012353
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012354 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012355 /* check whether NID 0x07 is valid */
12356 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010012357 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020012358
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012359 /* get type */
12360 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwai67ebcb02008-02-19 15:03:57 +010012361 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012362 spec->adc_nids = alc268_adc_nids_alt;
12363 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012364 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012365 } else {
12366 spec->adc_nids = alc268_adc_nids;
12367 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012368 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020012369 }
Takashi Iwaie1406342008-02-11 18:32:32 +010012370 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai85860c02008-02-19 15:00:15 +010012371 /* set default input source */
12372 for (i = 0; i < spec->num_adc_nids; i++)
12373 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
12374 0, AC_VERB_SET_CONNECT_SEL,
12375 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020012376 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010012377
12378 spec->vmaster_nid = 0x02;
12379
Kailang Yanga361d842007-06-05 12:30:55 +020012380 codec->patch_ops = alc_patch_ops;
12381 if (board_config == ALC268_AUTO)
12382 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020012383
Takashi Iwaidaead532008-11-28 12:55:36 +010012384 codec->proc_widget_hook = print_realtek_coef;
12385
Kailang Yanga361d842007-06-05 12:30:55 +020012386 return 0;
12387}
12388
12389/*
Kailang Yangf6a92242007-12-13 16:52:54 +010012390 * ALC269 channel source setting (2 channel)
12391 */
12392#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
12393
12394#define alc269_dac_nids alc260_dac_nids
12395
12396static hda_nid_t alc269_adc_nids[1] = {
12397 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020012398 0x08,
12399};
12400
Takashi Iwaie01bf502008-08-21 16:25:07 +020012401static hda_nid_t alc269_capsrc_nids[1] = {
12402 0x23,
12403};
12404
12405/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
12406 * not a mux!
12407 */
12408
Kailang Yangf53281e2008-07-18 12:36:43 +020012409static struct hda_input_mux alc269_eeepc_dmic_capture_source = {
12410 .num_items = 2,
12411 .items = {
12412 { "i-Mic", 0x5 },
12413 { "e-Mic", 0x0 },
12414 },
12415};
12416
12417static struct hda_input_mux alc269_eeepc_amic_capture_source = {
12418 .num_items = 2,
12419 .items = {
12420 { "i-Mic", 0x1 },
12421 { "e-Mic", 0x0 },
12422 },
Kailang Yangf6a92242007-12-13 16:52:54 +010012423};
12424
12425#define alc269_modes alc260_modes
12426#define alc269_capture_source alc880_lg_lw_capture_source
12427
12428static struct snd_kcontrol_new alc269_base_mixer[] = {
12429 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12430 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12431 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12432 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12433 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12434 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12435 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12436 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12437 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12438 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12439 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12440 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
12441 { } /* end */
12442};
12443
Kailang Yang60db6b52008-08-26 13:13:00 +020012444static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
12445 /* output mixer control */
12446 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12447 {
12448 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12449 .name = "Master Playback Switch",
12450 .info = snd_hda_mixer_amp_switch_info,
12451 .get = snd_hda_mixer_amp_switch_get,
12452 .put = alc268_acer_master_sw_put,
12453 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12454 },
12455 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12456 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12457 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12458 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12459 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12460 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020012461 { }
12462};
12463
Tony Vroon64154832008-11-06 15:08:49 +000012464static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
12465 /* output mixer control */
12466 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12467 {
12468 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12469 .name = "Master Playback Switch",
12470 .info = snd_hda_mixer_amp_switch_info,
12471 .get = snd_hda_mixer_amp_switch_get,
12472 .put = alc268_acer_master_sw_put,
12473 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12474 },
12475 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12476 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12477 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12478 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12479 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12480 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12481 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
12482 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
12483 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000012484 { }
12485};
12486
Kailang Yangf53281e2008-07-18 12:36:43 +020012487/* bind volumes of both NID 0x0c and 0x0d */
12488static struct hda_bind_ctls alc269_epc_bind_vol = {
12489 .ops = &snd_hda_bind_vol,
12490 .values = {
12491 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
12492 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
12493 0
12494 },
12495};
12496
12497static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
12498 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12499 HDA_BIND_VOL("LineOut Playback Volume", &alc269_epc_bind_vol),
12500 HDA_CODEC_MUTE("LineOut Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12501 { } /* end */
12502};
12503
Kailang Yangf6a92242007-12-13 16:52:54 +010012504/* capture mixer elements */
Kailang Yangf53281e2008-07-18 12:36:43 +020012505static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
12506 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12507 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012508 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12509 { } /* end */
12510};
12511
12512/* FSC amilo */
12513static struct snd_kcontrol_new alc269_fujitsu_mixer[] = {
12514 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12515 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12516 HDA_BIND_VOL("PCM Playback Volume", &alc269_epc_bind_vol),
Kailang Yangf53281e2008-07-18 12:36:43 +020012517 { } /* end */
12518};
12519
Kailang Yang60db6b52008-08-26 13:13:00 +020012520static struct hda_verb alc269_quanta_fl1_verbs[] = {
12521 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12522 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12523 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12524 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12525 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12526 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12527 { }
12528};
12529
Tony Vroon64154832008-11-06 15:08:49 +000012530static struct hda_verb alc269_lifebook_verbs[] = {
12531 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12532 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
12533 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12534 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12535 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12536 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12537 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12538 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12539 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12540 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12541 { }
12542};
12543
Kailang Yang60db6b52008-08-26 13:13:00 +020012544/* toggle speaker-output according to the hp-jack state */
12545static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
12546{
12547 unsigned int present;
12548 unsigned char bits;
12549
12550 present = snd_hda_codec_read(codec, 0x15, 0,
12551 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12552 bits = present ? AMP_IN_MUTE(0) : 0;
12553 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12554 AMP_IN_MUTE(0), bits);
12555 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12556 AMP_IN_MUTE(0), bits);
12557
12558 snd_hda_codec_write(codec, 0x20, 0,
12559 AC_VERB_SET_COEF_INDEX, 0x0c);
12560 snd_hda_codec_write(codec, 0x20, 0,
12561 AC_VERB_SET_PROC_COEF, 0x680);
12562
12563 snd_hda_codec_write(codec, 0x20, 0,
12564 AC_VERB_SET_COEF_INDEX, 0x0c);
12565 snd_hda_codec_write(codec, 0x20, 0,
12566 AC_VERB_SET_PROC_COEF, 0x480);
12567}
12568
Tony Vroon64154832008-11-06 15:08:49 +000012569/* toggle speaker-output according to the hp-jacks state */
12570static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
12571{
12572 unsigned int present;
12573 unsigned char bits;
12574
12575 /* Check laptop headphone socket */
12576 present = snd_hda_codec_read(codec, 0x15, 0,
12577 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12578
12579 /* Check port replicator headphone socket */
12580 present |= snd_hda_codec_read(codec, 0x1a, 0,
12581 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12582
12583 bits = present ? AMP_IN_MUTE(0) : 0;
12584 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12585 AMP_IN_MUTE(0), bits);
12586 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12587 AMP_IN_MUTE(0), bits);
12588
12589 snd_hda_codec_write(codec, 0x20, 0,
12590 AC_VERB_SET_COEF_INDEX, 0x0c);
12591 snd_hda_codec_write(codec, 0x20, 0,
12592 AC_VERB_SET_PROC_COEF, 0x680);
12593
12594 snd_hda_codec_write(codec, 0x20, 0,
12595 AC_VERB_SET_COEF_INDEX, 0x0c);
12596 snd_hda_codec_write(codec, 0x20, 0,
12597 AC_VERB_SET_PROC_COEF, 0x480);
12598}
12599
Kailang Yang60db6b52008-08-26 13:13:00 +020012600static void alc269_quanta_fl1_mic_automute(struct hda_codec *codec)
12601{
12602 unsigned int present;
12603
12604 present = snd_hda_codec_read(codec, 0x18, 0,
12605 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12606 snd_hda_codec_write(codec, 0x23, 0,
12607 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x1);
12608}
12609
Tony Vroon64154832008-11-06 15:08:49 +000012610static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
12611{
12612 unsigned int present_laptop;
12613 unsigned int present_dock;
12614
12615 present_laptop = snd_hda_codec_read(codec, 0x18, 0,
12616 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12617
12618 present_dock = snd_hda_codec_read(codec, 0x1b, 0,
12619 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12620
12621 /* Laptop mic port overrides dock mic port, design decision */
12622 if (present_dock)
12623 snd_hda_codec_write(codec, 0x23, 0,
12624 AC_VERB_SET_CONNECT_SEL, 0x3);
12625 if (present_laptop)
12626 snd_hda_codec_write(codec, 0x23, 0,
12627 AC_VERB_SET_CONNECT_SEL, 0x0);
12628 if (!present_dock && !present_laptop)
12629 snd_hda_codec_write(codec, 0x23, 0,
12630 AC_VERB_SET_CONNECT_SEL, 0x1);
12631}
12632
Kailang Yang60db6b52008-08-26 13:13:00 +020012633static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
12634 unsigned int res)
12635{
12636 if ((res >> 26) == ALC880_HP_EVENT)
12637 alc269_quanta_fl1_speaker_automute(codec);
12638 if ((res >> 26) == ALC880_MIC_EVENT)
12639 alc269_quanta_fl1_mic_automute(codec);
12640}
12641
Tony Vroon64154832008-11-06 15:08:49 +000012642static void alc269_lifebook_unsol_event(struct hda_codec *codec,
12643 unsigned int res)
12644{
12645 if ((res >> 26) == ALC880_HP_EVENT)
12646 alc269_lifebook_speaker_automute(codec);
12647 if ((res >> 26) == ALC880_MIC_EVENT)
12648 alc269_lifebook_mic_autoswitch(codec);
12649}
12650
Kailang Yang60db6b52008-08-26 13:13:00 +020012651static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
12652{
12653 alc269_quanta_fl1_speaker_automute(codec);
12654 alc269_quanta_fl1_mic_automute(codec);
12655}
12656
Tony Vroon64154832008-11-06 15:08:49 +000012657static void alc269_lifebook_init_hook(struct hda_codec *codec)
12658{
12659 alc269_lifebook_speaker_automute(codec);
12660 alc269_lifebook_mic_autoswitch(codec);
12661}
12662
Kailang Yang60db6b52008-08-26 13:13:00 +020012663static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
12664 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12665 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
12666 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12667 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
12668 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12669 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12670 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12671 {}
12672};
12673
12674static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
12675 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12676 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
12677 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12678 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
12679 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12680 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12681 {}
12682};
12683
12684/* toggle speaker-output according to the hp-jack state */
12685static void alc269_speaker_automute(struct hda_codec *codec)
12686{
12687 unsigned int present;
12688 unsigned char bits;
12689
12690 present = snd_hda_codec_read(codec, 0x15, 0,
12691 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12692 bits = present ? AMP_IN_MUTE(0) : 0;
12693 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12694 AMP_IN_MUTE(0), bits);
12695 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12696 AMP_IN_MUTE(0), bits);
12697}
12698
12699static void alc269_eeepc_dmic_automute(struct hda_codec *codec)
12700{
12701 unsigned int present;
12702
12703 present = snd_hda_codec_read(codec, 0x18, 0,
12704 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12705 snd_hda_codec_write(codec, 0x23, 0,
12706 AC_VERB_SET_CONNECT_SEL, (present ? 0 : 5));
12707}
12708
12709static void alc269_eeepc_amic_automute(struct hda_codec *codec)
12710{
12711 unsigned int present;
12712
12713 present = snd_hda_codec_read(codec, 0x18, 0,
12714 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12715 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12716 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
12717 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12718 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
12719}
12720
12721/* unsolicited event for HP jack sensing */
12722static void alc269_eeepc_dmic_unsol_event(struct hda_codec *codec,
12723 unsigned int res)
12724{
12725 if ((res >> 26) == ALC880_HP_EVENT)
12726 alc269_speaker_automute(codec);
12727
12728 if ((res >> 26) == ALC880_MIC_EVENT)
12729 alc269_eeepc_dmic_automute(codec);
12730}
12731
12732static void alc269_eeepc_dmic_inithook(struct hda_codec *codec)
12733{
12734 alc269_speaker_automute(codec);
12735 alc269_eeepc_dmic_automute(codec);
12736}
12737
12738/* unsolicited event for HP jack sensing */
12739static void alc269_eeepc_amic_unsol_event(struct hda_codec *codec,
12740 unsigned int res)
12741{
12742 if ((res >> 26) == ALC880_HP_EVENT)
12743 alc269_speaker_automute(codec);
12744
12745 if ((res >> 26) == ALC880_MIC_EVENT)
12746 alc269_eeepc_amic_automute(codec);
12747}
12748
12749static void alc269_eeepc_amic_inithook(struct hda_codec *codec)
12750{
12751 alc269_speaker_automute(codec);
12752 alc269_eeepc_amic_automute(codec);
12753}
12754
Kailang Yangf6a92242007-12-13 16:52:54 +010012755/*
12756 * generic initialization of ADC, input mixers and output mixers
12757 */
12758static struct hda_verb alc269_init_verbs[] = {
12759 /*
12760 * Unmute ADC0 and set the default input to mic-in
12761 */
Kailang Yang60db6b52008-08-26 13:13:00 +020012762 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010012763
12764 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
12765 * analog-loopback mixer widget
12766 * Note: PASD motherboards uses the Line In 2 as the input for
12767 * front panel mic (mic 2)
12768 */
12769 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
12770 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12771 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12772 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12773 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12774 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12775
12776 /*
12777 * Set up output mixers (0x0c - 0x0e)
12778 */
12779 /* set vol=0 to output mixers */
12780 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12781 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12782
12783 /* set up input amps for analog loopback */
12784 /* Amp Indices: DAC = 0, mixer = 1 */
12785 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12786 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12787 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12788 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12789 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12790 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12791
12792 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12793 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12794 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12795 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12796 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12797 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12798 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12799
12800 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12801 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12802 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12803 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12804 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12805 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12806 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12807
12808 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
12809 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12810
12811 /* FIXME: use matrix-type input source selection */
12812 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
12813 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang60db6b52008-08-26 13:13:00 +020012814 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12815 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangf6a92242007-12-13 16:52:54 +010012816 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12817 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12818
12819 /* set EAPD */
12820 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12821 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12822 { }
12823};
12824
12825/* add playback controls from the parsed DAC table */
12826static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
12827 const struct auto_pin_cfg *cfg)
12828{
12829 hda_nid_t nid;
12830 int err;
12831
12832 spec->multiout.num_dacs = 1; /* only use one dac */
12833 spec->multiout.dac_nids = spec->private_dac_nids;
12834 spec->multiout.dac_nids[0] = 2;
12835
12836 nid = cfg->line_out_pins[0];
12837 if (nid) {
12838 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12839 "Front Playback Volume",
12840 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
12841 if (err < 0)
12842 return err;
12843 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12844 "Front Playback Switch",
12845 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
12846 if (err < 0)
12847 return err;
12848 }
12849
12850 nid = cfg->speaker_pins[0];
12851 if (nid) {
12852 if (!cfg->line_out_pins[0]) {
12853 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12854 "Speaker Playback Volume",
12855 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12856 HDA_OUTPUT));
12857 if (err < 0)
12858 return err;
12859 }
12860 if (nid == 0x16) {
12861 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12862 "Speaker Playback Switch",
12863 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12864 HDA_OUTPUT));
12865 if (err < 0)
12866 return err;
12867 } else {
12868 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12869 "Speaker Playback Switch",
12870 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12871 HDA_OUTPUT));
12872 if (err < 0)
12873 return err;
12874 }
12875 }
12876 nid = cfg->hp_pins[0];
12877 if (nid) {
12878 /* spec->multiout.hp_nid = 2; */
12879 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
12880 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12881 "Headphone Playback Volume",
12882 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12883 HDA_OUTPUT));
12884 if (err < 0)
12885 return err;
12886 }
12887 if (nid == 0x16) {
12888 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12889 "Headphone Playback Switch",
12890 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12891 HDA_OUTPUT));
12892 if (err < 0)
12893 return err;
12894 } else {
12895 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12896 "Headphone Playback Switch",
12897 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12898 HDA_OUTPUT));
12899 if (err < 0)
12900 return err;
12901 }
12902 }
12903 return 0;
12904}
12905
Takashi Iwaiee956e02008-10-31 17:16:31 +010012906static int alc269_auto_create_analog_input_ctls(struct alc_spec *spec,
12907 const struct auto_pin_cfg *cfg)
12908{
12909 int err;
12910
12911 err = alc880_auto_create_analog_input_ctls(spec, cfg);
12912 if (err < 0)
12913 return err;
12914 /* digital-mic input pin is excluded in alc880_auto_create..()
12915 * because it's under 0x18
12916 */
12917 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
12918 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012919 struct hda_input_mux *imux = &spec->private_imux[0];
Takashi Iwaiee956e02008-10-31 17:16:31 +010012920 imux->items[imux->num_items].label = "Int Mic";
12921 imux->items[imux->num_items].index = 0x05;
12922 imux->num_items++;
12923 }
12924 return 0;
12925}
Kailang Yangf6a92242007-12-13 16:52:54 +010012926
12927#ifdef CONFIG_SND_HDA_POWER_SAVE
12928#define alc269_loopbacks alc880_loopbacks
12929#endif
12930
12931/* pcm configuration: identiacal with ALC880 */
12932#define alc269_pcm_analog_playback alc880_pcm_analog_playback
12933#define alc269_pcm_analog_capture alc880_pcm_analog_capture
12934#define alc269_pcm_digital_playback alc880_pcm_digital_playback
12935#define alc269_pcm_digital_capture alc880_pcm_digital_capture
12936
Takashi Iwaif03d3112009-03-05 14:18:16 +010012937static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
12938 .substreams = 1,
12939 .channels_min = 2,
12940 .channels_max = 8,
12941 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
12942 /* NID is set in alc_build_pcms */
12943 .ops = {
12944 .open = alc880_playback_pcm_open,
12945 .prepare = alc880_playback_pcm_prepare,
12946 .cleanup = alc880_playback_pcm_cleanup
12947 },
12948};
12949
12950static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
12951 .substreams = 1,
12952 .channels_min = 2,
12953 .channels_max = 2,
12954 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
12955 /* NID is set in alc_build_pcms */
12956};
12957
Kailang Yangf6a92242007-12-13 16:52:54 +010012958/*
12959 * BIOS auto configuration
12960 */
12961static int alc269_parse_auto_config(struct hda_codec *codec)
12962{
12963 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010012964 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010012965 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
12966
12967 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12968 alc269_ignore);
12969 if (err < 0)
12970 return err;
12971
12972 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
12973 if (err < 0)
12974 return err;
12975 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
12976 if (err < 0)
12977 return err;
12978
12979 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12980
Takashi Iwai0852d7a2009-02-11 11:35:15 +010012981 if (spec->autocfg.dig_outs)
Kailang Yangf6a92242007-12-13 16:52:54 +010012982 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
12983
Takashi Iwai603c4012008-07-30 15:01:44 +020012984 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012985 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010012986
Takashi Iwaid88897e2008-10-31 15:01:37 +010012987 add_verb(spec, alc269_init_verbs);
Kailang Yangf6a92242007-12-13 16:52:54 +010012988 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012989 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie01bf502008-08-21 16:25:07 +020012990 /* set default input source */
12991 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
12992 0, AC_VERB_SET_CONNECT_SEL,
12993 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010012994
12995 err = alc_auto_add_mic_boost(codec);
12996 if (err < 0)
12997 return err;
12998
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012999 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013000 set_capture_mixer(spec);
Kailang Yangf53281e2008-07-18 12:36:43 +020013001
Kailang Yangf6a92242007-12-13 16:52:54 +010013002 return 1;
13003}
13004
13005#define alc269_auto_init_multi_out alc882_auto_init_multi_out
13006#define alc269_auto_init_hp_out alc882_auto_init_hp_out
13007#define alc269_auto_init_analog_input alc882_auto_init_analog_input
13008
13009
13010/* init callback for auto-configuration model -- overriding the default init */
13011static void alc269_auto_init(struct hda_codec *codec)
13012{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013013 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010013014 alc269_auto_init_multi_out(codec);
13015 alc269_auto_init_hp_out(codec);
13016 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013017 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013018 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010013019}
13020
13021/*
13022 * configuration and preset
13023 */
13024static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013025 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020013026 [ALC269_QUANTA_FL1] = "quanta",
13027 [ALC269_ASUS_EEEPC_P703] = "eeepc-p703",
Takashi Iwai26f5df22008-11-03 17:39:46 +010013028 [ALC269_ASUS_EEEPC_P901] = "eeepc-p901",
Tony Vroon64154832008-11-06 15:08:49 +000013029 [ALC269_FUJITSU] = "fujitsu",
13030 [ALC269_LIFEBOOK] = "lifebook"
Kailang Yangf6a92242007-12-13 16:52:54 +010013031};
13032
13033static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013034 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020013035 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
13036 ALC269_ASUS_EEEPC_P703),
Kailang Yang622e84c2009-04-21 07:39:04 +020013037 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_ASUS_EEEPC_P703),
13038 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_ASUS_EEEPC_P703),
13039 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_ASUS_EEEPC_P703),
13040 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_ASUS_EEEPC_P703),
13041 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_ASUS_EEEPC_P703),
13042 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_ASUS_EEEPC_P703),
Kailang Yangf53281e2008-07-18 12:36:43 +020013043 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
13044 ALC269_ASUS_EEEPC_P901),
Kailang Yang60db6b52008-08-26 13:13:00 +020013045 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
13046 ALC269_ASUS_EEEPC_P901),
Kailang Yang622e84c2009-04-21 07:39:04 +020013047 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_ASUS_EEEPC_P901),
Takashi Iwai26f5df22008-11-03 17:39:46 +010013048 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
Tony Vroon64154832008-11-06 15:08:49 +000013049 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yangf6a92242007-12-13 16:52:54 +010013050 {}
13051};
13052
13053static struct alc_config_preset alc269_presets[] = {
13054 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013055 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010013056 .init_verbs = { alc269_init_verbs },
13057 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13058 .dac_nids = alc269_dac_nids,
13059 .hp_nid = 0x03,
13060 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13061 .channel_mode = alc269_modes,
13062 .input_mux = &alc269_capture_source,
13063 },
Kailang Yang60db6b52008-08-26 13:13:00 +020013064 [ALC269_QUANTA_FL1] = {
13065 .mixers = { alc269_quanta_fl1_mixer },
13066 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
13067 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13068 .dac_nids = alc269_dac_nids,
13069 .hp_nid = 0x03,
13070 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13071 .channel_mode = alc269_modes,
13072 .input_mux = &alc269_capture_source,
13073 .unsol_event = alc269_quanta_fl1_unsol_event,
13074 .init_hook = alc269_quanta_fl1_init_hook,
13075 },
Kailang Yangf53281e2008-07-18 12:36:43 +020013076 [ALC269_ASUS_EEEPC_P703] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013077 .mixers = { alc269_eeepc_mixer },
13078 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013079 .init_verbs = { alc269_init_verbs,
13080 alc269_eeepc_amic_init_verbs },
13081 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13082 .dac_nids = alc269_dac_nids,
13083 .hp_nid = 0x03,
13084 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13085 .channel_mode = alc269_modes,
13086 .input_mux = &alc269_eeepc_amic_capture_source,
13087 .unsol_event = alc269_eeepc_amic_unsol_event,
13088 .init_hook = alc269_eeepc_amic_inithook,
13089 },
13090 [ALC269_ASUS_EEEPC_P901] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013091 .mixers = { alc269_eeepc_mixer },
13092 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013093 .init_verbs = { alc269_init_verbs,
13094 alc269_eeepc_dmic_init_verbs },
13095 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13096 .dac_nids = alc269_dac_nids,
13097 .hp_nid = 0x03,
13098 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13099 .channel_mode = alc269_modes,
13100 .input_mux = &alc269_eeepc_dmic_capture_source,
13101 .unsol_event = alc269_eeepc_dmic_unsol_event,
13102 .init_hook = alc269_eeepc_dmic_inithook,
13103 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013104 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013105 .mixers = { alc269_fujitsu_mixer },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013106 .cap_mixer = alc269_epc_capture_mixer,
13107 .init_verbs = { alc269_init_verbs,
13108 alc269_eeepc_dmic_init_verbs },
13109 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13110 .dac_nids = alc269_dac_nids,
13111 .hp_nid = 0x03,
13112 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13113 .channel_mode = alc269_modes,
13114 .input_mux = &alc269_eeepc_dmic_capture_source,
13115 .unsol_event = alc269_eeepc_dmic_unsol_event,
13116 .init_hook = alc269_eeepc_dmic_inithook,
13117 },
Tony Vroon64154832008-11-06 15:08:49 +000013118 [ALC269_LIFEBOOK] = {
13119 .mixers = { alc269_lifebook_mixer },
13120 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
13121 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13122 .dac_nids = alc269_dac_nids,
13123 .hp_nid = 0x03,
13124 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13125 .channel_mode = alc269_modes,
13126 .input_mux = &alc269_capture_source,
13127 .unsol_event = alc269_lifebook_unsol_event,
13128 .init_hook = alc269_lifebook_init_hook,
13129 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013130};
13131
13132static int patch_alc269(struct hda_codec *codec)
13133{
13134 struct alc_spec *spec;
13135 int board_config;
13136 int err;
13137
13138 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13139 if (spec == NULL)
13140 return -ENOMEM;
13141
13142 codec->spec = spec;
13143
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020013144 alc_fix_pll_init(codec, 0x20, 0x04, 15);
13145
Kailang Yangf6a92242007-12-13 16:52:54 +010013146 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
13147 alc269_models,
13148 alc269_cfg_tbl);
13149
13150 if (board_config < 0) {
13151 printk(KERN_INFO "hda_codec: Unknown model for ALC269, "
13152 "trying auto-probe from BIOS...\n");
13153 board_config = ALC269_AUTO;
13154 }
13155
13156 if (board_config == ALC269_AUTO) {
13157 /* automatic parse from the BIOS config */
13158 err = alc269_parse_auto_config(codec);
13159 if (err < 0) {
13160 alc_free(codec);
13161 return err;
13162 } else if (!err) {
13163 printk(KERN_INFO
13164 "hda_codec: Cannot set up configuration "
13165 "from BIOS. Using base mode...\n");
13166 board_config = ALC269_BASIC;
13167 }
13168 }
13169
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090013170 err = snd_hda_attach_beep_device(codec, 0x1);
13171 if (err < 0) {
13172 alc_free(codec);
13173 return err;
13174 }
13175
Kailang Yangf6a92242007-12-13 16:52:54 +010013176 if (board_config != ALC269_AUTO)
13177 setup_preset(spec, &alc269_presets[board_config]);
13178
13179 spec->stream_name_analog = "ALC269 Analog";
Takashi Iwaif03d3112009-03-05 14:18:16 +010013180 if (codec->subsystem_id == 0x17aa3bf8) {
13181 /* Due to a hardware problem on Lenovo Ideadpad, we need to
13182 * fix the sample rate of analog I/O to 44.1kHz
13183 */
13184 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
13185 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
13186 } else {
13187 spec->stream_analog_playback = &alc269_pcm_analog_playback;
13188 spec->stream_analog_capture = &alc269_pcm_analog_capture;
13189 }
Kailang Yangf6a92242007-12-13 16:52:54 +010013190 spec->stream_name_digital = "ALC269 Digital";
13191 spec->stream_digital_playback = &alc269_pcm_digital_playback;
13192 spec->stream_digital_capture = &alc269_pcm_digital_capture;
13193
13194 spec->adc_nids = alc269_adc_nids;
13195 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
Takashi Iwaie01bf502008-08-21 16:25:07 +020013196 spec->capsrc_nids = alc269_capsrc_nids;
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013197 if (!spec->cap_mixer)
13198 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013199 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010013200
13201 codec->patch_ops = alc_patch_ops;
13202 if (board_config == ALC269_AUTO)
13203 spec->init_hook = alc269_auto_init;
13204#ifdef CONFIG_SND_HDA_POWER_SAVE
13205 if (!spec->loopback.amplist)
13206 spec->loopback.amplist = alc269_loopbacks;
13207#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010013208 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010013209
13210 return 0;
13211}
13212
13213/*
Kailang Yangdf694da2005-12-05 19:42:22 +010013214 * ALC861 channel source setting (2/6 channel selection for 3-stack)
13215 */
13216
13217/*
13218 * set the path ways for 2 channel output
13219 * need to set the codec line out and mic 1 pin widgets to inputs
13220 */
13221static struct hda_verb alc861_threestack_ch2_init[] = {
13222 /* set pin widget 1Ah (line in) for input */
13223 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013224 /* set pin widget 18h (mic1/2) for input, for mic also enable
13225 * the vref
13226 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013227 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13228
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013229 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13230#if 0
13231 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13232 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13233#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013234 { } /* end */
13235};
13236/*
13237 * 6ch mode
13238 * need to set the codec line out and mic 1 pin widgets to outputs
13239 */
13240static struct hda_verb alc861_threestack_ch6_init[] = {
13241 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13242 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13243 /* set pin widget 18h (mic1) for output (CLFE)*/
13244 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13245
13246 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013247 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013248
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013249 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13250#if 0
13251 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13252 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13253#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013254 { } /* end */
13255};
13256
13257static struct hda_channel_mode alc861_threestack_modes[2] = {
13258 { 2, alc861_threestack_ch2_init },
13259 { 6, alc861_threestack_ch6_init },
13260};
Takashi Iwai22309c32006-08-09 16:57:28 +020013261/* Set mic1 as input and unmute the mixer */
13262static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
13263 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13264 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13265 { } /* end */
13266};
13267/* Set mic1 as output and mute mixer */
13268static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
13269 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13270 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13271 { } /* end */
13272};
13273
13274static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
13275 { 2, alc861_uniwill_m31_ch2_init },
13276 { 4, alc861_uniwill_m31_ch4_init },
13277};
Kailang Yangdf694da2005-12-05 19:42:22 +010013278
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013279/* Set mic1 and line-in as input and unmute the mixer */
13280static struct hda_verb alc861_asus_ch2_init[] = {
13281 /* set pin widget 1Ah (line in) for input */
13282 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013283 /* set pin widget 18h (mic1/2) for input, for mic also enable
13284 * the vref
13285 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013286 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13287
13288 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13289#if 0
13290 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13291 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13292#endif
13293 { } /* end */
13294};
13295/* Set mic1 nad line-in as output and mute mixer */
13296static struct hda_verb alc861_asus_ch6_init[] = {
13297 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13298 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13299 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13300 /* set pin widget 18h (mic1) for output (CLFE)*/
13301 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13302 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13303 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
13304 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
13305
13306 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13307#if 0
13308 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13309 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13310#endif
13311 { } /* end */
13312};
13313
13314static struct hda_channel_mode alc861_asus_modes[2] = {
13315 { 2, alc861_asus_ch2_init },
13316 { 6, alc861_asus_ch6_init },
13317};
13318
Kailang Yangdf694da2005-12-05 19:42:22 +010013319/* patch-ALC861 */
13320
13321static struct snd_kcontrol_new alc861_base_mixer[] = {
13322 /* output mixer control */
13323 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13324 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13325 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13326 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13327 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13328
13329 /*Input mixer control */
13330 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13331 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13332 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13333 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13334 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13335 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13336 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13337 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13338 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13339 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013340
Kailang Yangdf694da2005-12-05 19:42:22 +010013341 { } /* end */
13342};
13343
13344static struct snd_kcontrol_new alc861_3ST_mixer[] = {
13345 /* output mixer control */
13346 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13347 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13348 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13349 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13350 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13351
13352 /* Input mixer control */
13353 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13354 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13355 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13356 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13357 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13358 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13359 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13360 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13361 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13362 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013363
Kailang Yangdf694da2005-12-05 19:42:22 +010013364 {
13365 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13366 .name = "Channel Mode",
13367 .info = alc_ch_mode_info,
13368 .get = alc_ch_mode_get,
13369 .put = alc_ch_mode_put,
13370 .private_value = ARRAY_SIZE(alc861_threestack_modes),
13371 },
13372 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013373};
13374
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013375static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013376 /* output mixer control */
13377 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13378 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13379 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020013380
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013381 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013382};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013383
Takashi Iwai22309c32006-08-09 16:57:28 +020013384static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
13385 /* output mixer control */
13386 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13387 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13388 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13389 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13390 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13391
13392 /* Input mixer control */
13393 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13394 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13395 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13396 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13397 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13398 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13399 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13400 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13401 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13402 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013403
Takashi Iwai22309c32006-08-09 16:57:28 +020013404 {
13405 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13406 .name = "Channel Mode",
13407 .info = alc_ch_mode_info,
13408 .get = alc_ch_mode_get,
13409 .put = alc_ch_mode_put,
13410 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
13411 },
13412 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013413};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013414
13415static struct snd_kcontrol_new alc861_asus_mixer[] = {
13416 /* output mixer control */
13417 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13418 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13419 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13420 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13421 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13422
13423 /* Input mixer control */
13424 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13425 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13426 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13427 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13428 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13429 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13430 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13431 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13432 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013433 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
13434
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013435 {
13436 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13437 .name = "Channel Mode",
13438 .info = alc_ch_mode_info,
13439 .get = alc_ch_mode_get,
13440 .put = alc_ch_mode_put,
13441 .private_value = ARRAY_SIZE(alc861_asus_modes),
13442 },
13443 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013444};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013445
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013446/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013447static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013448 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13449 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013450 { }
13451};
13452
Kailang Yangdf694da2005-12-05 19:42:22 +010013453/*
13454 * generic initialization of ADC, input mixers and output mixers
13455 */
13456static struct hda_verb alc861_base_init_verbs[] = {
13457 /*
13458 * Unmute ADC0 and set the default input to mic-in
13459 */
13460 /* port-A for surround (rear panel) */
13461 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13462 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
13463 /* port-B for mic-in (rear panel) with vref */
13464 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13465 /* port-C for line-in (rear panel) */
13466 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13467 /* port-D for Front */
13468 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13469 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13470 /* port-E for HP out (front panel) */
13471 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13472 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013473 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013474 /* port-F for mic-in (front panel) with vref */
13475 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13476 /* port-G for CLFE (rear panel) */
13477 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13478 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13479 /* port-H for side (rear panel) */
13480 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13481 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
13482 /* CD-in */
13483 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13484 /* route front mic to ADC1*/
13485 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13486 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013487
Kailang Yangdf694da2005-12-05 19:42:22 +010013488 /* Unmute DAC0~3 & spdif out*/
13489 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13490 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13491 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13492 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13493 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013494
Kailang Yangdf694da2005-12-05 19:42:22 +010013495 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13496 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13497 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13498 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13499 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013500
Kailang Yangdf694da2005-12-05 19:42:22 +010013501 /* Unmute Stereo Mixer 15 */
13502 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13503 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13504 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013505 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013506
13507 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13508 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13509 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13510 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13511 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13512 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13513 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13514 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013515 /* hp used DAC 3 (Front) */
13516 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013517 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13518
13519 { }
13520};
13521
13522static struct hda_verb alc861_threestack_init_verbs[] = {
13523 /*
13524 * Unmute ADC0 and set the default input to mic-in
13525 */
13526 /* port-A for surround (rear panel) */
13527 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13528 /* port-B for mic-in (rear panel) with vref */
13529 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13530 /* port-C for line-in (rear panel) */
13531 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13532 /* port-D for Front */
13533 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13534 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13535 /* port-E for HP out (front panel) */
13536 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13537 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013538 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013539 /* port-F for mic-in (front panel) with vref */
13540 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13541 /* port-G for CLFE (rear panel) */
13542 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13543 /* port-H for side (rear panel) */
13544 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13545 /* CD-in */
13546 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13547 /* route front mic to ADC1*/
13548 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13549 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13550 /* Unmute DAC0~3 & spdif out*/
13551 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13552 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13553 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13554 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13555 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013556
Kailang Yangdf694da2005-12-05 19:42:22 +010013557 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13558 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13559 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13560 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13561 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013562
Kailang Yangdf694da2005-12-05 19:42:22 +010013563 /* Unmute Stereo Mixer 15 */
13564 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13565 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13566 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013567 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013568
13569 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13570 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13571 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13572 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13573 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13574 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13575 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13576 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013577 /* hp used DAC 3 (Front) */
13578 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013579 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13580 { }
13581};
Takashi Iwai22309c32006-08-09 16:57:28 +020013582
13583static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
13584 /*
13585 * Unmute ADC0 and set the default input to mic-in
13586 */
13587 /* port-A for surround (rear panel) */
13588 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13589 /* port-B for mic-in (rear panel) with vref */
13590 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13591 /* port-C for line-in (rear panel) */
13592 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13593 /* port-D for Front */
13594 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13595 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13596 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013597 /* this has to be set to VREF80 */
13598 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013599 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013600 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013601 /* port-F for mic-in (front panel) with vref */
13602 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13603 /* port-G for CLFE (rear panel) */
13604 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13605 /* port-H for side (rear panel) */
13606 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13607 /* CD-in */
13608 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13609 /* route front mic to ADC1*/
13610 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13611 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13612 /* Unmute DAC0~3 & spdif out*/
13613 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13614 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13615 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13616 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13617 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013618
Takashi Iwai22309c32006-08-09 16:57:28 +020013619 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13620 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13621 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13622 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13623 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013624
Takashi Iwai22309c32006-08-09 16:57:28 +020013625 /* Unmute Stereo Mixer 15 */
13626 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13627 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13628 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013629 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020013630
13631 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13632 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13633 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13634 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13635 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13636 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13637 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13638 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013639 /* hp used DAC 3 (Front) */
13640 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020013641 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13642 { }
13643};
13644
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013645static struct hda_verb alc861_asus_init_verbs[] = {
13646 /*
13647 * Unmute ADC0 and set the default input to mic-in
13648 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013649 /* port-A for surround (rear panel)
13650 * according to codec#0 this is the HP jack
13651 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013652 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
13653 /* route front PCM to HP */
13654 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
13655 /* port-B for mic-in (rear panel) with vref */
13656 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13657 /* port-C for line-in (rear panel) */
13658 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13659 /* port-D for Front */
13660 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13661 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13662 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013663 /* this has to be set to VREF80 */
13664 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013665 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013666 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013667 /* port-F for mic-in (front panel) with vref */
13668 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13669 /* port-G for CLFE (rear panel) */
13670 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13671 /* port-H for side (rear panel) */
13672 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13673 /* CD-in */
13674 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13675 /* route front mic to ADC1*/
13676 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13677 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13678 /* Unmute DAC0~3 & spdif out*/
13679 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13680 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13681 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13682 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13683 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13684 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13685 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13686 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13687 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13688 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013689
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013690 /* Unmute Stereo Mixer 15 */
13691 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13692 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13693 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013694 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013695
13696 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13697 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13698 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13699 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13700 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13701 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13702 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13703 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013704 /* hp used DAC 3 (Front) */
13705 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013706 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13707 { }
13708};
13709
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013710/* additional init verbs for ASUS laptops */
13711static struct hda_verb alc861_asus_laptop_init_verbs[] = {
13712 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
13713 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
13714 { }
13715};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013716
Kailang Yangdf694da2005-12-05 19:42:22 +010013717/*
13718 * generic initialization of ADC, input mixers and output mixers
13719 */
13720static struct hda_verb alc861_auto_init_verbs[] = {
13721 /*
13722 * Unmute ADC0 and set the default input to mic-in
13723 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013724 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010013725 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013726
Kailang Yangdf694da2005-12-05 19:42:22 +010013727 /* Unmute DAC0~3 & spdif out*/
13728 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13729 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13730 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13731 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13732 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013733
Kailang Yangdf694da2005-12-05 19:42:22 +010013734 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13735 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13736 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13737 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13738 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013739
Kailang Yangdf694da2005-12-05 19:42:22 +010013740 /* Unmute Stereo Mixer 15 */
13741 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13742 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13743 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13744 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
13745
13746 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13747 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13748 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13749 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13750 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13751 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13752 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13753 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13754
13755 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13756 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013757 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13758 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013759 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13760 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013761 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13762 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013763
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013764 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013765
13766 { }
13767};
13768
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013769static struct hda_verb alc861_toshiba_init_verbs[] = {
13770 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013771
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013772 { }
13773};
13774
13775/* toggle speaker-output according to the hp-jack state */
13776static void alc861_toshiba_automute(struct hda_codec *codec)
13777{
13778 unsigned int present;
13779
13780 present = snd_hda_codec_read(codec, 0x0f, 0,
13781 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013782 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
13783 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
13784 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
13785 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013786}
13787
13788static void alc861_toshiba_unsol_event(struct hda_codec *codec,
13789 unsigned int res)
13790{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013791 if ((res >> 26) == ALC880_HP_EVENT)
13792 alc861_toshiba_automute(codec);
13793}
13794
Kailang Yangdf694da2005-12-05 19:42:22 +010013795/* pcm configuration: identiacal with ALC880 */
13796#define alc861_pcm_analog_playback alc880_pcm_analog_playback
13797#define alc861_pcm_analog_capture alc880_pcm_analog_capture
13798#define alc861_pcm_digital_playback alc880_pcm_digital_playback
13799#define alc861_pcm_digital_capture alc880_pcm_digital_capture
13800
13801
13802#define ALC861_DIGOUT_NID 0x07
13803
13804static struct hda_channel_mode alc861_8ch_modes[1] = {
13805 { 8, NULL }
13806};
13807
13808static hda_nid_t alc861_dac_nids[4] = {
13809 /* front, surround, clfe, side */
13810 0x03, 0x06, 0x05, 0x04
13811};
13812
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013813static hda_nid_t alc660_dac_nids[3] = {
13814 /* front, clfe, surround */
13815 0x03, 0x05, 0x06
13816};
13817
Kailang Yangdf694da2005-12-05 19:42:22 +010013818static hda_nid_t alc861_adc_nids[1] = {
13819 /* ADC0-2 */
13820 0x08,
13821};
13822
13823static struct hda_input_mux alc861_capture_source = {
13824 .num_items = 5,
13825 .items = {
13826 { "Mic", 0x0 },
13827 { "Front Mic", 0x3 },
13828 { "Line", 0x1 },
13829 { "CD", 0x4 },
13830 { "Mixer", 0x5 },
13831 },
13832};
13833
13834/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013835static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
13836 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010013837{
13838 int i;
13839 hda_nid_t nid;
13840
13841 spec->multiout.dac_nids = spec->private_dac_nids;
13842 for (i = 0; i < cfg->line_outs; i++) {
13843 nid = cfg->line_out_pins[i];
13844 if (nid) {
13845 if (i >= ARRAY_SIZE(alc861_dac_nids))
13846 continue;
13847 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
13848 }
13849 }
13850 spec->multiout.num_dacs = cfg->line_outs;
13851 return 0;
13852}
13853
13854/* add playback controls from the parsed DAC table */
13855static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
13856 const struct auto_pin_cfg *cfg)
13857{
13858 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013859 static const char *chname[4] = {
13860 "Front", "Surround", NULL /*CLFE*/, "Side"
13861 };
Kailang Yangdf694da2005-12-05 19:42:22 +010013862 hda_nid_t nid;
13863 int i, idx, err;
13864
13865 for (i = 0; i < cfg->line_outs; i++) {
13866 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013867 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010013868 continue;
13869 if (nid == 0x05) {
13870 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013871 err = add_control(spec, ALC_CTL_BIND_MUTE,
13872 "Center Playback Switch",
13873 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
13874 HDA_OUTPUT));
13875 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013876 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013877 err = add_control(spec, ALC_CTL_BIND_MUTE,
13878 "LFE Playback Switch",
13879 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13880 HDA_OUTPUT));
13881 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013882 return err;
13883 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013884 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
13885 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +010013886 if (nid == alc861_dac_nids[idx])
13887 break;
13888 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013889 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
13890 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13891 HDA_OUTPUT));
13892 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013893 return err;
13894 }
13895 }
13896 return 0;
13897}
13898
13899static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
13900{
13901 int err;
13902 hda_nid_t nid;
13903
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013904 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010013905 return 0;
13906
13907 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
13908 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013909 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13910 "Headphone Playback Switch",
13911 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
13912 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013913 return err;
13914 spec->multiout.hp_nid = nid;
13915 }
13916 return 0;
13917}
13918
13919/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013920static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
13921 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010013922{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013923 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010013924 int i, err, idx, idx1;
13925
13926 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013927 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010013928 case 0x0c:
13929 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013930 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013931 break;
13932 case 0x0f:
13933 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013934 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013935 break;
13936 case 0x0d:
13937 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013938 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013939 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013940 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010013941 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013942 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013943 break;
13944 case 0x11:
13945 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013946 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010013947 break;
13948 default:
13949 continue;
13950 }
13951
Takashi Iwai4a471b72005-12-07 13:56:29 +010013952 err = new_analog_input(spec, cfg->input_pins[i],
13953 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010013954 if (err < 0)
13955 return err;
13956
Takashi Iwai4a471b72005-12-07 13:56:29 +010013957 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010013958 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013959 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010013960 }
13961 return 0;
13962}
13963
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013964static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
13965 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +010013966 int pin_type, int dac_idx)
13967{
Jacek Luczak564c5be2008-05-03 18:41:23 +020013968 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
13969 pin_type);
13970 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13971 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +010013972}
13973
13974static void alc861_auto_init_multi_out(struct hda_codec *codec)
13975{
13976 struct alc_spec *spec = codec->spec;
13977 int i;
13978
13979 for (i = 0; i < spec->autocfg.line_outs; i++) {
13980 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013981 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010013982 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013983 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013984 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010013985 }
13986}
13987
13988static void alc861_auto_init_hp_out(struct hda_codec *codec)
13989{
13990 struct alc_spec *spec = codec->spec;
13991 hda_nid_t pin;
13992
Takashi Iwaieb06ed82006-09-20 17:10:27 +020013993 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010013994 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013995 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
13996 spec->multiout.dac_nids[0]);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013997 pin = spec->autocfg.speaker_pins[0];
13998 if (pin)
13999 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010014000}
14001
14002static void alc861_auto_init_analog_input(struct hda_codec *codec)
14003{
14004 struct alc_spec *spec = codec->spec;
14005 int i;
14006
14007 for (i = 0; i < AUTO_PIN_LAST; i++) {
14008 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai23f0c042009-02-26 13:03:58 +010014009 if (nid >= 0x0c && nid <= 0x11)
14010 alc_set_input_pin(codec, nid, i);
Kailang Yangdf694da2005-12-05 19:42:22 +010014011 }
14012}
14013
14014/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014015/* return 1 if successful, 0 if the proper config is not found,
14016 * or a negative error code
14017 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014018static int alc861_parse_auto_config(struct hda_codec *codec)
14019{
14020 struct alc_spec *spec = codec->spec;
14021 int err;
14022 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
14023
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014024 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14025 alc861_ignore);
14026 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014027 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014028 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014029 return 0; /* can't find valid BIOS pin config */
14030
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014031 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
14032 if (err < 0)
14033 return err;
14034 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
14035 if (err < 0)
14036 return err;
14037 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
14038 if (err < 0)
14039 return err;
14040 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
14041 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014042 return err;
14043
14044 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14045
Takashi Iwai0852d7a2009-02-11 11:35:15 +010014046 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014047 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
14048
Takashi Iwai603c4012008-07-30 15:01:44 +020014049 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014050 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010014051
Takashi Iwaid88897e2008-10-31 15:01:37 +010014052 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010014053
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020014054 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014055 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010014056
14057 spec->adc_nids = alc861_adc_nids;
14058 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014059 set_capture_mixer(spec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014060
Takashi Iwai4a79ba32009-04-22 16:31:35 +020014061 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b);
14062
Kailang Yangdf694da2005-12-05 19:42:22 +010014063 return 1;
14064}
14065
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014066/* additional initialization for auto-configuration model */
14067static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010014068{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014069 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014070 alc861_auto_init_multi_out(codec);
14071 alc861_auto_init_hp_out(codec);
14072 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014073 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014074 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014075}
14076
Takashi Iwaicb53c622007-08-10 17:21:45 +020014077#ifdef CONFIG_SND_HDA_POWER_SAVE
14078static struct hda_amp_list alc861_loopbacks[] = {
14079 { 0x15, HDA_INPUT, 0 },
14080 { 0x15, HDA_INPUT, 1 },
14081 { 0x15, HDA_INPUT, 2 },
14082 { 0x15, HDA_INPUT, 3 },
14083 { } /* end */
14084};
14085#endif
14086
Kailang Yangdf694da2005-12-05 19:42:22 +010014087
14088/*
14089 * configuration and preset
14090 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014091static const char *alc861_models[ALC861_MODEL_LAST] = {
14092 [ALC861_3ST] = "3stack",
14093 [ALC660_3ST] = "3stack-660",
14094 [ALC861_3ST_DIG] = "3stack-dig",
14095 [ALC861_6ST_DIG] = "6stack-dig",
14096 [ALC861_UNIWILL_M31] = "uniwill-m31",
14097 [ALC861_TOSHIBA] = "toshiba",
14098 [ALC861_ASUS] = "asus",
14099 [ALC861_ASUS_LAPTOP] = "asus-laptop",
14100 [ALC861_AUTO] = "auto",
14101};
14102
14103static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010014104 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014105 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14106 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14107 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014108 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020014109 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010014110 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020014111 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
14112 * Any other models that need this preset?
14113 */
14114 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020014115 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
14116 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014117 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
14118 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
14119 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
14120 /* FIXME: the below seems conflict */
14121 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
14122 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
14123 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010014124 {}
14125};
14126
14127static struct alc_config_preset alc861_presets[] = {
14128 [ALC861_3ST] = {
14129 .mixers = { alc861_3ST_mixer },
14130 .init_verbs = { alc861_threestack_init_verbs },
14131 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14132 .dac_nids = alc861_dac_nids,
14133 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14134 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014135 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014136 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14137 .adc_nids = alc861_adc_nids,
14138 .input_mux = &alc861_capture_source,
14139 },
14140 [ALC861_3ST_DIG] = {
14141 .mixers = { alc861_base_mixer },
14142 .init_verbs = { alc861_threestack_init_verbs },
14143 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14144 .dac_nids = alc861_dac_nids,
14145 .dig_out_nid = ALC861_DIGOUT_NID,
14146 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14147 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014148 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014149 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14150 .adc_nids = alc861_adc_nids,
14151 .input_mux = &alc861_capture_source,
14152 },
14153 [ALC861_6ST_DIG] = {
14154 .mixers = { alc861_base_mixer },
14155 .init_verbs = { alc861_base_init_verbs },
14156 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14157 .dac_nids = alc861_dac_nids,
14158 .dig_out_nid = ALC861_DIGOUT_NID,
14159 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
14160 .channel_mode = alc861_8ch_modes,
14161 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14162 .adc_nids = alc861_adc_nids,
14163 .input_mux = &alc861_capture_source,
14164 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014165 [ALC660_3ST] = {
14166 .mixers = { alc861_3ST_mixer },
14167 .init_verbs = { alc861_threestack_init_verbs },
14168 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
14169 .dac_nids = alc660_dac_nids,
14170 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14171 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014172 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014173 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14174 .adc_nids = alc861_adc_nids,
14175 .input_mux = &alc861_capture_source,
14176 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014177 [ALC861_UNIWILL_M31] = {
14178 .mixers = { alc861_uniwill_m31_mixer },
14179 .init_verbs = { alc861_uniwill_m31_init_verbs },
14180 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14181 .dac_nids = alc861_dac_nids,
14182 .dig_out_nid = ALC861_DIGOUT_NID,
14183 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
14184 .channel_mode = alc861_uniwill_m31_modes,
14185 .need_dac_fix = 1,
14186 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14187 .adc_nids = alc861_adc_nids,
14188 .input_mux = &alc861_capture_source,
14189 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014190 [ALC861_TOSHIBA] = {
14191 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014192 .init_verbs = { alc861_base_init_verbs,
14193 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014194 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14195 .dac_nids = alc861_dac_nids,
14196 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14197 .channel_mode = alc883_3ST_2ch_modes,
14198 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14199 .adc_nids = alc861_adc_nids,
14200 .input_mux = &alc861_capture_source,
14201 .unsol_event = alc861_toshiba_unsol_event,
14202 .init_hook = alc861_toshiba_automute,
14203 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014204 [ALC861_ASUS] = {
14205 .mixers = { alc861_asus_mixer },
14206 .init_verbs = { alc861_asus_init_verbs },
14207 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14208 .dac_nids = alc861_dac_nids,
14209 .dig_out_nid = ALC861_DIGOUT_NID,
14210 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
14211 .channel_mode = alc861_asus_modes,
14212 .need_dac_fix = 1,
14213 .hp_nid = 0x06,
14214 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14215 .adc_nids = alc861_adc_nids,
14216 .input_mux = &alc861_capture_source,
14217 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014218 [ALC861_ASUS_LAPTOP] = {
14219 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
14220 .init_verbs = { alc861_asus_init_verbs,
14221 alc861_asus_laptop_init_verbs },
14222 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14223 .dac_nids = alc861_dac_nids,
14224 .dig_out_nid = ALC861_DIGOUT_NID,
14225 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14226 .channel_mode = alc883_3ST_2ch_modes,
14227 .need_dac_fix = 1,
14228 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14229 .adc_nids = alc861_adc_nids,
14230 .input_mux = &alc861_capture_source,
14231 },
14232};
Kailang Yangdf694da2005-12-05 19:42:22 +010014233
14234
14235static int patch_alc861(struct hda_codec *codec)
14236{
14237 struct alc_spec *spec;
14238 int board_config;
14239 int err;
14240
Robert P. J. Daydc041e02006-12-19 14:44:15 +010014241 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010014242 if (spec == NULL)
14243 return -ENOMEM;
14244
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014245 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014246
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014247 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
14248 alc861_models,
14249 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014250
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014251 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014252 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
14253 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010014254 board_config = ALC861_AUTO;
14255 }
14256
14257 if (board_config == ALC861_AUTO) {
14258 /* automatic parse from the BIOS config */
14259 err = alc861_parse_auto_config(codec);
14260 if (err < 0) {
14261 alc_free(codec);
14262 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014263 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014264 printk(KERN_INFO
14265 "hda_codec: Cannot set up configuration "
14266 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010014267 board_config = ALC861_3ST_DIG;
14268 }
14269 }
14270
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014271 err = snd_hda_attach_beep_device(codec, 0x23);
14272 if (err < 0) {
14273 alc_free(codec);
14274 return err;
14275 }
14276
Kailang Yangdf694da2005-12-05 19:42:22 +010014277 if (board_config != ALC861_AUTO)
14278 setup_preset(spec, &alc861_presets[board_config]);
14279
14280 spec->stream_name_analog = "ALC861 Analog";
14281 spec->stream_analog_playback = &alc861_pcm_analog_playback;
14282 spec->stream_analog_capture = &alc861_pcm_analog_capture;
14283
14284 spec->stream_name_digital = "ALC861 Digital";
14285 spec->stream_digital_playback = &alc861_pcm_digital_playback;
14286 spec->stream_digital_capture = &alc861_pcm_digital_capture;
14287
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014288 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
14289
Takashi Iwai2134ea42008-01-10 16:53:55 +010014290 spec->vmaster_nid = 0x03;
14291
Kailang Yangdf694da2005-12-05 19:42:22 +010014292 codec->patch_ops = alc_patch_ops;
14293 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014294 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014295#ifdef CONFIG_SND_HDA_POWER_SAVE
14296 if (!spec->loopback.amplist)
14297 spec->loopback.amplist = alc861_loopbacks;
14298#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010014299 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020014300
Kailang Yangdf694da2005-12-05 19:42:22 +010014301 return 0;
14302}
14303
14304/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014305 * ALC861-VD support
14306 *
14307 * Based on ALC882
14308 *
14309 * In addition, an independent DAC
14310 */
14311#define ALC861VD_DIGOUT_NID 0x06
14312
14313static hda_nid_t alc861vd_dac_nids[4] = {
14314 /* front, surr, clfe, side surr */
14315 0x02, 0x03, 0x04, 0x05
14316};
14317
14318/* dac_nids for ALC660vd are in a different order - according to
14319 * Realtek's driver.
14320 * This should probably tesult in a different mixer for 6stack models
14321 * of ALC660vd codecs, but for now there is only 3stack mixer
14322 * - and it is the same as in 861vd.
14323 * adc_nids in ALC660vd are (is) the same as in 861vd
14324 */
14325static hda_nid_t alc660vd_dac_nids[3] = {
14326 /* front, rear, clfe, rear_surr */
14327 0x02, 0x04, 0x03
14328};
14329
14330static hda_nid_t alc861vd_adc_nids[1] = {
14331 /* ADC0 */
14332 0x09,
14333};
14334
Takashi Iwaie1406342008-02-11 18:32:32 +010014335static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
14336
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014337/* input MUX */
14338/* FIXME: should be a matrix-type input source selection */
14339static struct hda_input_mux alc861vd_capture_source = {
14340 .num_items = 4,
14341 .items = {
14342 { "Mic", 0x0 },
14343 { "Front Mic", 0x1 },
14344 { "Line", 0x2 },
14345 { "CD", 0x4 },
14346 },
14347};
14348
Kailang Yang272a5272007-05-14 11:00:38 +020014349static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010014350 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020014351 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010014352 { "Ext Mic", 0x0 },
14353 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020014354 },
14355};
14356
Kailang Yangd1a991a2007-08-15 16:21:59 +020014357static struct hda_input_mux alc861vd_hp_capture_source = {
14358 .num_items = 2,
14359 .items = {
14360 { "Front Mic", 0x0 },
14361 { "ATAPI Mic", 0x1 },
14362 },
14363};
14364
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014365/*
14366 * 2ch mode
14367 */
14368static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
14369 { 2, NULL }
14370};
14371
14372/*
14373 * 6ch mode
14374 */
14375static struct hda_verb alc861vd_6stack_ch6_init[] = {
14376 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14377 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14378 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14379 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14380 { } /* end */
14381};
14382
14383/*
14384 * 8ch mode
14385 */
14386static struct hda_verb alc861vd_6stack_ch8_init[] = {
14387 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14388 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14389 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14390 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14391 { } /* end */
14392};
14393
14394static struct hda_channel_mode alc861vd_6stack_modes[2] = {
14395 { 6, alc861vd_6stack_ch6_init },
14396 { 8, alc861vd_6stack_ch8_init },
14397};
14398
14399static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
14400 {
14401 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14402 .name = "Channel Mode",
14403 .info = alc_ch_mode_info,
14404 .get = alc_ch_mode_get,
14405 .put = alc_ch_mode_put,
14406 },
14407 { } /* end */
14408};
14409
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014410/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
14411 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
14412 */
14413static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
14414 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14415 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14416
14417 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14418 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
14419
14420 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
14421 HDA_OUTPUT),
14422 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
14423 HDA_OUTPUT),
14424 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
14425 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
14426
14427 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
14428 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
14429
14430 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14431
14432 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14433 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14434 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14435
14436 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14437 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14438 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14439
14440 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14441 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14442
14443 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14444 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14445
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014446 { } /* end */
14447};
14448
14449static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
14450 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14451 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14452
14453 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14454
14455 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14456 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14457 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14458
14459 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14460 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14461 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14462
14463 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14464 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14465
14466 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14467 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14468
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014469 { } /* end */
14470};
14471
Kailang Yangbdd148a2007-05-08 15:19:08 +020014472static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
14473 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14474 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
14475 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14476
14477 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14478
14479 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14480 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14481 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14482
14483 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14484 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14485 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14486
14487 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14488 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14489
14490 { } /* end */
14491};
14492
Tobin Davisb419f342008-03-07 11:57:51 +010014493/* Pin assignment: Speaker=0x14, HP = 0x15,
14494 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020014495 */
14496static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010014497 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14498 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014499 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14500 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010014501 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
14502 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14503 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14504 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
14505 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14506 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014507 { } /* end */
14508};
14509
Kailang Yangd1a991a2007-08-15 16:21:59 +020014510/* Pin assignment: Speaker=0x14, Line-out = 0x15,
14511 * Front Mic=0x18, ATAPI Mic = 0x19,
14512 */
14513static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
14514 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14515 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14516 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14517 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
14518 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14519 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14520 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14521 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020014522
Kailang Yangd1a991a2007-08-15 16:21:59 +020014523 { } /* end */
14524};
14525
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014526/*
14527 * generic initialization of ADC, input mixers and output mixers
14528 */
14529static struct hda_verb alc861vd_volume_init_verbs[] = {
14530 /*
14531 * Unmute ADC0 and set the default input to mic-in
14532 */
14533 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14534 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14535
14536 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
14537 * the analog-loopback mixer widget
14538 */
14539 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020014540 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14541 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14542 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14543 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14544 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014545
14546 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020014547 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14548 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14549 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014550 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014551
14552 /*
14553 * Set up output mixers (0x02 - 0x05)
14554 */
14555 /* set vol=0 to output mixers */
14556 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14557 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14558 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14559 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14560
14561 /* set up input amps for analog loopback */
14562 /* Amp Indices: DAC = 0, mixer = 1 */
14563 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14564 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14565 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14566 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14567 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14568 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14569 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14570 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14571
14572 { }
14573};
14574
14575/*
14576 * 3-stack pin configuration:
14577 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
14578 */
14579static struct hda_verb alc861vd_3stack_init_verbs[] = {
14580 /*
14581 * Set pin mode and muting
14582 */
14583 /* set front pin widgets 0x14 for output */
14584 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14585 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14586 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14587
14588 /* Mic (rear) pin: input vref at 80% */
14589 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14590 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14591 /* Front Mic pin: input vref at 80% */
14592 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14593 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14594 /* Line In pin: input */
14595 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14596 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14597 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14598 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14599 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14600 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14601 /* CD pin widget for input */
14602 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14603
14604 { }
14605};
14606
14607/*
14608 * 6-stack pin configuration:
14609 */
14610static struct hda_verb alc861vd_6stack_init_verbs[] = {
14611 /*
14612 * Set pin mode and muting
14613 */
14614 /* set front pin widgets 0x14 for output */
14615 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14616 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14617 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14618
14619 /* Rear Pin: output 1 (0x0d) */
14620 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14621 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14622 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14623 /* CLFE Pin: output 2 (0x0e) */
14624 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14625 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14626 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
14627 /* Side Pin: output 3 (0x0f) */
14628 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14629 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14630 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
14631
14632 /* Mic (rear) pin: input vref at 80% */
14633 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14634 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14635 /* Front Mic pin: input vref at 80% */
14636 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14637 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14638 /* Line In pin: input */
14639 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14640 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14641 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14642 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14643 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14644 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14645 /* CD pin widget for input */
14646 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14647
14648 { }
14649};
14650
Kailang Yangbdd148a2007-05-08 15:19:08 +020014651static struct hda_verb alc861vd_eapd_verbs[] = {
14652 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14653 { }
14654};
14655
Kailang Yangf9423e72008-05-27 12:32:25 +020014656static struct hda_verb alc660vd_eapd_verbs[] = {
14657 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14658 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
14659 { }
14660};
14661
Kailang Yangbdd148a2007-05-08 15:19:08 +020014662static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
14663 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14664 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14665 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
14666 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020014667 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020014668 {}
14669};
14670
14671/* toggle speaker-output according to the hp-jack state */
14672static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
14673{
14674 unsigned int present;
14675 unsigned char bits;
14676
14677 present = snd_hda_codec_read(codec, 0x1b, 0,
14678 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014679 bits = present ? HDA_AMP_MUTE : 0;
14680 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14681 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014682}
14683
14684static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
14685{
14686 unsigned int present;
14687 unsigned char bits;
14688
14689 present = snd_hda_codec_read(codec, 0x18, 0,
14690 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014691 bits = present ? HDA_AMP_MUTE : 0;
14692 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
14693 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014694}
14695
14696static void alc861vd_lenovo_automute(struct hda_codec *codec)
14697{
14698 alc861vd_lenovo_hp_automute(codec);
14699 alc861vd_lenovo_mic_automute(codec);
14700}
14701
14702static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
14703 unsigned int res)
14704{
14705 switch (res >> 26) {
14706 case ALC880_HP_EVENT:
14707 alc861vd_lenovo_hp_automute(codec);
14708 break;
14709 case ALC880_MIC_EVENT:
14710 alc861vd_lenovo_mic_automute(codec);
14711 break;
14712 }
14713}
14714
Kailang Yang272a5272007-05-14 11:00:38 +020014715static struct hda_verb alc861vd_dallas_verbs[] = {
14716 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14717 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14718 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14719 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14720
14721 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14722 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14723 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14724 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14725 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14726 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14727 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14728 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014729
Kailang Yang272a5272007-05-14 11:00:38 +020014730 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14731 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14732 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14733 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14734 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14735 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14736 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14737 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14738
14739 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14740 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14741 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14742 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14743 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14744 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14745 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14746 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14747
14748 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14749 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14750 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14751 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
14752
14753 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014754 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020014755 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14756
14757 { } /* end */
14758};
14759
14760/* toggle speaker-output according to the hp-jack state */
14761static void alc861vd_dallas_automute(struct hda_codec *codec)
14762{
14763 unsigned int present;
14764
14765 present = snd_hda_codec_read(codec, 0x15, 0,
14766 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014767 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14768 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +020014769}
14770
14771static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
14772{
14773 if ((res >> 26) == ALC880_HP_EVENT)
14774 alc861vd_dallas_automute(codec);
14775}
14776
Takashi Iwaicb53c622007-08-10 17:21:45 +020014777#ifdef CONFIG_SND_HDA_POWER_SAVE
14778#define alc861vd_loopbacks alc880_loopbacks
14779#endif
14780
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014781/* pcm configuration: identiacal with ALC880 */
14782#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
14783#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
14784#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
14785#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
14786
14787/*
14788 * configuration and preset
14789 */
14790static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
14791 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020014792 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010014793 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014794 [ALC861VD_3ST] = "3stack",
14795 [ALC861VD_3ST_DIG] = "3stack-digout",
14796 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020014797 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020014798 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020014799 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014800 [ALC861VD_AUTO] = "auto",
14801};
14802
14803static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014804 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
14805 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010014806 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014807 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Takashi Iwai13c94742008-11-05 08:06:08 +010014808 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020014809 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014810 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014811 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020014812 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Kailang Yang272a5272007-05-14 11:00:38 +020014813 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Takashi Iwai542d7c62007-08-16 18:57:30 +020014814 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010014815 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020014816 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010014817 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020014818 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014819 {}
14820};
14821
14822static struct alc_config_preset alc861vd_presets[] = {
14823 [ALC660VD_3ST] = {
14824 .mixers = { alc861vd_3st_mixer },
14825 .init_verbs = { alc861vd_volume_init_verbs,
14826 alc861vd_3stack_init_verbs },
14827 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14828 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014829 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14830 .channel_mode = alc861vd_3stack_2ch_modes,
14831 .input_mux = &alc861vd_capture_source,
14832 },
Mike Crash6963f842007-06-25 12:12:51 +020014833 [ALC660VD_3ST_DIG] = {
14834 .mixers = { alc861vd_3st_mixer },
14835 .init_verbs = { alc861vd_volume_init_verbs,
14836 alc861vd_3stack_init_verbs },
14837 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14838 .dac_nids = alc660vd_dac_nids,
14839 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020014840 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14841 .channel_mode = alc861vd_3stack_2ch_modes,
14842 .input_mux = &alc861vd_capture_source,
14843 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014844 [ALC861VD_3ST] = {
14845 .mixers = { alc861vd_3st_mixer },
14846 .init_verbs = { alc861vd_volume_init_verbs,
14847 alc861vd_3stack_init_verbs },
14848 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14849 .dac_nids = alc861vd_dac_nids,
14850 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14851 .channel_mode = alc861vd_3stack_2ch_modes,
14852 .input_mux = &alc861vd_capture_source,
14853 },
14854 [ALC861VD_3ST_DIG] = {
14855 .mixers = { alc861vd_3st_mixer },
14856 .init_verbs = { alc861vd_volume_init_verbs,
14857 alc861vd_3stack_init_verbs },
14858 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14859 .dac_nids = alc861vd_dac_nids,
14860 .dig_out_nid = ALC861VD_DIGOUT_NID,
14861 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14862 .channel_mode = alc861vd_3stack_2ch_modes,
14863 .input_mux = &alc861vd_capture_source,
14864 },
14865 [ALC861VD_6ST_DIG] = {
14866 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
14867 .init_verbs = { alc861vd_volume_init_verbs,
14868 alc861vd_6stack_init_verbs },
14869 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14870 .dac_nids = alc861vd_dac_nids,
14871 .dig_out_nid = ALC861VD_DIGOUT_NID,
14872 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
14873 .channel_mode = alc861vd_6stack_modes,
14874 .input_mux = &alc861vd_capture_source,
14875 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020014876 [ALC861VD_LENOVO] = {
14877 .mixers = { alc861vd_lenovo_mixer },
14878 .init_verbs = { alc861vd_volume_init_verbs,
14879 alc861vd_3stack_init_verbs,
14880 alc861vd_eapd_verbs,
14881 alc861vd_lenovo_unsol_verbs },
14882 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14883 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020014884 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14885 .channel_mode = alc861vd_3stack_2ch_modes,
14886 .input_mux = &alc861vd_capture_source,
14887 .unsol_event = alc861vd_lenovo_unsol_event,
14888 .init_hook = alc861vd_lenovo_automute,
14889 },
Kailang Yang272a5272007-05-14 11:00:38 +020014890 [ALC861VD_DALLAS] = {
14891 .mixers = { alc861vd_dallas_mixer },
14892 .init_verbs = { alc861vd_dallas_verbs },
14893 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14894 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020014895 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14896 .channel_mode = alc861vd_3stack_2ch_modes,
14897 .input_mux = &alc861vd_dallas_capture_source,
14898 .unsol_event = alc861vd_dallas_unsol_event,
14899 .init_hook = alc861vd_dallas_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014900 },
14901 [ALC861VD_HP] = {
14902 .mixers = { alc861vd_hp_mixer },
14903 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
14904 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14905 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014906 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014907 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14908 .channel_mode = alc861vd_3stack_2ch_modes,
14909 .input_mux = &alc861vd_hp_capture_source,
14910 .unsol_event = alc861vd_dallas_unsol_event,
14911 .init_hook = alc861vd_dallas_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020014912 },
Takashi Iwai13c94742008-11-05 08:06:08 +010014913 [ALC660VD_ASUS_V1S] = {
14914 .mixers = { alc861vd_lenovo_mixer },
14915 .init_verbs = { alc861vd_volume_init_verbs,
14916 alc861vd_3stack_init_verbs,
14917 alc861vd_eapd_verbs,
14918 alc861vd_lenovo_unsol_verbs },
14919 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14920 .dac_nids = alc660vd_dac_nids,
14921 .dig_out_nid = ALC861VD_DIGOUT_NID,
14922 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14923 .channel_mode = alc861vd_3stack_2ch_modes,
14924 .input_mux = &alc861vd_capture_source,
14925 .unsol_event = alc861vd_lenovo_unsol_event,
14926 .init_hook = alc861vd_lenovo_automute,
14927 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014928};
14929
14930/*
14931 * BIOS auto configuration
14932 */
14933static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
14934 hda_nid_t nid, int pin_type, int dac_idx)
14935{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014936 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014937}
14938
14939static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
14940{
14941 struct alc_spec *spec = codec->spec;
14942 int i;
14943
14944 for (i = 0; i <= HDA_SIDE; i++) {
14945 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014946 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014947 if (nid)
14948 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014949 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014950 }
14951}
14952
14953
14954static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
14955{
14956 struct alc_spec *spec = codec->spec;
14957 hda_nid_t pin;
14958
14959 pin = spec->autocfg.hp_pins[0];
14960 if (pin) /* connect to front and use dac 0 */
14961 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014962 pin = spec->autocfg.speaker_pins[0];
14963 if (pin)
14964 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014965}
14966
14967#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
14968#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
14969
14970static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
14971{
14972 struct alc_spec *spec = codec->spec;
14973 int i;
14974
14975 for (i = 0; i < AUTO_PIN_LAST; i++) {
14976 hda_nid_t nid = spec->autocfg.input_pins[i];
14977 if (alc861vd_is_input_pin(nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010014978 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +010014979 if (nid != ALC861VD_PIN_CD_NID &&
14980 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014981 snd_hda_codec_write(codec, nid, 0,
14982 AC_VERB_SET_AMP_GAIN_MUTE,
14983 AMP_OUT_MUTE);
14984 }
14985 }
14986}
14987
Takashi Iwaif511b012008-08-15 16:46:42 +020014988#define alc861vd_auto_init_input_src alc882_auto_init_input_src
14989
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014990#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
14991#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
14992
14993/* add playback controls from the parsed DAC table */
14994/* Based on ALC880 version. But ALC861VD has separate,
14995 * different NIDs for mute/unmute switch and volume control */
14996static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
14997 const struct auto_pin_cfg *cfg)
14998{
14999 char name[32];
15000 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
15001 hda_nid_t nid_v, nid_s;
15002 int i, err;
15003
15004 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015005 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015006 continue;
15007 nid_v = alc861vd_idx_to_mixer_vol(
15008 alc880_dac_to_idx(
15009 spec->multiout.dac_nids[i]));
15010 nid_s = alc861vd_idx_to_mixer_switch(
15011 alc880_dac_to_idx(
15012 spec->multiout.dac_nids[i]));
15013
15014 if (i == 2) {
15015 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015016 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15017 "Center Playback Volume",
15018 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
15019 HDA_OUTPUT));
15020 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015021 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015022 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15023 "LFE Playback Volume",
15024 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
15025 HDA_OUTPUT));
15026 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015027 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015028 err = add_control(spec, ALC_CTL_BIND_MUTE,
15029 "Center Playback Switch",
15030 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
15031 HDA_INPUT));
15032 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015033 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015034 err = add_control(spec, ALC_CTL_BIND_MUTE,
15035 "LFE Playback Switch",
15036 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
15037 HDA_INPUT));
15038 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015039 return err;
15040 } else {
15041 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015042 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
15043 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
15044 HDA_OUTPUT));
15045 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015046 return err;
15047 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015048 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015049 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015050 HDA_INPUT));
15051 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015052 return err;
15053 }
15054 }
15055 return 0;
15056}
15057
15058/* add playback controls for speaker and HP outputs */
15059/* Based on ALC880 version. But ALC861VD has separate,
15060 * different NIDs for mute/unmute switch and volume control */
15061static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
15062 hda_nid_t pin, const char *pfx)
15063{
15064 hda_nid_t nid_v, nid_s;
15065 int err;
15066 char name[32];
15067
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015068 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015069 return 0;
15070
15071 if (alc880_is_fixed_pin(pin)) {
15072 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
15073 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015074 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015075 spec->multiout.hp_nid = nid_v;
15076 else
15077 spec->multiout.extra_out_nid[0] = nid_v;
15078 /* control HP volume/switch on the output mixer amp */
15079 nid_v = alc861vd_idx_to_mixer_vol(
15080 alc880_fixed_pin_idx(pin));
15081 nid_s = alc861vd_idx_to_mixer_switch(
15082 alc880_fixed_pin_idx(pin));
15083
15084 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015085 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
15086 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
15087 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015088 return err;
15089 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015090 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
15091 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
15092 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015093 return err;
15094 } else if (alc880_is_multi_pin(pin)) {
15095 /* set manual connection */
15096 /* we have only a switch on HP-out PIN */
15097 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015098 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
15099 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
15100 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015101 return err;
15102 }
15103 return 0;
15104}
15105
15106/* parse the BIOS configuration and set up the alc_spec
15107 * return 1 if successful, 0 if the proper config is not found,
15108 * or a negative error code
15109 * Based on ALC880 version - had to change it to override
15110 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
15111static int alc861vd_parse_auto_config(struct hda_codec *codec)
15112{
15113 struct alc_spec *spec = codec->spec;
15114 int err;
15115 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
15116
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015117 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15118 alc861vd_ignore);
15119 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015120 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015121 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015122 return 0; /* can't find valid BIOS pin config */
15123
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015124 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
15125 if (err < 0)
15126 return err;
15127 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
15128 if (err < 0)
15129 return err;
15130 err = alc861vd_auto_create_extra_out(spec,
15131 spec->autocfg.speaker_pins[0],
15132 "Speaker");
15133 if (err < 0)
15134 return err;
15135 err = alc861vd_auto_create_extra_out(spec,
15136 spec->autocfg.hp_pins[0],
15137 "Headphone");
15138 if (err < 0)
15139 return err;
15140 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
15141 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015142 return err;
15143
15144 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15145
Takashi Iwai0852d7a2009-02-11 11:35:15 +010015146 if (spec->autocfg.dig_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015147 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
15148
Takashi Iwai603c4012008-07-30 15:01:44 +020015149 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010015150 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015151
Takashi Iwaid88897e2008-10-31 15:01:37 +010015152 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015153
15154 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015155 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015156
Takashi Iwai776e1842007-08-29 15:07:11 +020015157 err = alc_auto_add_mic_boost(codec);
15158 if (err < 0)
15159 return err;
15160
Takashi Iwai4a79ba32009-04-22 16:31:35 +020015161 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
15162
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015163 return 1;
15164}
15165
15166/* additional initialization for auto-configuration model */
15167static void alc861vd_auto_init(struct hda_codec *codec)
15168{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015169 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015170 alc861vd_auto_init_multi_out(codec);
15171 alc861vd_auto_init_hp_out(codec);
15172 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020015173 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015174 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020015175 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015176}
15177
15178static int patch_alc861vd(struct hda_codec *codec)
15179{
15180 struct alc_spec *spec;
15181 int err, board_config;
15182
15183 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15184 if (spec == NULL)
15185 return -ENOMEM;
15186
15187 codec->spec = spec;
15188
15189 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
15190 alc861vd_models,
15191 alc861vd_cfg_tbl);
15192
15193 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
15194 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
15195 "ALC861VD, trying auto-probe from BIOS...\n");
15196 board_config = ALC861VD_AUTO;
15197 }
15198
15199 if (board_config == ALC861VD_AUTO) {
15200 /* automatic parse from the BIOS config */
15201 err = alc861vd_parse_auto_config(codec);
15202 if (err < 0) {
15203 alc_free(codec);
15204 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015205 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015206 printk(KERN_INFO
15207 "hda_codec: Cannot set up configuration "
15208 "from BIOS. Using base mode...\n");
15209 board_config = ALC861VD_3ST;
15210 }
15211 }
15212
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015213 err = snd_hda_attach_beep_device(codec, 0x23);
15214 if (err < 0) {
15215 alc_free(codec);
15216 return err;
15217 }
15218
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015219 if (board_config != ALC861VD_AUTO)
15220 setup_preset(spec, &alc861vd_presets[board_config]);
15221
Kailang Yang2f893282008-05-27 12:14:47 +020015222 if (codec->vendor_id == 0x10ec0660) {
15223 spec->stream_name_analog = "ALC660-VD Analog";
15224 spec->stream_name_digital = "ALC660-VD Digital";
Kailang Yangf9423e72008-05-27 12:32:25 +020015225 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010015226 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020015227 } else {
15228 spec->stream_name_analog = "ALC861VD Analog";
15229 spec->stream_name_digital = "ALC861VD Digital";
15230 }
15231
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015232 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
15233 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
15234
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015235 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
15236 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
15237
15238 spec->adc_nids = alc861vd_adc_nids;
15239 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +010015240 spec->capsrc_nids = alc861vd_capsrc_nids;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015241 spec->capture_style = CAPT_MIX;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015242
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015243 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015244 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015245
Takashi Iwai2134ea42008-01-10 16:53:55 +010015246 spec->vmaster_nid = 0x02;
15247
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015248 codec->patch_ops = alc_patch_ops;
15249
15250 if (board_config == ALC861VD_AUTO)
15251 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015252#ifdef CONFIG_SND_HDA_POWER_SAVE
15253 if (!spec->loopback.amplist)
15254 spec->loopback.amplist = alc861vd_loopbacks;
15255#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010015256 codec->proc_widget_hook = print_realtek_coef;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015257
15258 return 0;
15259}
15260
15261/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015262 * ALC662 support
15263 *
15264 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
15265 * configuration. Each pin widget can choose any input DACs and a mixer.
15266 * Each ADC is connected from a mixer of all inputs. This makes possible
15267 * 6-channel independent captures.
15268 *
15269 * In addition, an independent DAC for the multi-playback (not used in this
15270 * driver yet).
15271 */
15272#define ALC662_DIGOUT_NID 0x06
15273#define ALC662_DIGIN_NID 0x0a
15274
15275static hda_nid_t alc662_dac_nids[4] = {
15276 /* front, rear, clfe, rear_surr */
15277 0x02, 0x03, 0x04
15278};
15279
Kailang Yang622e84c2009-04-21 07:39:04 +020015280static hda_nid_t alc272_dac_nids[2] = {
15281 0x02, 0x03
15282};
15283
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015284static hda_nid_t alc662_adc_nids[1] = {
15285 /* ADC1-2 */
15286 0x09,
15287};
Takashi Iwaie1406342008-02-11 18:32:32 +010015288
Kailang Yang622e84c2009-04-21 07:39:04 +020015289static hda_nid_t alc272_adc_nids[1] = {
15290 /* ADC1-2 */
15291 0x08,
15292};
15293
Kailang Yang77a261b2008-02-19 11:38:05 +010015294static hda_nid_t alc662_capsrc_nids[1] = { 0x22 };
Kailang Yang622e84c2009-04-21 07:39:04 +020015295static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
15296
Takashi Iwaie1406342008-02-11 18:32:32 +010015297
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015298/* input MUX */
15299/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015300static struct hda_input_mux alc662_capture_source = {
15301 .num_items = 4,
15302 .items = {
15303 { "Mic", 0x0 },
15304 { "Front Mic", 0x1 },
15305 { "Line", 0x2 },
15306 { "CD", 0x4 },
15307 },
15308};
15309
15310static struct hda_input_mux alc662_lenovo_101e_capture_source = {
15311 .num_items = 2,
15312 .items = {
15313 { "Mic", 0x1 },
15314 { "Line", 0x2 },
15315 },
15316};
Kailang Yang291702f2007-10-16 14:28:03 +020015317
15318static struct hda_input_mux alc662_eeepc_capture_source = {
15319 .num_items = 2,
15320 .items = {
15321 { "i-Mic", 0x1 },
15322 { "e-Mic", 0x0 },
15323 },
15324};
15325
Kailang Yang6dda9f42008-05-27 12:05:31 +020015326static struct hda_input_mux alc663_capture_source = {
15327 .num_items = 3,
15328 .items = {
15329 { "Mic", 0x0 },
15330 { "Front Mic", 0x1 },
15331 { "Line", 0x2 },
15332 },
15333};
15334
15335static struct hda_input_mux alc663_m51va_capture_source = {
15336 .num_items = 2,
15337 .items = {
15338 { "Ext-Mic", 0x0 },
15339 { "D-Mic", 0x9 },
15340 },
15341};
15342
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015343/*
15344 * 2ch mode
15345 */
15346static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
15347 { 2, NULL }
15348};
15349
15350/*
15351 * 2ch mode
15352 */
15353static struct hda_verb alc662_3ST_ch2_init[] = {
15354 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
15355 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15356 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
15357 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15358 { } /* end */
15359};
15360
15361/*
15362 * 6ch mode
15363 */
15364static struct hda_verb alc662_3ST_ch6_init[] = {
15365 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15366 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15367 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
15368 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15369 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15370 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
15371 { } /* end */
15372};
15373
15374static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
15375 { 2, alc662_3ST_ch2_init },
15376 { 6, alc662_3ST_ch6_init },
15377};
15378
15379/*
15380 * 2ch mode
15381 */
15382static struct hda_verb alc662_sixstack_ch6_init[] = {
15383 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15384 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15385 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15386 { } /* end */
15387};
15388
15389/*
15390 * 6ch mode
15391 */
15392static struct hda_verb alc662_sixstack_ch8_init[] = {
15393 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15394 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15395 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15396 { } /* end */
15397};
15398
15399static struct hda_channel_mode alc662_5stack_modes[2] = {
15400 { 2, alc662_sixstack_ch6_init },
15401 { 6, alc662_sixstack_ch8_init },
15402};
15403
15404/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15405 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15406 */
15407
15408static struct snd_kcontrol_new alc662_base_mixer[] = {
15409 /* output mixer control */
15410 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015411 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015412 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015413 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015414 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15415 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015416 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15417 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015418 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15419
15420 /*Input mixer control */
15421 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
15422 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
15423 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
15424 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
15425 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
15426 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
15427 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
15428 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015429 { } /* end */
15430};
15431
15432static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
15433 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015434 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015435 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15436 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15437 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15438 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15439 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15440 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15441 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15442 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15443 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015444 { } /* end */
15445};
15446
15447static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
15448 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015449 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015450 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015451 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015452 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15453 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015454 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15455 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015456 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15457 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15458 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15459 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15460 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15461 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15462 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15463 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15464 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015465 { } /* end */
15466};
15467
15468static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
15469 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15470 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010015471 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15472 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015473 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15474 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15475 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15476 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15477 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015478 { } /* end */
15479};
15480
Kailang Yang291702f2007-10-16 14:28:03 +020015481static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010015482 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020015483
Herton Ronaldo Krzesinskib4818492008-02-23 11:34:12 +010015484 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15485 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020015486
15487 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
15488 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15489 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15490
15491 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
15492 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15493 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15494 { } /* end */
15495};
15496
Kailang Yang8c427222008-01-10 13:03:59 +010015497static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai31bffaa2008-02-27 16:10:44 +010015498 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15499 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015500 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15501 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
15502 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15503 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
15504 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
15505 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010015506 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015507 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
15508 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15509 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15510 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15511 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15512 { } /* end */
15513};
15514
Kailang Yangf1d4e282008-08-26 14:03:29 +020015515static struct hda_bind_ctls alc663_asus_bind_master_vol = {
15516 .ops = &snd_hda_bind_vol,
15517 .values = {
15518 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15519 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
15520 0
15521 },
15522};
15523
15524static struct hda_bind_ctls alc663_asus_one_bind_switch = {
15525 .ops = &snd_hda_bind_sw,
15526 .values = {
15527 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15528 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15529 0
15530 },
15531};
15532
Kailang Yang6dda9f42008-05-27 12:05:31 +020015533static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015534 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15535 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
15536 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15537 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15538 { } /* end */
15539};
15540
15541static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
15542 .ops = &snd_hda_bind_sw,
15543 .values = {
15544 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15545 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15546 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15547 0
15548 },
15549};
15550
15551static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
15552 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15553 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
15554 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15555 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15556 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15557 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15558
15559 { } /* end */
15560};
15561
15562static struct hda_bind_ctls alc663_asus_four_bind_switch = {
15563 .ops = &snd_hda_bind_sw,
15564 .values = {
15565 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15566 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15567 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
15568 0
15569 },
15570};
15571
15572static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
15573 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15574 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
15575 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15576 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15577 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15578 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15579 { } /* end */
15580};
15581
15582static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020015583 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15584 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015585 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15586 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15587 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15588 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15589 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15590 { } /* end */
15591};
15592
15593static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
15594 .ops = &snd_hda_bind_vol,
15595 .values = {
15596 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15597 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
15598 0
15599 },
15600};
15601
15602static struct hda_bind_ctls alc663_asus_two_bind_switch = {
15603 .ops = &snd_hda_bind_sw,
15604 .values = {
15605 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15606 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
15607 0
15608 },
15609};
15610
15611static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
15612 HDA_BIND_VOL("Master Playback Volume",
15613 &alc663_asus_two_bind_master_vol),
15614 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15615 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015616 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15617 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15618 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015619 { } /* end */
15620};
15621
15622static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
15623 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15624 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15625 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15626 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15627 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15628 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015629 { } /* end */
15630};
15631
15632static struct snd_kcontrol_new alc663_g71v_mixer[] = {
15633 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15634 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15635 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15636 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15637 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15638
15639 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15640 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15641 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15642 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15643 { } /* end */
15644};
15645
15646static struct snd_kcontrol_new alc663_g50v_mixer[] = {
15647 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15648 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15649 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15650
15651 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15652 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15653 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15654 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15655 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15656 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15657 { } /* end */
15658};
15659
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015660static struct snd_kcontrol_new alc662_chmode_mixer[] = {
15661 {
15662 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15663 .name = "Channel Mode",
15664 .info = alc_ch_mode_info,
15665 .get = alc_ch_mode_get,
15666 .put = alc_ch_mode_put,
15667 },
15668 { } /* end */
15669};
15670
15671static struct hda_verb alc662_init_verbs[] = {
15672 /* ADC: mute amp left and right */
15673 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15674 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15675 /* Front mixer: unmute input/output amp left and right (volume = 0) */
15676
Takashi Iwaicb53c622007-08-10 17:21:45 +020015677 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15678 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15679 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15680 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15681 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015682
Kailang Yangb60dd392007-09-20 12:50:29 +020015683 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15684 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15685 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15686 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15687 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15688 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015689
15690 /* Front Pin: output 0 (0x0c) */
15691 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15692 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15693
15694 /* Rear Pin: output 1 (0x0d) */
15695 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15696 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15697
15698 /* CLFE Pin: output 2 (0x0e) */
15699 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15700 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15701
15702 /* Mic (rear) pin: input vref at 80% */
15703 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15704 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15705 /* Front Mic pin: input vref at 80% */
15706 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15707 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15708 /* Line In pin: input */
15709 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15710 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15711 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15712 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15713 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15714 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15715 /* CD pin widget for input */
15716 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15717
15718 /* FIXME: use matrix-type input source selection */
15719 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15720 /* Input mixer */
15721 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020015722 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015723
15724 /* always trun on EAPD */
15725 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15726 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
15727
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015728 { }
15729};
15730
15731static struct hda_verb alc662_sue_init_verbs[] = {
15732 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15733 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020015734 {}
15735};
15736
15737static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
15738 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15739 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15740 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015741};
15742
Kailang Yang8c427222008-01-10 13:03:59 +010015743/* Set Unsolicited Event*/
15744static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
15745 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15746 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15747 {}
15748};
15749
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015750/*
15751 * generic initialization of ADC, input mixers and output mixers
15752 */
15753static struct hda_verb alc662_auto_init_verbs[] = {
15754 /*
15755 * Unmute ADC and set the default input to mic-in
15756 */
15757 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15758 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15759
15760 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
15761 * mixer widget
15762 * Note: PASD motherboards uses the Line In 2 as the input for front
15763 * panel mic (mic 2)
15764 */
15765 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020015766 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15767 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15768 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15769 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15770 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015771
15772 /*
15773 * Set up output mixers (0x0c - 0x0f)
15774 */
15775 /* set vol=0 to output mixers */
15776 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15777 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15778 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15779
15780 /* set up input amps for analog loopback */
15781 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020015782 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15783 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15784 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15785 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15786 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15787 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015788
15789
15790 /* FIXME: use matrix-type input source selection */
15791 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15792 /* Input mixer */
15793 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020015794 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015795 { }
15796};
15797
Takashi Iwai24fb9172008-09-02 14:48:20 +020015798/* additional verbs for ALC663 */
15799static struct hda_verb alc663_auto_init_verbs[] = {
15800 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15801 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15802 { }
15803};
15804
Kailang Yang6dda9f42008-05-27 12:05:31 +020015805static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015806 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15807 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015808 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15809 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020015810 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15811 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15812 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015813 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15814 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15815 {}
15816};
15817
Kailang Yangf1d4e282008-08-26 14:03:29 +020015818static struct hda_verb alc663_21jd_amic_init_verbs[] = {
15819 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15820 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15821 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15822 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15823 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15824 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15825 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15826 {}
15827};
15828
15829static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
15830 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15831 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15832 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15833 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15834 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15835 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15836 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15837 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15838 {}
15839};
15840
15841static struct hda_verb alc663_15jd_amic_init_verbs[] = {
15842 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15843 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15844 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15845 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15846 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15847 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15848 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15849 {}
15850};
15851
15852static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
15853 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15854 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15855 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15856 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15857 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15858 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15859 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15860 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15861 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15862 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15863 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15864 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15865 {}
15866};
15867
15868static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
15869 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15870 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15871 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15872 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15873 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15874 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15875 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15876 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15877 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15878 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15879 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15880 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15881 {}
15882};
15883
Kailang Yang6dda9f42008-05-27 12:05:31 +020015884static struct hda_verb alc663_g71v_init_verbs[] = {
15885 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15886 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
15887 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
15888
15889 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15890 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15891 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15892
15893 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15894 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
15895 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
15896 {}
15897};
15898
15899static struct hda_verb alc663_g50v_init_verbs[] = {
15900 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15901 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15902 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15903
15904 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15905 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15906 {}
15907};
15908
Kailang Yangf1d4e282008-08-26 14:03:29 +020015909static struct hda_verb alc662_ecs_init_verbs[] = {
15910 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
15911 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15912 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15913 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15914 {}
15915};
15916
Kailang Yang622e84c2009-04-21 07:39:04 +020015917static struct hda_verb alc272_dell_zm1_init_verbs[] = {
15918 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15919 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15920 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15921 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15922 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15923 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15924 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15925 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15926 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
15927 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15928 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15929 {}
15930};
15931
15932static struct hda_verb alc272_dell_init_verbs[] = {
15933 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15934 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15935 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15936 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15937 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15938 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15939 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15940 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15941 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
15942 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15943 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15944 {}
15945};
15946
Kailang Yangf1d4e282008-08-26 14:03:29 +020015947static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
15948 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
15949 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
15950 { } /* end */
15951};
15952
Kailang Yang622e84c2009-04-21 07:39:04 +020015953static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
15954 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
15955 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
15956 { } /* end */
15957};
15958
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015959static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
15960{
15961 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015962 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015963
15964 present = snd_hda_codec_read(codec, 0x14, 0,
15965 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020015966 bits = present ? HDA_AMP_MUTE : 0;
15967 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15968 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015969}
15970
15971static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
15972{
15973 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015974 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015975
15976 present = snd_hda_codec_read(codec, 0x1b, 0,
15977 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020015978 bits = present ? HDA_AMP_MUTE : 0;
15979 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15980 HDA_AMP_MUTE, bits);
15981 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
15982 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015983}
15984
15985static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
15986 unsigned int res)
15987{
15988 if ((res >> 26) == ALC880_HP_EVENT)
15989 alc662_lenovo_101e_all_automute(codec);
15990 if ((res >> 26) == ALC880_FRONT_EVENT)
15991 alc662_lenovo_101e_ispeaker_automute(codec);
15992}
15993
Kailang Yang291702f2007-10-16 14:28:03 +020015994static void alc662_eeepc_mic_automute(struct hda_codec *codec)
15995{
15996 unsigned int present;
15997
15998 present = snd_hda_codec_read(codec, 0x18, 0,
15999 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
16000 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16001 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
16002 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16003 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
16004 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16005 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
16006 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16007 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
16008}
16009
16010/* unsolicited event for HP jack sensing */
16011static void alc662_eeepc_unsol_event(struct hda_codec *codec,
16012 unsigned int res)
16013{
16014 if ((res >> 26) == ALC880_HP_EVENT)
16015 alc262_hippo1_automute( codec );
16016
16017 if ((res >> 26) == ALC880_MIC_EVENT)
16018 alc662_eeepc_mic_automute(codec);
16019}
16020
16021static void alc662_eeepc_inithook(struct hda_codec *codec)
16022{
16023 alc262_hippo1_automute( codec );
16024 alc662_eeepc_mic_automute(codec);
16025}
16026
Kailang Yang8c427222008-01-10 13:03:59 +010016027static void alc662_eeepc_ep20_automute(struct hda_codec *codec)
16028{
16029 unsigned int mute;
16030 unsigned int present;
16031
16032 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
16033 present = snd_hda_codec_read(codec, 0x14, 0,
16034 AC_VERB_GET_PIN_SENSE, 0);
16035 present = (present & 0x80000000) != 0;
16036 if (present) {
16037 /* mute internal speaker */
16038 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020016039 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yang8c427222008-01-10 13:03:59 +010016040 } else {
16041 /* unmute internal speaker if necessary */
16042 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
16043 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020016044 HDA_AMP_MUTE, mute);
Kailang Yang8c427222008-01-10 13:03:59 +010016045 }
16046}
16047
16048/* unsolicited event for HP jack sensing */
16049static void alc662_eeepc_ep20_unsol_event(struct hda_codec *codec,
16050 unsigned int res)
16051{
16052 if ((res >> 26) == ALC880_HP_EVENT)
16053 alc662_eeepc_ep20_automute(codec);
16054}
16055
16056static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
16057{
16058 alc662_eeepc_ep20_automute(codec);
16059}
16060
Kailang Yang6dda9f42008-05-27 12:05:31 +020016061static void alc663_m51va_speaker_automute(struct hda_codec *codec)
16062{
16063 unsigned int present;
16064 unsigned char bits;
16065
16066 present = snd_hda_codec_read(codec, 0x21, 0,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016067 AC_VERB_GET_PIN_SENSE, 0)
16068 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020016069 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020016070 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16071 AMP_IN_MUTE(0), bits);
16072 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16073 AMP_IN_MUTE(0), bits);
16074}
16075
16076static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
16077{
16078 unsigned int present;
16079 unsigned char bits;
16080
16081 present = snd_hda_codec_read(codec, 0x21, 0,
16082 AC_VERB_GET_PIN_SENSE, 0)
16083 & AC_PINSENSE_PRESENCE;
16084 bits = present ? HDA_AMP_MUTE : 0;
16085 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16086 AMP_IN_MUTE(0), bits);
16087 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16088 AMP_IN_MUTE(0), bits);
16089 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16090 AMP_IN_MUTE(0), bits);
16091 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16092 AMP_IN_MUTE(0), bits);
16093}
16094
16095static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
16096{
16097 unsigned int present;
16098 unsigned char bits;
16099
16100 present = snd_hda_codec_read(codec, 0x15, 0,
16101 AC_VERB_GET_PIN_SENSE, 0)
16102 & AC_PINSENSE_PRESENCE;
16103 bits = present ? HDA_AMP_MUTE : 0;
16104 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16105 AMP_IN_MUTE(0), bits);
16106 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16107 AMP_IN_MUTE(0), bits);
16108 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16109 AMP_IN_MUTE(0), bits);
16110 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16111 AMP_IN_MUTE(0), bits);
16112}
16113
16114static void alc662_f5z_speaker_automute(struct hda_codec *codec)
16115{
16116 unsigned int present;
16117 unsigned char bits;
16118
16119 present = snd_hda_codec_read(codec, 0x1b, 0,
16120 AC_VERB_GET_PIN_SENSE, 0)
16121 & AC_PINSENSE_PRESENCE;
16122 bits = present ? 0 : PIN_OUT;
16123 snd_hda_codec_write(codec, 0x14, 0,
16124 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
16125}
16126
16127static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
16128{
16129 unsigned int present1, present2;
16130
16131 present1 = snd_hda_codec_read(codec, 0x21, 0,
16132 AC_VERB_GET_PIN_SENSE, 0)
16133 & AC_PINSENSE_PRESENCE;
16134 present2 = snd_hda_codec_read(codec, 0x15, 0,
16135 AC_VERB_GET_PIN_SENSE, 0)
16136 & AC_PINSENSE_PRESENCE;
16137
16138 if (present1 || present2) {
16139 snd_hda_codec_write_cache(codec, 0x14, 0,
16140 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16141 } else {
16142 snd_hda_codec_write_cache(codec, 0x14, 0,
16143 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16144 }
16145}
16146
16147static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
16148{
16149 unsigned int present1, present2;
16150
16151 present1 = snd_hda_codec_read(codec, 0x1b, 0,
16152 AC_VERB_GET_PIN_SENSE, 0)
16153 & AC_PINSENSE_PRESENCE;
16154 present2 = snd_hda_codec_read(codec, 0x15, 0,
16155 AC_VERB_GET_PIN_SENSE, 0)
16156 & AC_PINSENSE_PRESENCE;
16157
16158 if (present1 || present2) {
16159 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16160 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16161 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16162 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16163 } else {
16164 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16165 AMP_IN_MUTE(0), 0);
16166 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16167 AMP_IN_MUTE(0), 0);
16168 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020016169}
16170
16171static void alc663_m51va_mic_automute(struct hda_codec *codec)
16172{
16173 unsigned int present;
16174
16175 present = snd_hda_codec_read(codec, 0x18, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020016176 AC_VERB_GET_PIN_SENSE, 0)
16177 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020016178 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016179 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016180 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016181 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016182 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016183 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016184 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016185 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016186}
16187
16188static void alc663_m51va_unsol_event(struct hda_codec *codec,
16189 unsigned int res)
16190{
16191 switch (res >> 26) {
16192 case ALC880_HP_EVENT:
16193 alc663_m51va_speaker_automute(codec);
16194 break;
16195 case ALC880_MIC_EVENT:
16196 alc663_m51va_mic_automute(codec);
16197 break;
16198 }
16199}
16200
16201static void alc663_m51va_inithook(struct hda_codec *codec)
16202{
16203 alc663_m51va_speaker_automute(codec);
16204 alc663_m51va_mic_automute(codec);
16205}
16206
Kailang Yangf1d4e282008-08-26 14:03:29 +020016207/* ***************** Mode1 ******************************/
16208static void alc663_mode1_unsol_event(struct hda_codec *codec,
16209 unsigned int res)
16210{
16211 switch (res >> 26) {
16212 case ALC880_HP_EVENT:
16213 alc663_m51va_speaker_automute(codec);
16214 break;
16215 case ALC880_MIC_EVENT:
16216 alc662_eeepc_mic_automute(codec);
16217 break;
16218 }
16219}
16220
16221static void alc663_mode1_inithook(struct hda_codec *codec)
16222{
16223 alc663_m51va_speaker_automute(codec);
16224 alc662_eeepc_mic_automute(codec);
16225}
16226/* ***************** Mode2 ******************************/
16227static void alc662_mode2_unsol_event(struct hda_codec *codec,
16228 unsigned int res)
16229{
16230 switch (res >> 26) {
16231 case ALC880_HP_EVENT:
16232 alc662_f5z_speaker_automute(codec);
16233 break;
16234 case ALC880_MIC_EVENT:
16235 alc662_eeepc_mic_automute(codec);
16236 break;
16237 }
16238}
16239
16240static void alc662_mode2_inithook(struct hda_codec *codec)
16241{
16242 alc662_f5z_speaker_automute(codec);
16243 alc662_eeepc_mic_automute(codec);
16244}
16245/* ***************** Mode3 ******************************/
16246static void alc663_mode3_unsol_event(struct hda_codec *codec,
16247 unsigned int res)
16248{
16249 switch (res >> 26) {
16250 case ALC880_HP_EVENT:
16251 alc663_two_hp_m1_speaker_automute(codec);
16252 break;
16253 case ALC880_MIC_EVENT:
16254 alc662_eeepc_mic_automute(codec);
16255 break;
16256 }
16257}
16258
16259static void alc663_mode3_inithook(struct hda_codec *codec)
16260{
16261 alc663_two_hp_m1_speaker_automute(codec);
16262 alc662_eeepc_mic_automute(codec);
16263}
16264/* ***************** Mode4 ******************************/
16265static void alc663_mode4_unsol_event(struct hda_codec *codec,
16266 unsigned int res)
16267{
16268 switch (res >> 26) {
16269 case ALC880_HP_EVENT:
16270 alc663_21jd_two_speaker_automute(codec);
16271 break;
16272 case ALC880_MIC_EVENT:
16273 alc662_eeepc_mic_automute(codec);
16274 break;
16275 }
16276}
16277
16278static void alc663_mode4_inithook(struct hda_codec *codec)
16279{
16280 alc663_21jd_two_speaker_automute(codec);
16281 alc662_eeepc_mic_automute(codec);
16282}
16283/* ***************** Mode5 ******************************/
16284static void alc663_mode5_unsol_event(struct hda_codec *codec,
16285 unsigned int res)
16286{
16287 switch (res >> 26) {
16288 case ALC880_HP_EVENT:
16289 alc663_15jd_two_speaker_automute(codec);
16290 break;
16291 case ALC880_MIC_EVENT:
16292 alc662_eeepc_mic_automute(codec);
16293 break;
16294 }
16295}
16296
16297static void alc663_mode5_inithook(struct hda_codec *codec)
16298{
16299 alc663_15jd_two_speaker_automute(codec);
16300 alc662_eeepc_mic_automute(codec);
16301}
16302/* ***************** Mode6 ******************************/
16303static void alc663_mode6_unsol_event(struct hda_codec *codec,
16304 unsigned int res)
16305{
16306 switch (res >> 26) {
16307 case ALC880_HP_EVENT:
16308 alc663_two_hp_m2_speaker_automute(codec);
16309 break;
16310 case ALC880_MIC_EVENT:
16311 alc662_eeepc_mic_automute(codec);
16312 break;
16313 }
16314}
16315
16316static void alc663_mode6_inithook(struct hda_codec *codec)
16317{
16318 alc663_two_hp_m2_speaker_automute(codec);
16319 alc662_eeepc_mic_automute(codec);
16320}
16321
Kailang Yang6dda9f42008-05-27 12:05:31 +020016322static void alc663_g71v_hp_automute(struct hda_codec *codec)
16323{
16324 unsigned int present;
16325 unsigned char bits;
16326
16327 present = snd_hda_codec_read(codec, 0x21, 0,
16328 AC_VERB_GET_PIN_SENSE, 0)
16329 & AC_PINSENSE_PRESENCE;
16330 bits = present ? HDA_AMP_MUTE : 0;
16331 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16332 HDA_AMP_MUTE, bits);
16333 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16334 HDA_AMP_MUTE, bits);
16335}
16336
16337static void alc663_g71v_front_automute(struct hda_codec *codec)
16338{
16339 unsigned int present;
16340 unsigned char bits;
16341
16342 present = snd_hda_codec_read(codec, 0x15, 0,
16343 AC_VERB_GET_PIN_SENSE, 0)
16344 & AC_PINSENSE_PRESENCE;
16345 bits = present ? HDA_AMP_MUTE : 0;
16346 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16347 HDA_AMP_MUTE, bits);
16348}
16349
16350static void alc663_g71v_unsol_event(struct hda_codec *codec,
16351 unsigned int res)
16352{
16353 switch (res >> 26) {
16354 case ALC880_HP_EVENT:
16355 alc663_g71v_hp_automute(codec);
16356 break;
16357 case ALC880_FRONT_EVENT:
16358 alc663_g71v_front_automute(codec);
16359 break;
16360 case ALC880_MIC_EVENT:
16361 alc662_eeepc_mic_automute(codec);
16362 break;
16363 }
16364}
16365
16366static void alc663_g71v_inithook(struct hda_codec *codec)
16367{
16368 alc663_g71v_front_automute(codec);
16369 alc663_g71v_hp_automute(codec);
16370 alc662_eeepc_mic_automute(codec);
16371}
16372
16373static void alc663_g50v_unsol_event(struct hda_codec *codec,
16374 unsigned int res)
16375{
16376 switch (res >> 26) {
16377 case ALC880_HP_EVENT:
16378 alc663_m51va_speaker_automute(codec);
16379 break;
16380 case ALC880_MIC_EVENT:
16381 alc662_eeepc_mic_automute(codec);
16382 break;
16383 }
16384}
16385
16386static void alc663_g50v_inithook(struct hda_codec *codec)
16387{
16388 alc663_m51va_speaker_automute(codec);
16389 alc662_eeepc_mic_automute(codec);
16390}
16391
Kailang Yangf1d4e282008-08-26 14:03:29 +020016392/* bind hp and internal speaker mute (with plug check) */
16393static int alc662_ecs_master_sw_put(struct snd_kcontrol *kcontrol,
16394 struct snd_ctl_elem_value *ucontrol)
16395{
16396 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
16397 long *valp = ucontrol->value.integer.value;
16398 int change;
16399
16400 change = snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
16401 HDA_AMP_MUTE,
16402 valp[0] ? 0 : HDA_AMP_MUTE);
16403 change |= snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
16404 HDA_AMP_MUTE,
16405 valp[1] ? 0 : HDA_AMP_MUTE);
16406 if (change)
16407 alc262_hippo1_automute(codec);
16408 return change;
16409}
16410
16411static struct snd_kcontrol_new alc662_ecs_mixer[] = {
16412 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16413 {
16414 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16415 .name = "Master Playback Switch",
16416 .info = snd_hda_mixer_amp_switch_info,
16417 .get = snd_hda_mixer_amp_switch_get,
16418 .put = alc662_ecs_master_sw_put,
16419 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
16420 },
16421
16422 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
16423 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
16424 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
16425
16426 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16427 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16428 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16429 { } /* end */
16430};
16431
Takashi Iwaicb53c622007-08-10 17:21:45 +020016432#ifdef CONFIG_SND_HDA_POWER_SAVE
16433#define alc662_loopbacks alc880_loopbacks
16434#endif
16435
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016436
16437/* pcm configuration: identiacal with ALC880 */
16438#define alc662_pcm_analog_playback alc880_pcm_analog_playback
16439#define alc662_pcm_analog_capture alc880_pcm_analog_capture
16440#define alc662_pcm_digital_playback alc880_pcm_digital_playback
16441#define alc662_pcm_digital_capture alc880_pcm_digital_capture
16442
16443/*
16444 * configuration and preset
16445 */
16446static const char *alc662_models[ALC662_MODEL_LAST] = {
16447 [ALC662_3ST_2ch_DIG] = "3stack-dig",
16448 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
16449 [ALC662_3ST_6ch] = "3stack-6ch",
16450 [ALC662_5ST_DIG] = "6stack-dig",
16451 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020016452 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010016453 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016454 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020016455 [ALC663_ASUS_M51VA] = "m51va",
16456 [ALC663_ASUS_G71V] = "g71v",
16457 [ALC663_ASUS_H13] = "h13",
16458 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016459 [ALC663_ASUS_MODE1] = "asus-mode1",
16460 [ALC662_ASUS_MODE2] = "asus-mode2",
16461 [ALC663_ASUS_MODE3] = "asus-mode3",
16462 [ALC663_ASUS_MODE4] = "asus-mode4",
16463 [ALC663_ASUS_MODE5] = "asus-mode5",
16464 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016465 [ALC662_AUTO] = "auto",
16466};
16467
16468static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010016469 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020016470 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
16471 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016472 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
16473 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
16474 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
16475 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
16476 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
16477 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
16478 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
16479 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
16480 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
16481 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
16482 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
16483 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016484 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
16485 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
16486 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016487 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
16488 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
16489 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
16490 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016491 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016492 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
16493 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016494 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016495 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
16496 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
16497 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020016498 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
16499 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
16500 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016501 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
16502 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
16503 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016504 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016505 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
16506 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020016507 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016508 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020016509 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016510 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
16511 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
16512 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016513 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016514 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
16515 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010016516 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020016517 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010016518 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016519 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030016520 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
16521 ALC662_3ST_6ch_DIG),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030016522 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
16523 ALC662_3ST_6ch_DIG),
Vedran Miletic19c009a2008-09-29 20:29:25 +020016524 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020016525 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016526 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020016527 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020016528 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016529 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
16530 ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016531 {}
16532};
16533
16534static struct alc_config_preset alc662_presets[] = {
16535 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016536 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016537 .init_verbs = { alc662_init_verbs },
16538 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16539 .dac_nids = alc662_dac_nids,
16540 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016541 .dig_in_nid = ALC662_DIGIN_NID,
16542 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16543 .channel_mode = alc662_3ST_2ch_modes,
16544 .input_mux = &alc662_capture_source,
16545 },
16546 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016547 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016548 .init_verbs = { alc662_init_verbs },
16549 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16550 .dac_nids = alc662_dac_nids,
16551 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016552 .dig_in_nid = ALC662_DIGIN_NID,
16553 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16554 .channel_mode = alc662_3ST_6ch_modes,
16555 .need_dac_fix = 1,
16556 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016557 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016558 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016559 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016560 .init_verbs = { alc662_init_verbs },
16561 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16562 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016563 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16564 .channel_mode = alc662_3ST_6ch_modes,
16565 .need_dac_fix = 1,
16566 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016567 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016568 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016569 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016570 .init_verbs = { alc662_init_verbs },
16571 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16572 .dac_nids = alc662_dac_nids,
16573 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016574 .dig_in_nid = ALC662_DIGIN_NID,
16575 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
16576 .channel_mode = alc662_5stack_modes,
16577 .input_mux = &alc662_capture_source,
16578 },
16579 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016580 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016581 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
16582 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16583 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016584 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16585 .channel_mode = alc662_3ST_2ch_modes,
16586 .input_mux = &alc662_lenovo_101e_capture_source,
16587 .unsol_event = alc662_lenovo_101e_unsol_event,
16588 .init_hook = alc662_lenovo_101e_all_automute,
16589 },
Kailang Yang291702f2007-10-16 14:28:03 +020016590 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016591 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020016592 .init_verbs = { alc662_init_verbs,
16593 alc662_eeepc_sue_init_verbs },
16594 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16595 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020016596 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16597 .channel_mode = alc662_3ST_2ch_modes,
16598 .input_mux = &alc662_eeepc_capture_source,
16599 .unsol_event = alc662_eeepc_unsol_event,
16600 .init_hook = alc662_eeepc_inithook,
16601 },
Kailang Yang8c427222008-01-10 13:03:59 +010016602 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016603 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010016604 alc662_chmode_mixer },
16605 .init_verbs = { alc662_init_verbs,
16606 alc662_eeepc_ep20_sue_init_verbs },
16607 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16608 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010016609 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16610 .channel_mode = alc662_3ST_6ch_modes,
16611 .input_mux = &alc662_lenovo_101e_capture_source,
16612 .unsol_event = alc662_eeepc_ep20_unsol_event,
16613 .init_hook = alc662_eeepc_ep20_inithook,
16614 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016615 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016616 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016617 .init_verbs = { alc662_init_verbs,
16618 alc662_ecs_init_verbs },
16619 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16620 .dac_nids = alc662_dac_nids,
16621 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16622 .channel_mode = alc662_3ST_2ch_modes,
16623 .input_mux = &alc662_eeepc_capture_source,
16624 .unsol_event = alc662_eeepc_unsol_event,
16625 .init_hook = alc662_eeepc_inithook,
16626 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016627 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016628 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016629 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16630 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16631 .dac_nids = alc662_dac_nids,
16632 .dig_out_nid = ALC662_DIGOUT_NID,
16633 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16634 .channel_mode = alc662_3ST_2ch_modes,
16635 .input_mux = &alc663_m51va_capture_source,
16636 .unsol_event = alc663_m51va_unsol_event,
16637 .init_hook = alc663_m51va_inithook,
16638 },
16639 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016640 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016641 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
16642 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16643 .dac_nids = alc662_dac_nids,
16644 .dig_out_nid = ALC662_DIGOUT_NID,
16645 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16646 .channel_mode = alc662_3ST_2ch_modes,
16647 .input_mux = &alc662_eeepc_capture_source,
16648 .unsol_event = alc663_g71v_unsol_event,
16649 .init_hook = alc663_g71v_inithook,
16650 },
16651 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016652 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016653 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16654 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16655 .dac_nids = alc662_dac_nids,
16656 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16657 .channel_mode = alc662_3ST_2ch_modes,
16658 .input_mux = &alc663_m51va_capture_source,
16659 .unsol_event = alc663_m51va_unsol_event,
16660 .init_hook = alc663_m51va_inithook,
16661 },
16662 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016663 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016664 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
16665 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16666 .dac_nids = alc662_dac_nids,
16667 .dig_out_nid = ALC662_DIGOUT_NID,
16668 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16669 .channel_mode = alc662_3ST_6ch_modes,
16670 .input_mux = &alc663_capture_source,
16671 .unsol_event = alc663_g50v_unsol_event,
16672 .init_hook = alc663_g50v_inithook,
16673 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016674 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016675 .mixers = { alc663_m51va_mixer },
16676 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016677 .init_verbs = { alc662_init_verbs,
16678 alc663_21jd_amic_init_verbs },
16679 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16680 .hp_nid = 0x03,
16681 .dac_nids = alc662_dac_nids,
16682 .dig_out_nid = ALC662_DIGOUT_NID,
16683 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16684 .channel_mode = alc662_3ST_2ch_modes,
16685 .input_mux = &alc662_eeepc_capture_source,
16686 .unsol_event = alc663_mode1_unsol_event,
16687 .init_hook = alc663_mode1_inithook,
16688 },
16689 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016690 .mixers = { alc662_1bjd_mixer },
16691 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016692 .init_verbs = { alc662_init_verbs,
16693 alc662_1bjd_amic_init_verbs },
16694 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16695 .dac_nids = alc662_dac_nids,
16696 .dig_out_nid = ALC662_DIGOUT_NID,
16697 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16698 .channel_mode = alc662_3ST_2ch_modes,
16699 .input_mux = &alc662_eeepc_capture_source,
16700 .unsol_event = alc662_mode2_unsol_event,
16701 .init_hook = alc662_mode2_inithook,
16702 },
16703 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016704 .mixers = { alc663_two_hp_m1_mixer },
16705 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016706 .init_verbs = { alc662_init_verbs,
16707 alc663_two_hp_amic_m1_init_verbs },
16708 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16709 .hp_nid = 0x03,
16710 .dac_nids = alc662_dac_nids,
16711 .dig_out_nid = ALC662_DIGOUT_NID,
16712 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16713 .channel_mode = alc662_3ST_2ch_modes,
16714 .input_mux = &alc662_eeepc_capture_source,
16715 .unsol_event = alc663_mode3_unsol_event,
16716 .init_hook = alc663_mode3_inithook,
16717 },
16718 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016719 .mixers = { alc663_asus_21jd_clfe_mixer },
16720 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016721 .init_verbs = { alc662_init_verbs,
16722 alc663_21jd_amic_init_verbs},
16723 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16724 .hp_nid = 0x03,
16725 .dac_nids = alc662_dac_nids,
16726 .dig_out_nid = ALC662_DIGOUT_NID,
16727 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16728 .channel_mode = alc662_3ST_2ch_modes,
16729 .input_mux = &alc662_eeepc_capture_source,
16730 .unsol_event = alc663_mode4_unsol_event,
16731 .init_hook = alc663_mode4_inithook,
16732 },
16733 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016734 .mixers = { alc663_asus_15jd_clfe_mixer },
16735 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016736 .init_verbs = { alc662_init_verbs,
16737 alc663_15jd_amic_init_verbs },
16738 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16739 .hp_nid = 0x03,
16740 .dac_nids = alc662_dac_nids,
16741 .dig_out_nid = ALC662_DIGOUT_NID,
16742 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16743 .channel_mode = alc662_3ST_2ch_modes,
16744 .input_mux = &alc662_eeepc_capture_source,
16745 .unsol_event = alc663_mode5_unsol_event,
16746 .init_hook = alc663_mode5_inithook,
16747 },
16748 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016749 .mixers = { alc663_two_hp_m2_mixer },
16750 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016751 .init_verbs = { alc662_init_verbs,
16752 alc663_two_hp_amic_m2_init_verbs },
16753 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16754 .hp_nid = 0x03,
16755 .dac_nids = alc662_dac_nids,
16756 .dig_out_nid = ALC662_DIGOUT_NID,
16757 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16758 .channel_mode = alc662_3ST_2ch_modes,
16759 .input_mux = &alc662_eeepc_capture_source,
16760 .unsol_event = alc663_mode6_unsol_event,
16761 .init_hook = alc663_mode6_inithook,
16762 },
Kailang Yang622e84c2009-04-21 07:39:04 +020016763 [ALC272_DELL] = {
16764 .mixers = { alc663_m51va_mixer },
16765 .cap_mixer = alc272_auto_capture_mixer,
16766 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
16767 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
16768 .dac_nids = alc662_dac_nids,
16769 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16770 .adc_nids = alc272_adc_nids,
16771 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
16772 .capsrc_nids = alc272_capsrc_nids,
16773 .channel_mode = alc662_3ST_2ch_modes,
16774 .input_mux = &alc663_m51va_capture_source,
16775 .unsol_event = alc663_m51va_unsol_event,
16776 .init_hook = alc663_m51va_inithook,
16777 },
16778 [ALC272_DELL_ZM1] = {
16779 .mixers = { alc663_m51va_mixer },
16780 .cap_mixer = alc662_auto_capture_mixer,
16781 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
16782 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
16783 .dac_nids = alc662_dac_nids,
16784 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16785 .adc_nids = alc662_adc_nids,
16786 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
16787 .capsrc_nids = alc662_capsrc_nids,
16788 .channel_mode = alc662_3ST_2ch_modes,
16789 .input_mux = &alc663_m51va_capture_source,
16790 .unsol_event = alc663_m51va_unsol_event,
16791 .init_hook = alc663_m51va_inithook,
16792 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016793};
16794
16795
16796/*
16797 * BIOS auto configuration
16798 */
16799
16800/* add playback controls from the parsed DAC table */
16801static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
16802 const struct auto_pin_cfg *cfg)
16803{
16804 char name[32];
16805 static const char *chname[4] = {
16806 "Front", "Surround", NULL /*CLFE*/, "Side"
16807 };
16808 hda_nid_t nid;
16809 int i, err;
16810
16811 for (i = 0; i < cfg->line_outs; i++) {
16812 if (!spec->multiout.dac_nids[i])
16813 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020016814 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016815 if (i == 2) {
16816 /* Center/LFE */
16817 err = add_control(spec, ALC_CTL_WIDGET_VOL,
16818 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016819 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
16820 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016821 if (err < 0)
16822 return err;
16823 err = add_control(spec, ALC_CTL_WIDGET_VOL,
16824 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016825 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
16826 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016827 if (err < 0)
16828 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016829 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016830 "Center Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016831 HDA_COMPOSE_AMP_VAL(0x0e, 1, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016832 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016833 if (err < 0)
16834 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016835 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016836 "LFE Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016837 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016838 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016839 if (err < 0)
16840 return err;
16841 } else {
16842 sprintf(name, "%s Playback Volume", chname[i]);
16843 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016844 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
16845 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016846 if (err < 0)
16847 return err;
16848 sprintf(name, "%s Playback Switch", chname[i]);
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016849 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16850 HDA_COMPOSE_AMP_VAL(alc880_idx_to_mixer(i),
16851 3, 0, HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016852 if (err < 0)
16853 return err;
16854 }
16855 }
16856 return 0;
16857}
16858
16859/* add playback controls for speaker and HP outputs */
16860static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
16861 const char *pfx)
16862{
16863 hda_nid_t nid;
16864 int err;
16865 char name[32];
16866
16867 if (!pin)
16868 return 0;
16869
Takashi Iwai24fb9172008-09-02 14:48:20 +020016870 if (pin == 0x17) {
16871 /* ALC663 has a mono output pin on 0x17 */
16872 sprintf(name, "%s Playback Switch", pfx);
16873 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16874 HDA_COMPOSE_AMP_VAL(pin, 2, 0, HDA_OUTPUT));
16875 return err;
16876 }
16877
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016878 if (alc880_is_fixed_pin(pin)) {
16879 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai939778a2009-02-05 15:57:55 +010016880 /* printk(KERN_DEBUG "DAC nid=%x\n",nid); */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016881 /* specify the DAC as the extra output */
16882 if (!spec->multiout.hp_nid)
16883 spec->multiout.hp_nid = nid;
16884 else
16885 spec->multiout.extra_out_nid[0] = nid;
16886 /* control HP volume/switch on the output mixer amp */
16887 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16888 sprintf(name, "%s Playback Volume", pfx);
16889 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
16890 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
16891 if (err < 0)
16892 return err;
16893 sprintf(name, "%s Playback Switch", pfx);
16894 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
16895 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
16896 if (err < 0)
16897 return err;
16898 } else if (alc880_is_multi_pin(pin)) {
16899 /* set manual connection */
16900 /* we have only a switch on HP-out PIN */
16901 sprintf(name, "%s Playback Switch", pfx);
16902 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16903 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
16904 if (err < 0)
16905 return err;
16906 }
16907 return 0;
16908}
16909
Takashi Iwai2d864c42009-03-20 12:52:47 +010016910/* return the index of the src widget from the connection list of the nid.
16911 * return -1 if not found
16912 */
16913static int alc662_input_pin_idx(struct hda_codec *codec, hda_nid_t nid,
16914 hda_nid_t src)
16915{
16916 hda_nid_t conn_list[HDA_MAX_CONNECTIONS];
16917 int i, conns;
16918
16919 conns = snd_hda_get_connections(codec, nid, conn_list,
16920 ARRAY_SIZE(conn_list));
16921 if (conns < 0)
16922 return -1;
16923 for (i = 0; i < conns; i++)
16924 if (conn_list[i] == src)
16925 return i;
16926 return -1;
16927}
16928
16929static int alc662_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
16930{
Takashi Iwai1327a322009-03-23 13:07:47 +010016931 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai2d864c42009-03-20 12:52:47 +010016932 return (pincap & AC_PINCAP_IN) != 0;
16933}
16934
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016935/* create playback/capture controls for input pins */
Takashi Iwai2d864c42009-03-20 12:52:47 +010016936static int alc662_auto_create_analog_input_ctls(struct hda_codec *codec,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016937 const struct auto_pin_cfg *cfg)
16938{
Takashi Iwai2d864c42009-03-20 12:52:47 +010016939 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016940 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016941 int i, err, idx;
16942
16943 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai2d864c42009-03-20 12:52:47 +010016944 if (alc662_is_input_pin(codec, cfg->input_pins[i])) {
16945 idx = alc662_input_pin_idx(codec, 0x0b,
16946 cfg->input_pins[i]);
16947 if (idx >= 0) {
16948 err = new_analog_input(spec, cfg->input_pins[i],
16949 auto_pin_cfg_labels[i],
16950 idx, 0x0b);
16951 if (err < 0)
16952 return err;
16953 }
16954 idx = alc662_input_pin_idx(codec, 0x22,
16955 cfg->input_pins[i]);
16956 if (idx >= 0) {
16957 imux->items[imux->num_items].label =
16958 auto_pin_cfg_labels[i];
16959 imux->items[imux->num_items].index = idx;
16960 imux->num_items++;
16961 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016962 }
16963 }
16964 return 0;
16965}
16966
16967static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
16968 hda_nid_t nid, int pin_type,
16969 int dac_idx)
16970{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016971 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016972 /* need the manual connection? */
16973 if (alc880_is_multi_pin(nid)) {
16974 struct alc_spec *spec = codec->spec;
16975 int idx = alc880_multi_pin_idx(nid);
16976 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
16977 AC_VERB_SET_CONNECT_SEL,
16978 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
16979 }
16980}
16981
16982static void alc662_auto_init_multi_out(struct hda_codec *codec)
16983{
16984 struct alc_spec *spec = codec->spec;
16985 int i;
16986
16987 for (i = 0; i <= HDA_SIDE; i++) {
16988 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016989 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016990 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016991 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016992 i);
16993 }
16994}
16995
16996static void alc662_auto_init_hp_out(struct hda_codec *codec)
16997{
16998 struct alc_spec *spec = codec->spec;
16999 hda_nid_t pin;
17000
17001 pin = spec->autocfg.hp_pins[0];
17002 if (pin) /* connect to front */
17003 /* use dac 0 */
17004 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017005 pin = spec->autocfg.speaker_pins[0];
17006 if (pin)
17007 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017008}
17009
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017010#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
17011
17012static void alc662_auto_init_analog_input(struct hda_codec *codec)
17013{
17014 struct alc_spec *spec = codec->spec;
17015 int i;
17016
17017 for (i = 0; i < AUTO_PIN_LAST; i++) {
17018 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai2d864c42009-03-20 12:52:47 +010017019 if (alc662_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010017020 alc_set_input_pin(codec, nid, i);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010017021 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010017022 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017023 snd_hda_codec_write(codec, nid, 0,
17024 AC_VERB_SET_AMP_GAIN_MUTE,
17025 AMP_OUT_MUTE);
17026 }
17027 }
17028}
17029
Takashi Iwaif511b012008-08-15 16:46:42 +020017030#define alc662_auto_init_input_src alc882_auto_init_input_src
17031
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017032static int alc662_parse_auto_config(struct hda_codec *codec)
17033{
17034 struct alc_spec *spec = codec->spec;
17035 int err;
17036 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
17037
17038 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
17039 alc662_ignore);
17040 if (err < 0)
17041 return err;
17042 if (!spec->autocfg.line_outs)
17043 return 0; /* can't find valid BIOS pin config */
17044
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017045 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
17046 if (err < 0)
17047 return err;
17048 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
17049 if (err < 0)
17050 return err;
17051 err = alc662_auto_create_extra_out(spec,
17052 spec->autocfg.speaker_pins[0],
17053 "Speaker");
17054 if (err < 0)
17055 return err;
17056 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
17057 "Headphone");
17058 if (err < 0)
17059 return err;
Takashi Iwai2d864c42009-03-20 12:52:47 +010017060 err = alc662_auto_create_analog_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017061 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017062 return err;
17063
17064 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
17065
Takashi Iwai0852d7a2009-02-11 11:35:15 +010017066 if (spec->autocfg.dig_outs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017067 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
17068
Takashi Iwai603c4012008-07-30 15:01:44 +020017069 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017070 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017071
17072 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017073 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020017074
Takashi Iwaid88897e2008-10-31 15:01:37 +010017075 add_verb(spec, alc662_auto_init_verbs);
Takashi Iwai24fb9172008-09-02 14:48:20 +020017076 if (codec->vendor_id == 0x10ec0663)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017077 add_verb(spec, alc663_auto_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020017078
17079 err = alc_auto_add_mic_boost(codec);
17080 if (err < 0)
17081 return err;
17082
Takashi Iwai4a79ba32009-04-22 16:31:35 +020017083 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
17084
Takashi Iwai8c87286f2007-06-19 12:11:16 +020017085 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017086}
17087
17088/* additional initialization for auto-configuration model */
17089static void alc662_auto_init(struct hda_codec *codec)
17090{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017091 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017092 alc662_auto_init_multi_out(codec);
17093 alc662_auto_init_hp_out(codec);
17094 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020017095 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017096 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020017097 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017098}
17099
17100static int patch_alc662(struct hda_codec *codec)
17101{
17102 struct alc_spec *spec;
17103 int err, board_config;
17104
17105 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
17106 if (!spec)
17107 return -ENOMEM;
17108
17109 codec->spec = spec;
17110
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020017111 alc_fix_pll_init(codec, 0x20, 0x04, 15);
17112
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017113 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
17114 alc662_models,
17115 alc662_cfg_tbl);
17116 if (board_config < 0) {
17117 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
17118 "trying auto-probe from BIOS...\n");
17119 board_config = ALC662_AUTO;
17120 }
17121
17122 if (board_config == ALC662_AUTO) {
17123 /* automatic parse from the BIOS config */
17124 err = alc662_parse_auto_config(codec);
17125 if (err < 0) {
17126 alc_free(codec);
17127 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020017128 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017129 printk(KERN_INFO
17130 "hda_codec: Cannot set up configuration "
17131 "from BIOS. Using base mode...\n");
17132 board_config = ALC662_3ST_2ch_DIG;
17133 }
17134 }
17135
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090017136 err = snd_hda_attach_beep_device(codec, 0x1);
17137 if (err < 0) {
17138 alc_free(codec);
17139 return err;
17140 }
17141
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017142 if (board_config != ALC662_AUTO)
17143 setup_preset(spec, &alc662_presets[board_config]);
17144
Kailang Yang6dda9f42008-05-27 12:05:31 +020017145 if (codec->vendor_id == 0x10ec0663) {
17146 spec->stream_name_analog = "ALC663 Analog";
17147 spec->stream_name_digital = "ALC663 Digital";
Kailang Yang01afd412008-10-15 11:22:09 +020017148 } else if (codec->vendor_id == 0x10ec0272) {
17149 spec->stream_name_analog = "ALC272 Analog";
17150 spec->stream_name_digital = "ALC272 Digital";
Kailang Yang6dda9f42008-05-27 12:05:31 +020017151 } else {
17152 spec->stream_name_analog = "ALC662 Analog";
17153 spec->stream_name_digital = "ALC662 Digital";
17154 }
17155
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017156 spec->stream_analog_playback = &alc662_pcm_analog_playback;
17157 spec->stream_analog_capture = &alc662_pcm_analog_capture;
17158
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017159 spec->stream_digital_playback = &alc662_pcm_digital_playback;
17160 spec->stream_digital_capture = &alc662_pcm_digital_capture;
17161
Takashi Iwaie1406342008-02-11 18:32:32 +010017162 spec->adc_nids = alc662_adc_nids;
17163 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
17164 spec->capsrc_nids = alc662_capsrc_nids;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017165 spec->capture_style = CAPT_MIX;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017166
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017167 if (!spec->cap_mixer)
17168 set_capture_mixer(spec);
Takashi Iwaib9591442009-03-16 15:25:00 +010017169 if (codec->vendor_id == 0x10ec0662)
17170 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
17171 else
17172 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017173
Takashi Iwai2134ea42008-01-10 16:53:55 +010017174 spec->vmaster_nid = 0x02;
17175
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017176 codec->patch_ops = alc_patch_ops;
17177 if (board_config == ALC662_AUTO)
17178 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020017179#ifdef CONFIG_SND_HDA_POWER_SAVE
17180 if (!spec->loopback.amplist)
17181 spec->loopback.amplist = alc662_loopbacks;
17182#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010017183 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017184
17185 return 0;
17186}
17187
17188/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070017189 * patch entries
17190 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017191static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070017192 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010017193 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017194 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020017195 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017196 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020017197 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017198 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017199 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017200 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
17201 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
17202 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017203 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
17204 .patch = patch_alc883 },
17205 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
17206 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017207 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017208 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017209 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020017210 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Clive Messer669faba2008-09-30 15:49:13 +020017211 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
17212 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Takashi Iwaicb308f92008-04-16 14:13:29 +020017213 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai7943a8a2008-04-16 17:29:09 +020017214 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Kailang Yangdf694da2005-12-05 19:42:22 +010017215 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Kailang Yanga385a522008-10-15 11:20:21 +020017216 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc883 },
Kailang Yang44426082008-10-15 11:18:05 +020017217 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
17218 .patch = patch_alc883 },
Wu Fengguang3fea2cb2008-12-26 12:20:43 +080017219 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017220 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017221 {} /* terminator */
17222};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017223
17224MODULE_ALIAS("snd-hda-codec-id:10ec*");
17225
17226MODULE_LICENSE("GPL");
17227MODULE_DESCRIPTION("Realtek HD-audio codec");
17228
17229static struct hda_codec_preset_list realtek_list = {
17230 .preset = snd_hda_preset_realtek,
17231 .owner = THIS_MODULE,
17232};
17233
17234static int __init patch_realtek_init(void)
17235{
17236 return snd_hda_add_codec_preset(&realtek_list);
17237}
17238
17239static void __exit patch_realtek_exit(void)
17240{
17241 snd_hda_delete_codec_preset(&realtek_list);
17242}
17243
17244module_init(patch_realtek_init)
17245module_exit(patch_realtek_exit)