blob: c14020ab3cb6ef6268b2513519f55f7eaebedde1 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for ALC 260/880/882 codecs
5 *
Kailang Yangdf694da2005-12-05 19:42:22 +01006 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * Takashi Iwai <tiwai@suse.de>
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01009 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#include <linux/init.h>
27#include <linux/delay.h>
28#include <linux/slab.h>
29#include <linux/pci.h>
30#include <sound/core.h>
31#include "hda_codec.h"
32#include "hda_local.h"
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090033#include "hda_beep.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070034
Kailang Yangccc656c2006-10-17 12:32:26 +020035#define ALC880_FRONT_EVENT 0x01
36#define ALC880_DCVOL_EVENT 0x02
37#define ALC880_HP_EVENT 0x04
38#define ALC880_MIC_EVENT 0x08
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
40/* ALC880 board config type */
41enum {
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 ALC880_3ST,
43 ALC880_3ST_DIG,
44 ALC880_5ST,
45 ALC880_5ST_DIG,
46 ALC880_W810,
Takashi Iwaidfc0ff62005-05-12 14:31:49 +020047 ALC880_Z71V,
Takashi Iwaib6482d42005-06-27 15:32:43 +020048 ALC880_6ST,
Takashi Iwai16ded522005-06-10 19:58:24 +020049 ALC880_6ST_DIG,
50 ALC880_F1734,
51 ALC880_ASUS,
52 ALC880_ASUS_DIG,
53 ALC880_ASUS_W1V,
Kailang Yangdf694da2005-12-05 19:42:22 +010054 ALC880_ASUS_DIG2,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +010055 ALC880_FUJITSU,
Takashi Iwai16ded522005-06-10 19:58:24 +020056 ALC880_UNIWILL_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +020057 ALC880_UNIWILL,
58 ALC880_UNIWILL_P53,
Kailang Yangdf694da2005-12-05 19:42:22 +010059 ALC880_CLEVO,
60 ALC880_TCL_S700,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010061 ALC880_LG,
Takashi Iwaid6815182006-03-23 16:06:23 +010062 ALC880_LG_LW,
Takashi Iwaidf99cd32008-04-25 15:25:04 +020063 ALC880_MEDION_RIM,
Takashi Iwaie9edcee2005-06-13 14:16:38 +020064#ifdef CONFIG_SND_DEBUG
65 ALC880_TEST,
66#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010067 ALC880_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020068 ALC880_MODEL_LAST /* last tag */
69};
70
71/* ALC260 models */
72enum {
73 ALC260_BASIC,
74 ALC260_HP,
Kailang Yang3f878302008-08-26 13:02:23 +020075 ALC260_HP_DC7600,
Kailang Yangdf694da2005-12-05 19:42:22 +010076 ALC260_HP_3013,
77 ALC260_FUJITSU_S702X,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +010078 ALC260_ACER,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020079 ALC260_WILL,
80 ALC260_REPLACER_672V,
Michael Schwingencc959482009-02-22 18:58:45 +010081 ALC260_FAVORIT100,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +010082#ifdef CONFIG_SND_DEBUG
83 ALC260_TEST,
84#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010085 ALC260_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020086 ALC260_MODEL_LAST /* last tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -070087};
88
Kailang Yangdf694da2005-12-05 19:42:22 +010089/* ALC262 models */
90enum {
91 ALC262_BASIC,
Kailang Yangccc656c2006-10-17 12:32:26 +020092 ALC262_HIPPO,
93 ALC262_HIPPO_1,
Takashi Iwai834be882006-03-01 14:16:17 +010094 ALC262_FUJITSU,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020095 ALC262_HP_BPC,
Kailang Yangcd7509a2007-01-26 18:33:17 +010096 ALC262_HP_BPC_D7000_WL,
97 ALC262_HP_BPC_D7000_WF,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010098 ALC262_HP_TC_T5735,
Kailang Yang8c427222008-01-10 13:03:59 +010099 ALC262_HP_RP5700,
Takashi Iwai304dcaa2006-07-25 14:51:16 +0200100 ALC262_BENQ_ED8,
Kailang Yang272a5272007-05-14 11:00:38 +0200101 ALC262_SONY_ASSAMD,
Kailang Yang83c34212007-07-05 11:43:05 +0200102 ALC262_BENQ_T31,
Tobin Davisf651b502007-10-26 12:40:47 +0200103 ALC262_ULTRA,
Jiang zhe0e31daf2008-03-20 12:12:39 +0100104 ALC262_LENOVO_3000,
Pascal Terjane8f9ae22008-08-04 14:36:05 +0200105 ALC262_NEC,
Kailang Yang4e555fe2008-08-26 13:05:55 +0200106 ALC262_TOSHIBA_S06,
Hiroshi Miura9f99a632008-08-28 16:09:06 +0200107 ALC262_TOSHIBA_RX1,
Tony Vroonba340e82009-02-02 19:01:30 +0000108 ALC262_TYAN,
Kailang Yangdf694da2005-12-05 19:42:22 +0100109 ALC262_AUTO,
110 ALC262_MODEL_LAST /* last tag */
111};
112
Kailang Yanga361d842007-06-05 12:30:55 +0200113/* ALC268 models */
114enum {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +0200115 ALC267_QUANTA_IL1,
Kailang Yanga361d842007-06-05 12:30:55 +0200116 ALC268_3ST,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200117 ALC268_TOSHIBA,
Takashi Iwaid2738092007-08-16 14:59:45 +0200118 ALC268_ACER,
Takashi Iwaic238b4f2008-11-05 14:57:20 +0100119 ALC268_ACER_DMIC,
Kailang Yang8ef355d2008-08-26 13:10:22 +0200120 ALC268_ACER_ASPIRE_ONE,
Takashi Iwai3866f0b2008-01-15 12:37:42 +0100121 ALC268_DELL,
Mirco Tischlerf12462c2008-02-04 12:33:59 +0100122 ALC268_ZEPTO,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +0100123#ifdef CONFIG_SND_DEBUG
124 ALC268_TEST,
125#endif
Kailang Yanga361d842007-06-05 12:30:55 +0200126 ALC268_AUTO,
127 ALC268_MODEL_LAST /* last tag */
128};
129
Kailang Yangf6a92242007-12-13 16:52:54 +0100130/* ALC269 models */
131enum {
132 ALC269_BASIC,
Kailang Yang60db6b52008-08-26 13:13:00 +0200133 ALC269_QUANTA_FL1,
Kailang Yangf53281e2008-07-18 12:36:43 +0200134 ALC269_ASUS_EEEPC_P703,
135 ALC269_ASUS_EEEPC_P901,
Takashi Iwai26f5df22008-11-03 17:39:46 +0100136 ALC269_FUJITSU,
Tony Vroon64154832008-11-06 15:08:49 +0000137 ALC269_LIFEBOOK,
Kailang Yangf6a92242007-12-13 16:52:54 +0100138 ALC269_AUTO,
139 ALC269_MODEL_LAST /* last tag */
140};
141
Kailang Yangdf694da2005-12-05 19:42:22 +0100142/* ALC861 models */
143enum {
144 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200145 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100146 ALC861_3ST_DIG,
147 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200148 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200149 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200150 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100151 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100152 ALC861_AUTO,
153 ALC861_MODEL_LAST,
154};
155
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100156/* ALC861-VD models */
157enum {
158 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200159 ALC660VD_3ST_DIG,
Takashi Iwai13c94742008-11-05 08:06:08 +0100160 ALC660VD_ASUS_V1S,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100161 ALC861VD_3ST,
162 ALC861VD_3ST_DIG,
163 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200164 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200165 ALC861VD_DALLAS,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200166 ALC861VD_HP,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100167 ALC861VD_AUTO,
168 ALC861VD_MODEL_LAST,
169};
170
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200171/* ALC662 models */
172enum {
173 ALC662_3ST_2ch_DIG,
174 ALC662_3ST_6ch_DIG,
175 ALC662_3ST_6ch,
176 ALC662_5ST_DIG,
177 ALC662_LENOVO_101E,
Kailang Yang291702f2007-10-16 14:28:03 +0200178 ALC662_ASUS_EEEPC_P701,
Kailang Yang8c427222008-01-10 13:03:59 +0100179 ALC662_ASUS_EEEPC_EP20,
Kailang Yang6dda9f42008-05-27 12:05:31 +0200180 ALC663_ASUS_M51VA,
181 ALC663_ASUS_G71V,
182 ALC663_ASUS_H13,
183 ALC663_ASUS_G50V,
Kailang Yangf1d4e282008-08-26 14:03:29 +0200184 ALC662_ECS,
185 ALC663_ASUS_MODE1,
186 ALC662_ASUS_MODE2,
187 ALC663_ASUS_MODE3,
188 ALC663_ASUS_MODE4,
189 ALC663_ASUS_MODE5,
190 ALC663_ASUS_MODE6,
Kailang Yang622e84c2009-04-21 07:39:04 +0200191 ALC272_DELL,
192 ALC272_DELL_ZM1,
Chris Pockelé9541ba12009-05-12 08:08:53 +0200193 ALC272_SAMSUNG_NC10,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200194 ALC662_AUTO,
195 ALC662_MODEL_LAST,
196};
197
Kailang Yangdf694da2005-12-05 19:42:22 +0100198/* ALC882 models */
199enum {
200 ALC882_3ST_DIG,
201 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200202 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200203 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200204 ALC882_TARGA,
205 ALC882_ASUS_A7J,
Takashi Iwai914759b2007-09-06 14:52:04 +0200206 ALC882_ASUS_A7M,
Tobin Davis9102cd12006-12-15 10:02:12 +0100207 ALC885_MACPRO,
Takashi Iwai87350ad2007-08-16 18:19:38 +0200208 ALC885_MBP3,
Kacper Szczesniak41d55452009-05-07 12:47:43 +0200209 ALC885_MB5,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200210 ALC885_IMAC24,
Kailang Yang272a5272007-05-14 11:00:38 +0200211 ALC882_AUTO,
Kailang Yangdf694da2005-12-05 19:42:22 +0100212 ALC882_MODEL_LAST,
213};
214
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200215/* ALC883 models */
216enum {
217 ALC883_3ST_2ch_DIG,
218 ALC883_3ST_6ch_DIG,
219 ALC883_3ST_6ch,
220 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200221 ALC883_TARGA_DIG,
222 ALC883_TARGA_2ch_DIG,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +0200223 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200224 ALC883_ACER_ASPIRE,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +0800225 ALC888_ACER_ASPIRE_4930G,
Tobin Davisc07584c2006-10-13 12:32:16 +0200226 ALC883_MEDION,
Kailang Yangea1fb292008-08-26 12:58:38 +0200227 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100228 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200229 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200230 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200231 ALC888_LENOVO_MS7195_DIG,
Kailang Yange2757d52008-08-26 13:17:46 +0200232 ALC888_LENOVO_SKY,
Kailang Yangea1fb292008-08-26 12:58:38 +0200233 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200234 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100235 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100236 ALC883_MITAC,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100237 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100238 ALC883_FUJITSU_PI2515,
Vincent Petryef8ef5f2008-11-23 11:31:41 +0800239 ALC888_FUJITSU_XA3530,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200240 ALC883_3ST_6ch_INTEL,
Kailang Yange2757d52008-08-26 13:17:46 +0200241 ALC888_ASUS_M90V,
242 ALC888_ASUS_EEE1601,
Wu Fengguang3ab90932008-11-17 09:51:09 +0100243 ALC1200_ASUS_P5Q,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200244 ALC883_AUTO,
245 ALC883_MODEL_LAST,
246};
247
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200248/* styles of capture selection */
249enum {
250 CAPT_MUX = 0, /* only mux based */
251 CAPT_MIX, /* only mixer based */
252 CAPT_1MUX_MIX, /* first mux and other mixers */
253};
254
Kailang Yangdf694da2005-12-05 19:42:22 +0100255/* for GPIO Poll */
256#define GPIO_MASK 0x03
257
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200258/* extra amp-initialization sequence types */
259enum {
260 ALC_INIT_NONE,
261 ALC_INIT_DEFAULT,
262 ALC_INIT_GPIO1,
263 ALC_INIT_GPIO2,
264 ALC_INIT_GPIO3,
265};
266
Linus Torvalds1da177e2005-04-16 15:20:36 -0700267struct alc_spec {
268 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100269 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700270 unsigned int num_mixers;
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100271 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100272 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700273
Kailang Yangdf694da2005-12-05 19:42:22 +0100274 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200275 * don't forget NULL
276 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200277 */
278 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700279
Takashi Iwai16ded522005-06-10 19:58:24 +0200280 char *stream_name_analog; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700281 struct hda_pcm_stream *stream_analog_playback;
282 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100283 struct hda_pcm_stream *stream_analog_alt_playback;
284 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700285
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200286 char *stream_name_digital; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700287 struct hda_pcm_stream *stream_digital_playback;
288 struct hda_pcm_stream *stream_digital_capture;
289
290 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200291 struct hda_multi_out multiout; /* playback set-up
292 * max_channels, dacs must be set
293 * dig_out_nid and hp_nid are optional
294 */
Takashi Iwai63300792008-01-24 15:31:36 +0100295 hda_nid_t alt_dac_nid;
Takashi Iwai6a05ac42009-02-13 11:19:09 +0100296 hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */
Takashi Iwai8c441982009-01-20 18:30:20 +0100297 int dig_out_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700298
299 /* capture */
300 unsigned int num_adc_nids;
301 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100302 hda_nid_t *capsrc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200303 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200304 int capture_style; /* capture style (CAPT_*) */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305
306 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200307 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700308 const struct hda_input_mux *input_mux;
309 unsigned int cur_mux[3];
310
311 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100312 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700313 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200314 int need_dac_fix;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700315
316 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100317 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200318
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200319 /* dynamic controls, init_verbs and input_mux */
320 struct auto_pin_cfg autocfg;
Takashi Iwai603c4012008-07-30 15:01:44 +0200321 struct snd_array kctls;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200322 struct hda_input_mux private_imux[3];
Takashi Iwai41923e42007-10-22 17:20:10 +0200323 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100324
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100325 /* hooks */
326 void (*init_hook)(struct hda_codec *codec);
327 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
328
Takashi Iwai834be882006-03-01 14:16:17 +0100329 /* for pin sensing */
330 unsigned int sense_updated: 1;
331 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100332 unsigned int master_sw: 1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200333
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100334 /* other flags */
335 unsigned int no_analog :1; /* digital I/O only */
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200336 int init_amp;
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100337
Takashi Iwai2134ea42008-01-10 16:53:55 +0100338 /* for virtual master */
339 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200340#ifdef CONFIG_SND_HDA_POWER_SAVE
341 struct hda_loopback_check loopback;
342#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200343
344 /* for PLL fix */
345 hda_nid_t pll_nid;
346 unsigned int pll_coef_idx, pll_coef_bit;
Kailang Yangdf694da2005-12-05 19:42:22 +0100347};
348
349/*
350 * configuration template - to be copied to the spec instance
351 */
352struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200353 struct snd_kcontrol_new *mixers[5]; /* should be identical size
354 * with spec
355 */
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100356 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Kailang Yangdf694da2005-12-05 19:42:22 +0100357 const struct hda_verb *init_verbs[5];
358 unsigned int num_dacs;
359 hda_nid_t *dac_nids;
360 hda_nid_t dig_out_nid; /* optional */
361 hda_nid_t hp_nid; /* optional */
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800362 hda_nid_t *slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100363 unsigned int num_adc_nids;
364 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100365 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100366 hda_nid_t dig_in_nid;
367 unsigned int num_channel_mode;
368 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200369 int need_dac_fix;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200370 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100371 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100372 void (*unsol_event)(struct hda_codec *, unsigned int);
373 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200374#ifdef CONFIG_SND_HDA_POWER_SAVE
375 struct hda_amp_list *loopbacks;
376#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700377};
378
Linus Torvalds1da177e2005-04-16 15:20:36 -0700379
380/*
381 * input MUX handling
382 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200383static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
384 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700385{
386 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
387 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200388 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
389 if (mux_idx >= spec->num_mux_defs)
390 mux_idx = 0;
391 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700392}
393
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200394static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
395 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700396{
397 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
398 struct alc_spec *spec = codec->spec;
399 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
400
401 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
402 return 0;
403}
404
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200405static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
406 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700407{
408 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
409 struct alc_spec *spec = codec->spec;
Takashi Iwaicd896c32008-11-18 12:36:33 +0100410 const struct hda_input_mux *imux;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700411 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwaicd896c32008-11-18 12:36:33 +0100412 unsigned int mux_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100413 hda_nid_t nid = spec->capsrc_nids ?
414 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700415
Takashi Iwaicd896c32008-11-18 12:36:33 +0100416 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
417 imux = &spec->input_mux[mux_idx];
418
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200419 if (spec->capture_style &&
420 !(spec->capture_style == CAPT_1MUX_MIX && !adc_idx)) {
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100421 /* Matrix-mixer style (e.g. ALC882) */
422 unsigned int *cur_val = &spec->cur_mux[adc_idx];
423 unsigned int i, idx;
424
425 idx = ucontrol->value.enumerated.item[0];
426 if (idx >= imux->num_items)
427 idx = imux->num_items - 1;
428 if (*cur_val == idx)
429 return 0;
430 for (i = 0; i < imux->num_items; i++) {
431 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
432 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
433 imux->items[i].index,
434 HDA_AMP_MUTE, v);
435 }
436 *cur_val = idx;
437 return 1;
438 } else {
439 /* MUX style (e.g. ALC880) */
Takashi Iwaicd896c32008-11-18 12:36:33 +0100440 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100441 &spec->cur_mux[adc_idx]);
442 }
443}
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200444
Linus Torvalds1da177e2005-04-16 15:20:36 -0700445/*
446 * channel mode setting
447 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200448static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
449 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700450{
451 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
452 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100453 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
454 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700455}
456
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200457static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
458 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700459{
460 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
461 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100462 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200463 spec->num_channel_mode,
464 spec->multiout.max_channels);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700465}
466
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200467static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
468 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469{
470 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
471 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200472 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
473 spec->num_channel_mode,
474 &spec->multiout.max_channels);
Takashi Iwaibd2033f2006-10-10 19:49:31 +0200475 if (err >= 0 && spec->need_dac_fix)
Takashi Iwai4e195a72006-07-28 14:47:34 +0200476 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
477 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700478}
479
Linus Torvalds1da177e2005-04-16 15:20:36 -0700480/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100481 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200482 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100483 * being part of a format specifier. Maximum allowed length of a value is
484 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100485 *
486 * Note: some retasking pin complexes seem to ignore requests for input
487 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
488 * are requested. Therefore order this list so that this behaviour will not
489 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200490 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
491 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200492 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100493static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100494 "Mic 50pc bias", "Mic 80pc bias",
495 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100496};
497static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100498 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100499};
500/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200501 * in the pin being assumed to be exclusively an input or an output pin. In
502 * addition, "input" pins may or may not process the mic bias option
503 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
504 * accept requests for bias as of chip versions up to March 2006) and/or
505 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100506 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200507#define ALC_PIN_DIR_IN 0x00
508#define ALC_PIN_DIR_OUT 0x01
509#define ALC_PIN_DIR_INOUT 0x02
510#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
511#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100512
Kailang Yangea1fb292008-08-26 12:58:38 +0200513/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100514 * For each direction the minimum and maximum values are given.
515 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200516static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100517 { 0, 2 }, /* ALC_PIN_DIR_IN */
518 { 3, 4 }, /* ALC_PIN_DIR_OUT */
519 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200520 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
521 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100522};
523#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
524#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
525#define alc_pin_mode_n_items(_dir) \
526 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
527
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200528static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
529 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200530{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100531 unsigned int item_num = uinfo->value.enumerated.item;
532 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
533
534 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200535 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100536 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
537
538 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
539 item_num = alc_pin_mode_min(dir);
540 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200541 return 0;
542}
543
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200544static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
545 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200546{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100547 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200548 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
549 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100550 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200551 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200552 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
553 AC_VERB_GET_PIN_WIDGET_CONTROL,
554 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200555
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100556 /* Find enumerated value for current pinctl setting */
557 i = alc_pin_mode_min(dir);
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200558 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100559 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200560 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100561 return 0;
562}
563
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200564static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
565 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100566{
567 signed int change;
568 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
569 hda_nid_t nid = kcontrol->private_value & 0xffff;
570 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
571 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200572 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
573 AC_VERB_GET_PIN_WIDGET_CONTROL,
574 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100575
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200576 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100577 val = alc_pin_mode_min(dir);
578
579 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100580 if (change) {
581 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200582 snd_hda_codec_write_cache(codec, nid, 0,
583 AC_VERB_SET_PIN_WIDGET_CONTROL,
584 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100585
Kailang Yangea1fb292008-08-26 12:58:38 +0200586 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100587 * for the requested pin mode. Enum values of 2 or less are
588 * input modes.
589 *
590 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200591 * reduces noise slightly (particularly on input) so we'll
592 * do it. However, having both input and output buffers
593 * enabled simultaneously doesn't seem to be problematic if
594 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100595 */
596 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200597 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
598 HDA_AMP_MUTE, HDA_AMP_MUTE);
599 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
600 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100601 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200602 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
603 HDA_AMP_MUTE, HDA_AMP_MUTE);
604 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
605 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100606 }
607 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200608 return change;
609}
610
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100611#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200612 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100613 .info = alc_pin_mode_info, \
614 .get = alc_pin_mode_get, \
615 .put = alc_pin_mode_put, \
616 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100617
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100618/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
619 * together using a mask with more than one bit set. This control is
620 * currently used only by the ALC260 test model. At this stage they are not
621 * needed for any "production" models.
622 */
623#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200624#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200625
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200626static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
627 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100628{
629 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
630 hda_nid_t nid = kcontrol->private_value & 0xffff;
631 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
632 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200633 unsigned int val = snd_hda_codec_read(codec, nid, 0,
634 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100635
636 *valp = (val & mask) != 0;
637 return 0;
638}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200639static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
640 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100641{
642 signed int change;
643 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
644 hda_nid_t nid = kcontrol->private_value & 0xffff;
645 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
646 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200647 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
648 AC_VERB_GET_GPIO_DATA,
649 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100650
651 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200652 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
653 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100654 gpio_data &= ~mask;
655 else
656 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200657 snd_hda_codec_write_cache(codec, nid, 0,
658 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100659
660 return change;
661}
662#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
663 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
664 .info = alc_gpio_data_info, \
665 .get = alc_gpio_data_get, \
666 .put = alc_gpio_data_put, \
667 .private_value = nid | (mask<<16) }
668#endif /* CONFIG_SND_DEBUG */
669
Jonathan Woithe92621f12006-02-28 11:47:47 +0100670/* A switch control to allow the enabling of the digital IO pins on the
671 * ALC260. This is incredibly simplistic; the intention of this control is
672 * to provide something in the test model allowing digital outputs to be
673 * identified if present. If models are found which can utilise these
674 * outputs a more complete mixer control can be devised for those models if
675 * necessary.
676 */
677#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200678#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200679
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200680static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
681 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100682{
683 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
684 hda_nid_t nid = kcontrol->private_value & 0xffff;
685 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
686 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200687 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100688 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100689
690 *valp = (val & mask) != 0;
691 return 0;
692}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200693static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
694 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100695{
696 signed int change;
697 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
698 hda_nid_t nid = kcontrol->private_value & 0xffff;
699 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
700 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200701 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100702 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200703 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100704
705 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200706 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100707 if (val==0)
708 ctrl_data &= ~mask;
709 else
710 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200711 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
712 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100713
714 return change;
715}
716#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
717 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
718 .info = alc_spdif_ctrl_info, \
719 .get = alc_spdif_ctrl_get, \
720 .put = alc_spdif_ctrl_put, \
721 .private_value = nid | (mask<<16) }
722#endif /* CONFIG_SND_DEBUG */
723
Jonathan Woithef8225f62008-01-08 12:16:54 +0100724/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
725 * Again, this is only used in the ALC26x test models to help identify when
726 * the EAPD line must be asserted for features to work.
727 */
728#ifdef CONFIG_SND_DEBUG
729#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
730
731static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
732 struct snd_ctl_elem_value *ucontrol)
733{
734 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
735 hda_nid_t nid = kcontrol->private_value & 0xffff;
736 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
737 long *valp = ucontrol->value.integer.value;
738 unsigned int val = snd_hda_codec_read(codec, nid, 0,
739 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
740
741 *valp = (val & mask) != 0;
742 return 0;
743}
744
745static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
746 struct snd_ctl_elem_value *ucontrol)
747{
748 int change;
749 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
750 hda_nid_t nid = kcontrol->private_value & 0xffff;
751 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
752 long val = *ucontrol->value.integer.value;
753 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
754 AC_VERB_GET_EAPD_BTLENABLE,
755 0x00);
756
757 /* Set/unset the masked control bit(s) as needed */
758 change = (!val ? 0 : mask) != (ctrl_data & mask);
759 if (!val)
760 ctrl_data &= ~mask;
761 else
762 ctrl_data |= mask;
763 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
764 ctrl_data);
765
766 return change;
767}
768
769#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
770 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
771 .info = alc_eapd_ctrl_info, \
772 .get = alc_eapd_ctrl_get, \
773 .put = alc_eapd_ctrl_put, \
774 .private_value = nid | (mask<<16) }
775#endif /* CONFIG_SND_DEBUG */
776
Kailang Yangdf694da2005-12-05 19:42:22 +0100777/*
Takashi Iwai23f0c042009-02-26 13:03:58 +0100778 * set up the input pin config (depending on the given auto-pin type)
779 */
780static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
781 int auto_pin_type)
782{
783 unsigned int val = PIN_IN;
784
785 if (auto_pin_type <= AUTO_PIN_FRONT_MIC) {
786 unsigned int pincap;
Takashi Iwai1327a322009-03-23 13:07:47 +0100787 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai23f0c042009-02-26 13:03:58 +0100788 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
789 if (pincap & AC_PINCAP_VREF_80)
790 val = PIN_VREF80;
791 }
792 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
793}
794
795/*
Takashi Iwaid88897e2008-10-31 15:01:37 +0100796 */
797static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
798{
799 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
800 return;
801 spec->mixers[spec->num_mixers++] = mix;
802}
803
804static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
805{
806 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
807 return;
808 spec->init_verbs[spec->num_init_verbs++] = verb;
809}
810
Takashi Iwaidaead532008-11-28 12:55:36 +0100811#ifdef CONFIG_PROC_FS
812/*
813 * hook for proc
814 */
815static void print_realtek_coef(struct snd_info_buffer *buffer,
816 struct hda_codec *codec, hda_nid_t nid)
817{
818 int coeff;
819
820 if (nid != 0x20)
821 return;
822 coeff = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PROC_COEF, 0);
823 snd_iprintf(buffer, " Processing Coefficient: 0x%02x\n", coeff);
824 coeff = snd_hda_codec_read(codec, nid, 0,
825 AC_VERB_GET_COEF_INDEX, 0);
826 snd_iprintf(buffer, " Coefficient Index: 0x%02x\n", coeff);
827}
828#else
829#define print_realtek_coef NULL
830#endif
831
Takashi Iwaid88897e2008-10-31 15:01:37 +0100832/*
Kailang Yangdf694da2005-12-05 19:42:22 +0100833 * set up from the preset table
834 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200835static void setup_preset(struct alc_spec *spec,
836 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100837{
838 int i;
839
840 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100841 add_mixer(spec, preset->mixers[i]);
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100842 spec->cap_mixer = preset->cap_mixer;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200843 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
844 i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100845 add_verb(spec, preset->init_verbs[i]);
Kailang Yangea1fb292008-08-26 12:58:38 +0200846
Kailang Yangdf694da2005-12-05 19:42:22 +0100847 spec->channel_mode = preset->channel_mode;
848 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200849 spec->need_dac_fix = preset->need_dac_fix;
Kailang Yangdf694da2005-12-05 19:42:22 +0100850
851 spec->multiout.max_channels = spec->channel_mode[0].channels;
852
853 spec->multiout.num_dacs = preset->num_dacs;
854 spec->multiout.dac_nids = preset->dac_nids;
855 spec->multiout.dig_out_nid = preset->dig_out_nid;
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800856 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100857 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200858
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200859 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200860 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200861 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100862 spec->input_mux = preset->input_mux;
863
864 spec->num_adc_nids = preset->num_adc_nids;
865 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100866 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100867 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100868
869 spec->unsol_event = preset->unsol_event;
870 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200871#ifdef CONFIG_SND_HDA_POWER_SAVE
872 spec->loopback.amplist = preset->loopbacks;
873#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100874}
875
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200876/* Enable GPIO mask and set output */
877static struct hda_verb alc_gpio1_init_verbs[] = {
878 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
879 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
880 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
881 { }
882};
883
884static struct hda_verb alc_gpio2_init_verbs[] = {
885 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
886 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
887 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
888 { }
889};
890
Kailang Yangbdd148a2007-05-08 15:19:08 +0200891static struct hda_verb alc_gpio3_init_verbs[] = {
892 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
893 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
894 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
895 { }
896};
897
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200898/*
899 * Fix hardware PLL issue
900 * On some codecs, the analog PLL gating control must be off while
901 * the default value is 1.
902 */
903static void alc_fix_pll(struct hda_codec *codec)
904{
905 struct alc_spec *spec = codec->spec;
906 unsigned int val;
907
908 if (!spec->pll_nid)
909 return;
910 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
911 spec->pll_coef_idx);
912 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
913 AC_VERB_GET_PROC_COEF, 0);
914 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
915 spec->pll_coef_idx);
916 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
917 val & ~(1 << spec->pll_coef_bit));
918}
919
920static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
921 unsigned int coef_idx, unsigned int coef_bit)
922{
923 struct alc_spec *spec = codec->spec;
924 spec->pll_nid = nid;
925 spec->pll_coef_idx = coef_idx;
926 spec->pll_coef_bit = coef_bit;
927 alc_fix_pll(codec);
928}
929
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200930static void alc_automute_pin(struct hda_codec *codec)
Kailang Yangc9b58002007-10-16 14:30:01 +0200931{
932 struct alc_spec *spec = codec->spec;
Kailang Yangc9b58002007-10-16 14:30:01 +0200933 unsigned int present;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200934 unsigned int nid = spec->autocfg.hp_pins[0];
935 int i;
Kailang Yangc9b58002007-10-16 14:30:01 +0200936
937 /* need to execute and sync at first */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200938 snd_hda_codec_read(codec, nid, 0, AC_VERB_SET_PIN_SENSE, 0);
939 present = snd_hda_codec_read(codec, nid, 0,
Kailang Yangc9b58002007-10-16 14:30:01 +0200940 AC_VERB_GET_PIN_SENSE, 0);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200941 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
942 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
943 nid = spec->autocfg.speaker_pins[i];
944 if (!nid)
945 break;
946 snd_hda_codec_write(codec, nid, 0,
947 AC_VERB_SET_PIN_WIDGET_CONTROL,
948 spec->jack_present ? 0 : PIN_OUT);
949 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200950}
951
Takashi Iwai4605b712008-10-31 14:18:24 +0100952#if 0 /* it's broken in some acses -- temporarily disabled */
Kailang Yang7fb0d782008-10-15 11:12:35 +0200953static void alc_mic_automute(struct hda_codec *codec)
954{
955 struct alc_spec *spec = codec->spec;
956 unsigned int present;
957 unsigned int mic_nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
958 unsigned int fmic_nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
959 unsigned int mix_nid = spec->capsrc_nids[0];
960 unsigned int capsrc_idx_mic, capsrc_idx_fmic;
961
962 capsrc_idx_mic = mic_nid - 0x18;
963 capsrc_idx_fmic = fmic_nid - 0x18;
964 present = snd_hda_codec_read(codec, mic_nid, 0,
965 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
966 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
967 0x7000 | (capsrc_idx_mic << 8) | (present ? 0 : 0x80));
968 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
969 0x7000 | (capsrc_idx_fmic << 8) | (present ? 0x80 : 0));
970 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, capsrc_idx_fmic,
971 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
972}
Takashi Iwai4605b712008-10-31 14:18:24 +0100973#else
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100974#define alc_mic_automute(codec) do {} while(0) /* NOP */
Takashi Iwai4605b712008-10-31 14:18:24 +0100975#endif /* disabled */
Kailang Yang7fb0d782008-10-15 11:12:35 +0200976
Kailang Yangc9b58002007-10-16 14:30:01 +0200977/* unsolicited event for HP jack sensing */
978static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
979{
980 if (codec->vendor_id == 0x10ec0880)
981 res >>= 28;
982 else
983 res >>= 26;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200984 switch (res) {
985 case ALC880_HP_EVENT:
986 alc_automute_pin(codec);
987 break;
988 case ALC880_MIC_EVENT:
Kailang Yang7fb0d782008-10-15 11:12:35 +0200989 alc_mic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200990 break;
991 }
Kailang Yang7fb0d782008-10-15 11:12:35 +0200992}
993
994static void alc_inithook(struct hda_codec *codec)
995{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200996 alc_automute_pin(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +0200997 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +0200998}
999
Kailang Yangf9423e72008-05-27 12:32:25 +02001000/* additional initialization for ALC888 variants */
1001static void alc888_coef_init(struct hda_codec *codec)
1002{
1003 unsigned int tmp;
1004
1005 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1006 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1007 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
Takashi Iwai37db6232009-03-05 09:40:16 +01001008 if ((tmp & 0xf0) == 0x20)
Kailang Yangf9423e72008-05-27 12:32:25 +02001009 /* alc888S-VC */
1010 snd_hda_codec_read(codec, 0x20, 0,
1011 AC_VERB_SET_PROC_COEF, 0x830);
1012 else
1013 /* alc888-VB */
1014 snd_hda_codec_read(codec, 0x20, 0,
1015 AC_VERB_SET_PROC_COEF, 0x3030);
1016}
1017
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001018static void alc_auto_init_amp(struct hda_codec *codec, int type)
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001019{
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001020 unsigned int tmp;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001021
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001022 switch (type) {
1023 case ALC_INIT_GPIO1:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001024 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1025 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001026 case ALC_INIT_GPIO2:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001027 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1028 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001029 case ALC_INIT_GPIO3:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001030 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1031 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001032 case ALC_INIT_DEFAULT:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001033 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001034 case 0x10ec0260:
1035 snd_hda_codec_write(codec, 0x0f, 0,
1036 AC_VERB_SET_EAPD_BTLENABLE, 2);
1037 snd_hda_codec_write(codec, 0x10, 0,
1038 AC_VERB_SET_EAPD_BTLENABLE, 2);
1039 break;
1040 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001041 case 0x10ec0267:
1042 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001043 case 0x10ec0269:
Takashi Iwaic6e8f2d2009-02-06 12:45:52 +01001044 case 0x10ec0272:
Kailang Yangf9423e72008-05-27 12:32:25 +02001045 case 0x10ec0660:
1046 case 0x10ec0662:
1047 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001048 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001049 case 0x10ec0889:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001050 snd_hda_codec_write(codec, 0x14, 0,
1051 AC_VERB_SET_EAPD_BTLENABLE, 2);
1052 snd_hda_codec_write(codec, 0x15, 0,
1053 AC_VERB_SET_EAPD_BTLENABLE, 2);
Kailang Yangc9b58002007-10-16 14:30:01 +02001054 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001055 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001056 switch (codec->vendor_id) {
1057 case 0x10ec0260:
1058 snd_hda_codec_write(codec, 0x1a, 0,
1059 AC_VERB_SET_COEF_INDEX, 7);
1060 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1061 AC_VERB_GET_PROC_COEF, 0);
1062 snd_hda_codec_write(codec, 0x1a, 0,
1063 AC_VERB_SET_COEF_INDEX, 7);
1064 snd_hda_codec_write(codec, 0x1a, 0,
1065 AC_VERB_SET_PROC_COEF,
1066 tmp | 0x2010);
1067 break;
1068 case 0x10ec0262:
1069 case 0x10ec0880:
1070 case 0x10ec0882:
1071 case 0x10ec0883:
1072 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001073 case 0x10ec0887:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001074 case 0x10ec0889:
Kailang Yangc9b58002007-10-16 14:30:01 +02001075 snd_hda_codec_write(codec, 0x20, 0,
1076 AC_VERB_SET_COEF_INDEX, 7);
1077 tmp = snd_hda_codec_read(codec, 0x20, 0,
1078 AC_VERB_GET_PROC_COEF, 0);
1079 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001080 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001081 snd_hda_codec_write(codec, 0x20, 0,
1082 AC_VERB_SET_PROC_COEF,
1083 tmp | 0x2010);
1084 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001085 case 0x10ec0888:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001086 alc888_coef_init(codec);
Kailang Yangf9423e72008-05-27 12:32:25 +02001087 break;
Kailang Yangc9b58002007-10-16 14:30:01 +02001088 case 0x10ec0267:
1089 case 0x10ec0268:
1090 snd_hda_codec_write(codec, 0x20, 0,
1091 AC_VERB_SET_COEF_INDEX, 7);
1092 tmp = snd_hda_codec_read(codec, 0x20, 0,
1093 AC_VERB_GET_PROC_COEF, 0);
1094 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001095 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001096 snd_hda_codec_write(codec, 0x20, 0,
1097 AC_VERB_SET_PROC_COEF,
1098 tmp | 0x3000);
1099 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001100 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001101 break;
1102 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001103}
Kailang Yangea1fb292008-08-26 12:58:38 +02001104
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001105static void alc_init_auto_hp(struct hda_codec *codec)
1106{
1107 struct alc_spec *spec = codec->spec;
1108
1109 if (!spec->autocfg.hp_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +02001110 return;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001111
Kailang Yangc9b58002007-10-16 14:30:01 +02001112 if (!spec->autocfg.speaker_pins[0]) {
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001113 if (spec->autocfg.line_out_pins[0] &&
1114 spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT)
Kailang Yangc9b58002007-10-16 14:30:01 +02001115 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +01001116 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +02001117 else
1118 return;
1119 }
1120
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001121 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1122 spec->autocfg.hp_pins[0]);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001123 snd_hda_codec_write_cache(codec, spec->autocfg.hp_pins[0], 0,
1124 AC_VERB_SET_UNSOLICITED_ENABLE,
1125 AC_USRSP_EN | ALC880_HP_EVENT);
1126 spec->unsol_event = alc_sku_unsol_event;
1127}
1128
1129/* check subsystem ID and set up device-specific initialization;
1130 * return 1 if initialized, 0 if invalid SSID
1131 */
1132/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1133 * 31 ~ 16 : Manufacture ID
1134 * 15 ~ 8 : SKU ID
1135 * 7 ~ 0 : Assembly ID
1136 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1137 */
1138static int alc_subsystem_id(struct hda_codec *codec,
1139 hda_nid_t porta, hda_nid_t porte,
1140 hda_nid_t portd)
1141{
1142 unsigned int ass, tmp, i;
1143 unsigned nid;
1144 struct alc_spec *spec = codec->spec;
1145
1146 ass = codec->subsystem_id & 0xffff;
1147 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1148 goto do_sku;
1149
1150 /* invalid SSID, check the special NID pin defcfg instead */
1151 /*
1152 * 31~30 : port conetcivity
1153 * 29~21 : reserve
1154 * 20 : PCBEEP input
1155 * 19~16 : Check sum (15:1)
1156 * 15~1 : Custom
1157 * 0 : override
1158 */
1159 nid = 0x1d;
1160 if (codec->vendor_id == 0x10ec0260)
1161 nid = 0x17;
1162 ass = snd_hda_codec_get_pincfg(codec, nid);
1163 snd_printd("realtek: No valid SSID, "
1164 "checking pincfg 0x%08x for NID 0x%x\n",
Takashi Iwaicb6605c2009-04-28 13:03:19 +02001165 ass, nid);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001166 if (!(ass & 1) && !(ass & 0x100000))
1167 return 0;
1168 if ((ass >> 30) != 1) /* no physical connection */
1169 return 0;
1170
1171 /* check sum */
1172 tmp = 0;
1173 for (i = 1; i < 16; i++) {
1174 if ((ass >> i) & 1)
1175 tmp++;
1176 }
1177 if (((ass >> 16) & 0xf) != tmp)
1178 return 0;
1179do_sku:
1180 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1181 ass & 0xffff, codec->vendor_id);
1182 /*
1183 * 0 : override
1184 * 1 : Swap Jack
1185 * 2 : 0 --> Desktop, 1 --> Laptop
1186 * 3~5 : External Amplifier control
1187 * 7~6 : Reserved
1188 */
1189 tmp = (ass & 0x38) >> 3; /* external Amp control */
1190 switch (tmp) {
1191 case 1:
1192 spec->init_amp = ALC_INIT_GPIO1;
1193 break;
1194 case 3:
1195 spec->init_amp = ALC_INIT_GPIO2;
1196 break;
1197 case 7:
1198 spec->init_amp = ALC_INIT_GPIO3;
1199 break;
1200 case 5:
1201 spec->init_amp = ALC_INIT_DEFAULT;
1202 break;
1203 }
1204
1205 /* is laptop or Desktop and enable the function "Mute internal speaker
1206 * when the external headphone out jack is plugged"
1207 */
1208 if (!(ass & 0x8000))
1209 return 1;
1210 /*
1211 * 10~8 : Jack location
1212 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1213 * 14~13: Resvered
1214 * 15 : 1 --> enable the function "Mute internal speaker
1215 * when the external headphone out jack is plugged"
1216 */
Kailang Yangc9b58002007-10-16 14:30:01 +02001217 if (!spec->autocfg.hp_pins[0]) {
1218 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1219 if (tmp == 0)
1220 spec->autocfg.hp_pins[0] = porta;
1221 else if (tmp == 1)
1222 spec->autocfg.hp_pins[0] = porte;
1223 else if (tmp == 2)
1224 spec->autocfg.hp_pins[0] = portd;
1225 else
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001226 return 1;
Kailang Yangc9b58002007-10-16 14:30:01 +02001227 }
1228
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001229 alc_init_auto_hp(codec);
1230 return 1;
1231}
Kailang Yangea1fb292008-08-26 12:58:38 +02001232
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001233static void alc_ssid_check(struct hda_codec *codec,
1234 hda_nid_t porta, hda_nid_t porte, hda_nid_t portd)
1235{
1236 if (!alc_subsystem_id(codec, porta, porte, portd)) {
1237 struct alc_spec *spec = codec->spec;
1238 snd_printd("realtek: "
1239 "Enable default setup for auto mode as fallback\n");
1240 spec->init_amp = ALC_INIT_DEFAULT;
1241 alc_init_auto_hp(codec);
1242 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001243}
1244
Takashi Iwai41e41f12005-06-08 14:48:49 +02001245/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02001246 * Fix-up pin default configurations
1247 */
1248
1249struct alc_pincfg {
1250 hda_nid_t nid;
1251 u32 val;
1252};
1253
1254static void alc_fix_pincfg(struct hda_codec *codec,
1255 const struct snd_pci_quirk *quirk,
1256 const struct alc_pincfg **pinfix)
1257{
1258 const struct alc_pincfg *cfg;
1259
1260 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1261 if (!quirk)
1262 return;
1263
1264 cfg = pinfix[quirk->value];
Takashi Iwai0e8a21b2009-02-20 14:13:06 +01001265 for (; cfg->nid; cfg++)
1266 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
Takashi Iwaif95474e2007-07-10 00:47:43 +02001267}
1268
1269/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001270 * ALC888
1271 */
1272
1273/*
1274 * 2ch mode
1275 */
1276static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1277/* Mic-in jack as mic in */
1278 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1279 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1280/* Line-in jack as Line in */
1281 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1282 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1283/* Line-Out as Front */
1284 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1285 { } /* end */
1286};
1287
1288/*
1289 * 4ch mode
1290 */
1291static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1292/* Mic-in jack as mic in */
1293 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1294 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1295/* Line-in jack as Surround */
1296 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1297 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1298/* Line-Out as Front */
1299 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1300 { } /* end */
1301};
1302
1303/*
1304 * 6ch mode
1305 */
1306static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1307/* Mic-in jack as CLFE */
1308 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1309 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1310/* Line-in jack as Surround */
1311 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1312 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1313/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1314 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1315 { } /* end */
1316};
1317
1318/*
1319 * 8ch mode
1320 */
1321static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1322/* Mic-in jack as CLFE */
1323 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1324 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1325/* Line-in jack as Surround */
1326 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1327 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1328/* Line-Out as Side */
1329 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1330 { } /* end */
1331};
1332
1333static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1334 { 2, alc888_4ST_ch2_intel_init },
1335 { 4, alc888_4ST_ch4_intel_init },
1336 { 6, alc888_4ST_ch6_intel_init },
1337 { 8, alc888_4ST_ch8_intel_init },
1338};
1339
1340/*
1341 * ALC888 Fujitsu Siemens Amillo xa3530
1342 */
1343
1344static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1345/* Front Mic: set to PIN_IN (empty by default) */
1346 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1347/* Connect Internal HP to Front */
1348 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1349 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1350 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1351/* Connect Bass HP to Front */
1352 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1353 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1354 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1355/* Connect Line-Out side jack (SPDIF) to Side */
1356 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1357 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1358 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1359/* Connect Mic jack to CLFE */
1360 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1361 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1362 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1363/* Connect Line-in jack to Surround */
1364 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1365 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1366 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1367/* Connect HP out jack to Front */
1368 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1369 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1370 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1371/* Enable unsolicited event for HP jack and Line-out jack */
1372 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1373 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1374 {}
1375};
1376
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001377static void alc_automute_amp(struct hda_codec *codec)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001378{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001379 struct alc_spec *spec = codec->spec;
1380 unsigned int val, mute;
1381 hda_nid_t nid;
1382 int i;
1383
1384 spec->jack_present = 0;
1385 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1386 nid = spec->autocfg.hp_pins[i];
1387 if (!nid)
1388 break;
1389 val = snd_hda_codec_read(codec, nid, 0,
1390 AC_VERB_GET_PIN_SENSE, 0);
1391 if (val & AC_PINSENSE_PRESENCE) {
1392 spec->jack_present = 1;
1393 break;
1394 }
1395 }
1396
1397 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001398 /* Toggle internal speakers muting */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001399 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1400 nid = spec->autocfg.speaker_pins[i];
1401 if (!nid)
1402 break;
1403 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1404 HDA_AMP_MUTE, mute);
1405 }
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001406}
1407
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001408static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1409 unsigned int res)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001410{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001411 if (codec->vendor_id == 0x10ec0880)
1412 res >>= 28;
1413 else
1414 res >>= 26;
1415 if (res == ALC880_HP_EVENT)
1416 alc_automute_amp(codec);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001417}
1418
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001419static void alc888_fujitsu_xa3530_init_hook(struct hda_codec *codec)
1420{
1421 struct alc_spec *spec = codec->spec;
1422
1423 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1424 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1425 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1426 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
1427 alc_automute_amp(codec);
1428}
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001429
1430/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001431 * ALC888 Acer Aspire 4930G model
1432 */
1433
1434static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1435/* Front Mic: set to PIN_IN (empty by default) */
1436 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1437/* Unselect Front Mic by default in input mixer 3 */
1438 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001439/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001440 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1441/* Connect Internal HP to front */
1442 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1443 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1444 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1445/* Connect HP out to front */
1446 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1447 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1448 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1449 { }
1450};
1451
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001452static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001453 /* Front mic only available on one ADC */
1454 {
1455 .num_items = 4,
1456 .items = {
1457 { "Mic", 0x0 },
1458 { "Line", 0x2 },
1459 { "CD", 0x4 },
1460 { "Front Mic", 0xb },
1461 },
1462 },
1463 {
1464 .num_items = 3,
1465 .items = {
1466 { "Mic", 0x0 },
1467 { "Line", 0x2 },
1468 { "CD", 0x4 },
1469 },
1470 }
1471};
1472
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001473static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001474 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1475 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1476 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1477 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1478 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1479 HDA_OUTPUT),
1480 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1481 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1482 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1483 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1484 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1485 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1486 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1487 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1488 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1489 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1490 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1491 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001492 { } /* end */
1493};
1494
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001495static void alc888_acer_aspire_4930g_init_hook(struct hda_codec *codec)
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001496{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001497 struct alc_spec *spec = codec->spec;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001498
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001499 spec->autocfg.hp_pins[0] = 0x15;
1500 spec->autocfg.speaker_pins[0] = 0x14;
1501 alc_automute_amp(codec);
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001502}
1503
1504/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001505 * ALC880 3-stack model
1506 *
1507 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001508 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1509 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07001510 */
1511
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001512static hda_nid_t alc880_dac_nids[4] = {
1513 /* front, rear, clfe, rear_surr */
1514 0x02, 0x05, 0x04, 0x03
1515};
1516
1517static hda_nid_t alc880_adc_nids[3] = {
1518 /* ADC0-2 */
1519 0x07, 0x08, 0x09,
1520};
1521
1522/* The datasheet says the node 0x07 is connected from inputs,
1523 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01001524 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07001525 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001526static hda_nid_t alc880_adc_nids_alt[2] = {
1527 /* ADC1-2 */
1528 0x08, 0x09,
1529};
1530
1531#define ALC880_DIGOUT_NID 0x06
1532#define ALC880_DIGIN_NID 0x0a
1533
1534static struct hda_input_mux alc880_capture_source = {
1535 .num_items = 4,
1536 .items = {
1537 { "Mic", 0x0 },
1538 { "Front Mic", 0x3 },
1539 { "Line", 0x2 },
1540 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001541 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001542};
1543
1544/* channel source setting (2/6 channel selection for 3-stack) */
1545/* 2ch mode */
1546static struct hda_verb alc880_threestack_ch2_init[] = {
1547 /* set line-in to input, mute it */
1548 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1549 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1550 /* set mic-in to input vref 80%, mute it */
1551 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1552 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001553 { } /* end */
1554};
1555
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001556/* 6ch mode */
1557static struct hda_verb alc880_threestack_ch6_init[] = {
1558 /* set line-in to output, unmute it */
1559 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1560 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1561 /* set mic-in to output, unmute it */
1562 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1563 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1564 { } /* end */
1565};
1566
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001567static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001568 { 2, alc880_threestack_ch2_init },
1569 { 6, alc880_threestack_ch6_init },
1570};
1571
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001572static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001573 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001574 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001575 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001576 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001577 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1578 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001579 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1580 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001581 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1582 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1583 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1584 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1585 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1586 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1587 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1588 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001589 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001590 {
1591 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1592 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001593 .info = alc_ch_mode_info,
1594 .get = alc_ch_mode_get,
1595 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001596 },
1597 { } /* end */
1598};
1599
1600/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001601static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1602 struct snd_ctl_elem_info *uinfo)
1603{
1604 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1605 struct alc_spec *spec = codec->spec;
1606 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001607
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001608 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001609 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1610 HDA_INPUT);
1611 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001612 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001613 return err;
1614}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001615
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001616static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1617 unsigned int size, unsigned int __user *tlv)
1618{
1619 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1620 struct alc_spec *spec = codec->spec;
1621 int err;
1622
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001623 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001624 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1625 HDA_INPUT);
1626 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001627 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001628 return err;
1629}
1630
1631typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1632 struct snd_ctl_elem_value *ucontrol);
1633
1634static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1635 struct snd_ctl_elem_value *ucontrol,
1636 getput_call_t func)
1637{
1638 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1639 struct alc_spec *spec = codec->spec;
1640 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1641 int err;
1642
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001643 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001644 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
1645 3, 0, HDA_INPUT);
1646 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001647 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001648 return err;
1649}
1650
1651static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
1652 struct snd_ctl_elem_value *ucontrol)
1653{
1654 return alc_cap_getput_caller(kcontrol, ucontrol,
1655 snd_hda_mixer_amp_volume_get);
1656}
1657
1658static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
1659 struct snd_ctl_elem_value *ucontrol)
1660{
1661 return alc_cap_getput_caller(kcontrol, ucontrol,
1662 snd_hda_mixer_amp_volume_put);
1663}
1664
1665/* capture mixer elements */
1666#define alc_cap_sw_info snd_ctl_boolean_stereo_info
1667
1668static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
1669 struct snd_ctl_elem_value *ucontrol)
1670{
1671 return alc_cap_getput_caller(kcontrol, ucontrol,
1672 snd_hda_mixer_amp_switch_get);
1673}
1674
1675static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
1676 struct snd_ctl_elem_value *ucontrol)
1677{
1678 return alc_cap_getput_caller(kcontrol, ucontrol,
1679 snd_hda_mixer_amp_switch_put);
1680}
1681
Takashi Iwaia23b6882009-03-23 15:21:36 +01001682#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001683 { \
1684 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1685 .name = "Capture Switch", \
1686 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1687 .count = num, \
1688 .info = alc_cap_sw_info, \
1689 .get = alc_cap_sw_get, \
1690 .put = alc_cap_sw_put, \
1691 }, \
1692 { \
1693 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1694 .name = "Capture Volume", \
1695 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1696 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1697 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
1698 .count = num, \
1699 .info = alc_cap_vol_info, \
1700 .get = alc_cap_vol_get, \
1701 .put = alc_cap_vol_put, \
1702 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01001703 }
1704
1705#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01001706 { \
1707 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1708 /* .name = "Capture Source", */ \
1709 .name = "Input Source", \
1710 .count = num, \
1711 .info = alc_mux_enum_info, \
1712 .get = alc_mux_enum_get, \
1713 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01001714 }
1715
1716#define DEFINE_CAPMIX(num) \
1717static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
1718 _DEFINE_CAPMIX(num), \
1719 _DEFINE_CAPSRC(num), \
1720 { } /* end */ \
1721}
1722
1723#define DEFINE_CAPMIX_NOSRC(num) \
1724static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
1725 _DEFINE_CAPMIX(num), \
1726 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001727}
1728
1729/* up to three ADCs */
1730DEFINE_CAPMIX(1);
1731DEFINE_CAPMIX(2);
1732DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01001733DEFINE_CAPMIX_NOSRC(1);
1734DEFINE_CAPMIX_NOSRC(2);
1735DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001736
1737/*
1738 * ALC880 5-stack model
1739 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001740 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
1741 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001742 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
1743 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
1744 */
1745
1746/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001747static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001748 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001749 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001750 { } /* end */
1751};
1752
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001753/* channel source setting (6/8 channel selection for 5-stack) */
1754/* 6ch mode */
1755static struct hda_verb alc880_fivestack_ch6_init[] = {
1756 /* set line-in to input, mute it */
1757 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1758 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001759 { } /* end */
1760};
1761
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001762/* 8ch mode */
1763static struct hda_verb alc880_fivestack_ch8_init[] = {
1764 /* set line-in to output, unmute it */
1765 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1766 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1767 { } /* end */
1768};
1769
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001770static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001771 { 6, alc880_fivestack_ch6_init },
1772 { 8, alc880_fivestack_ch8_init },
1773};
1774
1775
1776/*
1777 * ALC880 6-stack model
1778 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001779 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
1780 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001781 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
1782 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
1783 */
1784
1785static hda_nid_t alc880_6st_dac_nids[4] = {
1786 /* front, rear, clfe, rear_surr */
1787 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001788};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001789
1790static struct hda_input_mux alc880_6stack_capture_source = {
1791 .num_items = 4,
1792 .items = {
1793 { "Mic", 0x0 },
1794 { "Front Mic", 0x1 },
1795 { "Line", 0x2 },
1796 { "CD", 0x4 },
1797 },
1798};
1799
1800/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001801static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001802 { 8, NULL },
1803};
1804
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001805static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001806 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001807 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001808 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001809 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001810 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1811 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001812 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1813 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001814 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001815 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001816 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1817 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1818 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1819 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1820 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1821 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1822 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1823 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001824 {
1825 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1826 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001827 .info = alc_ch_mode_info,
1828 .get = alc_ch_mode_get,
1829 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001830 },
1831 { } /* end */
1832};
1833
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001834
1835/*
1836 * ALC880 W810 model
1837 *
1838 * W810 has rear IO for:
1839 * Front (DAC 02)
1840 * Surround (DAC 03)
1841 * Center/LFE (DAC 04)
1842 * Digital out (06)
1843 *
1844 * The system also has a pair of internal speakers, and a headphone jack.
1845 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02001846 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001847 * There is a variable resistor to control the speaker or headphone
1848 * volume. This is a hardware-only device without a software API.
1849 *
1850 * Plugging headphones in will disable the internal speakers. This is
1851 * implemented in hardware, not via the driver using jack sense. In
1852 * a similar fashion, plugging into the rear socket marked "front" will
1853 * disable both the speakers and headphones.
1854 *
1855 * For input, there's a microphone jack, and an "audio in" jack.
1856 * These may not do anything useful with this driver yet, because I
1857 * haven't setup any initialization verbs for these yet...
1858 */
1859
1860static hda_nid_t alc880_w810_dac_nids[3] = {
1861 /* front, rear/surround, clfe */
1862 0x02, 0x03, 0x04
1863};
1864
1865/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001866static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001867 { 6, NULL }
1868};
1869
1870/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001871static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001872 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001873 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001874 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001875 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001876 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1877 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001878 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1879 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001880 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1881 { } /* end */
1882};
1883
1884
1885/*
1886 * Z710V model
1887 *
1888 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001889 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1890 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001891 */
1892
1893static hda_nid_t alc880_z71v_dac_nids[1] = {
1894 0x02
1895};
1896#define ALC880_Z71V_HP_DAC 0x03
1897
1898/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001899static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001900 { 2, NULL }
1901};
1902
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001903static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001904 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001905 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001906 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001907 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001908 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1909 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1910 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1911 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1912 { } /* end */
1913};
1914
1915
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001916/*
1917 * ALC880 F1734 model
1918 *
1919 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1920 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1921 */
1922
1923static hda_nid_t alc880_f1734_dac_nids[1] = {
1924 0x03
1925};
1926#define ALC880_F1734_HP_DAC 0x02
1927
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001928static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001929 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001930 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01001931 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1932 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001933 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1934 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01001935 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1936 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001937 { } /* end */
1938};
1939
Takashi Iwai937b4162008-02-11 14:52:36 +01001940static struct hda_input_mux alc880_f1734_capture_source = {
1941 .num_items = 2,
1942 .items = {
1943 { "Mic", 0x1 },
1944 { "CD", 0x4 },
1945 },
1946};
1947
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001948
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001949/*
1950 * ALC880 ASUS model
1951 *
1952 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1953 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1954 * Mic = 0x18, Line = 0x1a
1955 */
1956
1957#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1958#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1959
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001960static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001961 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001962 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001963 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001964 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001965 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1966 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001967 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1968 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001969 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1970 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1971 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1972 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1973 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1974 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001975 {
1976 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1977 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001978 .info = alc_ch_mode_info,
1979 .get = alc_ch_mode_get,
1980 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001981 },
1982 { } /* end */
1983};
1984
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001985/*
1986 * ALC880 ASUS W1V model
1987 *
1988 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1989 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1990 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1991 */
1992
1993/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001994static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001995 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1996 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001997 { } /* end */
1998};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001999
Kailang Yangdf694da2005-12-05 19:42:22 +01002000/* TCL S700 */
2001static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2002 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2003 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2004 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2005 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2006 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2007 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2008 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2009 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2010 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002011 { } /* end */
2012};
2013
Kailang Yangccc656c2006-10-17 12:32:26 +02002014/* Uniwill */
2015static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002016 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2017 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2018 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2019 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002020 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2021 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2022 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2023 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2024 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2025 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2026 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2027 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2028 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2029 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2030 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2031 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002032 {
2033 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2034 .name = "Channel Mode",
2035 .info = alc_ch_mode_info,
2036 .get = alc_ch_mode_get,
2037 .put = alc_ch_mode_put,
2038 },
2039 { } /* end */
2040};
2041
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002042static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2043 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2044 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2045 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2046 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2047 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2048 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2049 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2050 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2051 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2052 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2053 { } /* end */
2054};
2055
Kailang Yangccc656c2006-10-17 12:32:26 +02002056static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002057 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2058 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2059 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2060 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002061 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2062 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2063 { } /* end */
2064};
2065
Linus Torvalds1da177e2005-04-16 15:20:36 -07002066/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01002067 * virtual master controls
2068 */
2069
2070/*
2071 * slave controls for virtual master
2072 */
2073static const char *alc_slave_vols[] = {
2074 "Front Playback Volume",
2075 "Surround Playback Volume",
2076 "Center Playback Volume",
2077 "LFE Playback Volume",
2078 "Side Playback Volume",
2079 "Headphone Playback Volume",
2080 "Speaker Playback Volume",
2081 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002082 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01002083 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002084 NULL,
2085};
2086
2087static const char *alc_slave_sws[] = {
2088 "Front Playback Switch",
2089 "Surround Playback Switch",
2090 "Center Playback Switch",
2091 "LFE Playback Switch",
2092 "Side Playback Switch",
2093 "Headphone Playback Switch",
2094 "Speaker Playback Switch",
2095 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01002096 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002097 NULL,
2098};
2099
2100/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002101 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002102 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002103
2104static void alc_free_kctls(struct hda_codec *codec);
2105
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002106/* additional beep mixers; the actual parameters are overwritten at build */
2107static struct snd_kcontrol_new alc_beep_mixer[] = {
2108 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
2109 HDA_CODEC_MUTE("Beep Playback Switch", 0, 0, HDA_INPUT),
2110 { } /* end */
2111};
2112
Linus Torvalds1da177e2005-04-16 15:20:36 -07002113static int alc_build_controls(struct hda_codec *codec)
2114{
2115 struct alc_spec *spec = codec->spec;
2116 int err;
2117 int i;
2118
2119 for (i = 0; i < spec->num_mixers; i++) {
2120 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2121 if (err < 0)
2122 return err;
2123 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002124 if (spec->cap_mixer) {
2125 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2126 if (err < 0)
2127 return err;
2128 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002129 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002130 err = snd_hda_create_spdif_out_ctls(codec,
2131 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002132 if (err < 0)
2133 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002134 if (!spec->no_analog) {
2135 err = snd_hda_create_spdif_share_sw(codec,
2136 &spec->multiout);
2137 if (err < 0)
2138 return err;
2139 spec->multiout.share_spdif = 1;
2140 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002141 }
2142 if (spec->dig_in_nid) {
2143 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2144 if (err < 0)
2145 return err;
2146 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002147
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002148 /* create beep controls if needed */
2149 if (spec->beep_amp) {
2150 struct snd_kcontrol_new *knew;
2151 for (knew = alc_beep_mixer; knew->name; knew++) {
2152 struct snd_kcontrol *kctl;
2153 kctl = snd_ctl_new1(knew, codec);
2154 if (!kctl)
2155 return -ENOMEM;
2156 kctl->private_value = spec->beep_amp;
2157 err = snd_hda_ctl_add(codec, kctl);
2158 if (err < 0)
2159 return err;
2160 }
2161 }
2162
Takashi Iwai2134ea42008-01-10 16:53:55 +01002163 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002164 if (!spec->no_analog &&
2165 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002166 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002167 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002168 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002169 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002170 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002171 if (err < 0)
2172 return err;
2173 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002174 if (!spec->no_analog &&
2175 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002176 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2177 NULL, alc_slave_sws);
2178 if (err < 0)
2179 return err;
2180 }
2181
Takashi Iwai603c4012008-07-30 15:01:44 +02002182 alc_free_kctls(codec); /* no longer needed */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002183 return 0;
2184}
2185
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002186
Linus Torvalds1da177e2005-04-16 15:20:36 -07002187/*
2188 * initialize the codec volumes, etc
2189 */
2190
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002191/*
2192 * generic initialization of ADC, input mixers and output mixers
2193 */
2194static struct hda_verb alc880_volume_init_verbs[] = {
2195 /*
2196 * Unmute ADC0-2 and set the default input to mic-in
2197 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002198 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002199 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002200 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002201 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002202 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002203 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002204
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002205 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2206 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002207 * Note: PASD motherboards uses the Line In 2 as the input for front
2208 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002209 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002210 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02002211 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2212 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2213 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2214 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2215 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2216 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2217 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002218
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002219 /*
2220 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002221 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002222 /* set vol=0 to output mixers */
2223 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2224 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2225 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2226 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2227 /* set up input amps for analog loopback */
2228 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002229 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2230 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002231 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2232 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002233 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2234 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002235 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2236 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002237
2238 { }
2239};
2240
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002241/*
2242 * 3-stack pin configuration:
2243 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2244 */
2245static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2246 /*
2247 * preset connection lists of input pins
2248 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2249 */
2250 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2251 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2252 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2253
2254 /*
2255 * Set pin mode and muting
2256 */
2257 /* set front pin widgets 0x14 for output */
2258 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2259 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2260 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2261 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2262 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2263 /* Mic2 (as headphone out) for HP output */
2264 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2265 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2266 /* Line In pin widget for input */
2267 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2268 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2269 /* Line2 (as front mic) pin widget for input and vref at 80% */
2270 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2271 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2272 /* CD pin widget for input */
2273 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2274
2275 { }
2276};
2277
2278/*
2279 * 5-stack pin configuration:
2280 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2281 * line-in/side = 0x1a, f-mic = 0x1b
2282 */
2283static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2284 /*
2285 * preset connection lists of input pins
2286 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2287 */
2288 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2289 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2290
2291 /*
2292 * Set pin mode and muting
2293 */
2294 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02002295 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2296 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2297 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2298 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002299 /* unmute pins for output (no gain on this amp) */
2300 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2301 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2302 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2303 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2304
Linus Torvalds1da177e2005-04-16 15:20:36 -07002305 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02002306 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002307 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2308 /* Mic2 (as headphone out) for HP output */
2309 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002310 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002311 /* Line In pin widget for input */
2312 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2313 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2314 /* Line2 (as front mic) pin widget for input and vref at 80% */
2315 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2316 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2317 /* CD pin widget for input */
2318 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002319
2320 { }
2321};
2322
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002323/*
2324 * W810 pin configuration:
2325 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2326 */
2327static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002328 /* hphone/speaker input selector: front DAC */
2329 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2330
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002331 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2332 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2333 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2334 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2335 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2336 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2337
2338 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002339 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002340
Linus Torvalds1da177e2005-04-16 15:20:36 -07002341 { }
2342};
2343
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002344/*
2345 * Z71V pin configuration:
2346 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2347 */
2348static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002349 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002350 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02002351 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002352 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002353
Takashi Iwai16ded522005-06-10 19:58:24 +02002354 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002355 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002356 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002357 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002358
2359 { }
2360};
2361
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002362/*
2363 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002364 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2365 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002366 */
2367static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2368 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2369
Takashi Iwai16ded522005-06-10 19:58:24 +02002370 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002371 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002372 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002373 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002374 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002375 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002376 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002377 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2378
Takashi Iwai16ded522005-06-10 19:58:24 +02002379 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002380 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002381 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002382 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002383 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002384 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002385 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02002386 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002387 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002388
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002389 { }
2390};
Takashi Iwai16ded522005-06-10 19:58:24 +02002391
Kailang Yangccc656c2006-10-17 12:32:26 +02002392/*
2393 * Uniwill pin configuration:
2394 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2395 * line = 0x1a
2396 */
2397static struct hda_verb alc880_uniwill_init_verbs[] = {
2398 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2399
2400 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2401 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2402 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2403 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2404 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2405 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2406 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2407 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2408 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2409 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2410 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2411 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2412 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2413 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2414
2415 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2416 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2417 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2418 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2419 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2420 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2421 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2422 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2423 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2424
2425 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2426 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2427
2428 { }
2429};
2430
2431/*
2432* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02002433* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02002434 */
2435static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2436 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2437
2438 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2439 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2440 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2441 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2442 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2443 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2444 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2445 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2446 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2447 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2448 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2449 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2450
2451 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2452 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2453 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2454 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2455 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2456 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2457
2458 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2459 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2460
2461 { }
2462};
2463
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002464static struct hda_verb alc880_beep_init_verbs[] = {
2465 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2466 { }
2467};
2468
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002469/* auto-toggle front mic */
2470static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2471{
2472 unsigned int present;
2473 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002474
2475 present = snd_hda_codec_read(codec, 0x18, 0,
2476 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002477 bits = present ? HDA_AMP_MUTE : 0;
2478 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002479}
2480
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002481static void alc880_uniwill_init_hook(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002482{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002483 struct alc_spec *spec = codec->spec;
2484
2485 spec->autocfg.hp_pins[0] = 0x14;
2486 spec->autocfg.speaker_pins[0] = 0x15;
2487 spec->autocfg.speaker_pins[0] = 0x16;
2488 alc_automute_amp(codec);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002489 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002490}
2491
2492static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2493 unsigned int res)
2494{
2495 /* Looks like the unsol event is incompatible with the standard
2496 * definition. 4bit tag is placed at 28 bit!
2497 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002498 switch (res >> 28) {
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002499 case ALC880_MIC_EVENT:
2500 alc880_uniwill_mic_automute(codec);
2501 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002502 default:
2503 alc_automute_amp_unsol_event(codec, res);
2504 break;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002505 }
Kailang Yangccc656c2006-10-17 12:32:26 +02002506}
2507
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002508static void alc880_uniwill_p53_init_hook(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02002509{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002510 struct alc_spec *spec = codec->spec;
Kailang Yangccc656c2006-10-17 12:32:26 +02002511
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002512 spec->autocfg.hp_pins[0] = 0x14;
2513 spec->autocfg.speaker_pins[0] = 0x15;
2514 alc_automute_amp(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002515}
2516
2517static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2518{
2519 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02002520
Kailang Yangccc656c2006-10-17 12:32:26 +02002521 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02002522 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2523 present &= HDA_AMP_VOLMASK;
2524 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2525 HDA_AMP_VOLMASK, present);
2526 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2527 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02002528}
Takashi Iwai47fd8302007-08-10 17:11:07 +02002529
Kailang Yangccc656c2006-10-17 12:32:26 +02002530static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2531 unsigned int res)
2532{
2533 /* Looks like the unsol event is incompatible with the standard
2534 * definition. 4bit tag is placed at 28 bit!
2535 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002536 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02002537 alc880_uniwill_p53_dcvol_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002538 else
2539 alc_automute_amp_unsol_event(codec, res);
Kailang Yangccc656c2006-10-17 12:32:26 +02002540}
2541
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002542/*
2543 * F1734 pin configuration:
2544 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2545 */
2546static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01002547 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002548 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2549 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2550 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2551 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2552
2553 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2554 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2555 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2556 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2557
2558 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2559 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01002560 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002561 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2562 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2563 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2564 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2565 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2566 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002567
Takashi Iwai937b4162008-02-11 14:52:36 +01002568 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2569 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2570
Takashi Iwai16ded522005-06-10 19:58:24 +02002571 { }
2572};
2573
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002574/*
2575 * ASUS pin configuration:
2576 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2577 */
2578static struct hda_verb alc880_pin_asus_init_verbs[] = {
2579 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2580 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2581 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2582 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2583
2584 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2585 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2586 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2587 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2588 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2589 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2590 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2591 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2592
2593 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2594 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2595 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2596 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2597 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2598 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2599 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2600 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2601 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002602
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002603 { }
2604};
2605
2606/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02002607#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2608#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002609
Kailang Yangdf694da2005-12-05 19:42:22 +01002610/* Clevo m520g init */
2611static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2612 /* headphone output */
2613 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2614 /* line-out */
2615 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2616 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2617 /* Line-in */
2618 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2619 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2620 /* CD */
2621 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2622 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2623 /* Mic1 (rear panel) */
2624 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2625 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2626 /* Mic2 (front panel) */
2627 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2628 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2629 /* headphone */
2630 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2631 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2632 /* change to EAPD mode */
2633 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2634 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2635
2636 { }
2637};
2638
2639static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002640 /* change to EAPD mode */
2641 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2642 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2643
Kailang Yangdf694da2005-12-05 19:42:22 +01002644 /* Headphone output */
2645 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2646 /* Front output*/
2647 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2648 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2649
2650 /* Line In pin widget for input */
2651 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2652 /* CD pin widget for input */
2653 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2654 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2655 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2656
2657 /* change to EAPD mode */
2658 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2659 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2660
2661 { }
2662};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002663
2664/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002665 * LG m1 express dual
2666 *
2667 * Pin assignment:
2668 * Rear Line-In/Out (blue): 0x14
2669 * Build-in Mic-In: 0x15
2670 * Speaker-out: 0x17
2671 * HP-Out (green): 0x1b
2672 * Mic-In/Out (red): 0x19
2673 * SPDIF-Out: 0x1e
2674 */
2675
2676/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2677static hda_nid_t alc880_lg_dac_nids[3] = {
2678 0x05, 0x02, 0x03
2679};
2680
2681/* seems analog CD is not working */
2682static struct hda_input_mux alc880_lg_capture_source = {
2683 .num_items = 3,
2684 .items = {
2685 { "Mic", 0x1 },
2686 { "Line", 0x5 },
2687 { "Internal Mic", 0x6 },
2688 },
2689};
2690
2691/* 2,4,6 channel modes */
2692static struct hda_verb alc880_lg_ch2_init[] = {
2693 /* set line-in and mic-in to input */
2694 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2695 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2696 { }
2697};
2698
2699static struct hda_verb alc880_lg_ch4_init[] = {
2700 /* set line-in to out and mic-in to input */
2701 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2702 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2703 { }
2704};
2705
2706static struct hda_verb alc880_lg_ch6_init[] = {
2707 /* set line-in and mic-in to output */
2708 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2709 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2710 { }
2711};
2712
2713static struct hda_channel_mode alc880_lg_ch_modes[3] = {
2714 { 2, alc880_lg_ch2_init },
2715 { 4, alc880_lg_ch4_init },
2716 { 6, alc880_lg_ch6_init },
2717};
2718
2719static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002720 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2721 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002722 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2723 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
2724 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
2725 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
2726 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
2727 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
2728 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2729 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2730 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
2731 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
2732 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
2733 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
2734 {
2735 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2736 .name = "Channel Mode",
2737 .info = alc_ch_mode_info,
2738 .get = alc_ch_mode_get,
2739 .put = alc_ch_mode_put,
2740 },
2741 { } /* end */
2742};
2743
2744static struct hda_verb alc880_lg_init_verbs[] = {
2745 /* set capture source to mic-in */
2746 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2747 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2748 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2749 /* mute all amp mixer inputs */
2750 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002751 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2752 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002753 /* line-in to input */
2754 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2755 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2756 /* built-in mic */
2757 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2758 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2759 /* speaker-out */
2760 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2761 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2762 /* mic-in to input */
2763 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2764 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2765 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2766 /* HP-out */
2767 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
2768 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2769 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2770 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002771 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002772 { }
2773};
2774
2775/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002776static void alc880_lg_init_hook(struct hda_codec *codec)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002777{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002778 struct alc_spec *spec = codec->spec;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002779
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002780 spec->autocfg.hp_pins[0] = 0x1b;
2781 spec->autocfg.speaker_pins[0] = 0x17;
2782 alc_automute_amp(codec);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002783}
2784
2785/*
Takashi Iwaid6815182006-03-23 16:06:23 +01002786 * LG LW20
2787 *
2788 * Pin assignment:
2789 * Speaker-out: 0x14
2790 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002791 * Built-in Mic-In: 0x19
2792 * Line-In: 0x1b
2793 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01002794 * SPDIF-Out: 0x1e
2795 */
2796
Takashi Iwaid6815182006-03-23 16:06:23 +01002797static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002798 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01002799 .items = {
2800 { "Mic", 0x0 },
2801 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002802 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002803 },
2804};
2805
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002806#define alc880_lg_lw_modes alc880_threestack_modes
2807
Takashi Iwaid6815182006-03-23 16:06:23 +01002808static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002809 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2810 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2811 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2812 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2813 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2814 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2815 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2816 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2817 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2818 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01002819 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2820 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2821 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
2822 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002823 {
2824 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2825 .name = "Channel Mode",
2826 .info = alc_ch_mode_info,
2827 .get = alc_ch_mode_get,
2828 .put = alc_ch_mode_put,
2829 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002830 { } /* end */
2831};
2832
2833static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002834 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2835 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2836 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2837
Takashi Iwaid6815182006-03-23 16:06:23 +01002838 /* set capture source to mic-in */
2839 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2840 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2841 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002842 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01002843 /* speaker-out */
2844 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2845 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2846 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01002847 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2848 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2849 /* mic-in to input */
2850 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2851 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2852 /* built-in mic */
2853 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2854 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2855 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002856 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaid6815182006-03-23 16:06:23 +01002857 { }
2858};
2859
2860/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002861static void alc880_lg_lw_init_hook(struct hda_codec *codec)
Takashi Iwaid6815182006-03-23 16:06:23 +01002862{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002863 struct alc_spec *spec = codec->spec;
Takashi Iwaid6815182006-03-23 16:06:23 +01002864
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002865 spec->autocfg.hp_pins[0] = 0x1b;
2866 spec->autocfg.speaker_pins[0] = 0x14;
2867 alc_automute_amp(codec);
Takashi Iwaid6815182006-03-23 16:06:23 +01002868}
2869
Takashi Iwaidf99cd32008-04-25 15:25:04 +02002870static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
2871 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2872 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
2873 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2874 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2875 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2876 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
2877 { } /* end */
2878};
2879
2880static struct hda_input_mux alc880_medion_rim_capture_source = {
2881 .num_items = 2,
2882 .items = {
2883 { "Mic", 0x0 },
2884 { "Internal Mic", 0x1 },
2885 },
2886};
2887
2888static struct hda_verb alc880_medion_rim_init_verbs[] = {
2889 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2890
2891 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2892 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2893
2894 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2895 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2896 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2897 /* Mic2 (as headphone out) for HP output */
2898 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2899 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2900 /* Internal Speaker */
2901 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2902 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2903
2904 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2905 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2906
2907 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2908 { }
2909};
2910
2911/* toggle speaker-output according to the hp-jack state */
2912static void alc880_medion_rim_automute(struct hda_codec *codec)
2913{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002914 struct alc_spec *spec = codec->spec;
2915 alc_automute_amp(codec);
2916 /* toggle EAPD */
2917 if (spec->jack_present)
Takashi Iwaidf99cd32008-04-25 15:25:04 +02002918 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
2919 else
2920 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
2921}
2922
2923static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
2924 unsigned int res)
2925{
2926 /* Looks like the unsol event is incompatible with the standard
2927 * definition. 4bit tag is placed at 28 bit!
2928 */
2929 if ((res >> 28) == ALC880_HP_EVENT)
2930 alc880_medion_rim_automute(codec);
2931}
2932
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002933static void alc880_medion_rim_init_hook(struct hda_codec *codec)
2934{
2935 struct alc_spec *spec = codec->spec;
2936
2937 spec->autocfg.hp_pins[0] = 0x14;
2938 spec->autocfg.speaker_pins[0] = 0x1b;
2939 alc880_medion_rim_automute(codec);
2940}
2941
Takashi Iwaicb53c622007-08-10 17:21:45 +02002942#ifdef CONFIG_SND_HDA_POWER_SAVE
2943static struct hda_amp_list alc880_loopbacks[] = {
2944 { 0x0b, HDA_INPUT, 0 },
2945 { 0x0b, HDA_INPUT, 1 },
2946 { 0x0b, HDA_INPUT, 2 },
2947 { 0x0b, HDA_INPUT, 3 },
2948 { 0x0b, HDA_INPUT, 4 },
2949 { } /* end */
2950};
2951
2952static struct hda_amp_list alc880_lg_loopbacks[] = {
2953 { 0x0b, HDA_INPUT, 1 },
2954 { 0x0b, HDA_INPUT, 6 },
2955 { 0x0b, HDA_INPUT, 7 },
2956 { } /* end */
2957};
2958#endif
2959
Takashi Iwaid6815182006-03-23 16:06:23 +01002960/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002961 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002962 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002963
Linus Torvalds1da177e2005-04-16 15:20:36 -07002964static int alc_init(struct hda_codec *codec)
2965{
2966 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002967 unsigned int i;
2968
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02002969 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02002970 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02002971
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002972 for (i = 0; i < spec->num_init_verbs; i++)
2973 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002974
2975 if (spec->init_hook)
2976 spec->init_hook(codec);
2977
Linus Torvalds1da177e2005-04-16 15:20:36 -07002978 return 0;
2979}
2980
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002981static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2982{
2983 struct alc_spec *spec = codec->spec;
2984
2985 if (spec->unsol_event)
2986 spec->unsol_event(codec, res);
2987}
2988
Takashi Iwaicb53c622007-08-10 17:21:45 +02002989#ifdef CONFIG_SND_HDA_POWER_SAVE
2990static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
2991{
2992 struct alc_spec *spec = codec->spec;
2993 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
2994}
2995#endif
2996
Linus Torvalds1da177e2005-04-16 15:20:36 -07002997/*
2998 * Analog playback callbacks
2999 */
3000static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3001 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003002 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003003{
3004 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01003005 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3006 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003007}
3008
3009static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3010 struct hda_codec *codec,
3011 unsigned int stream_tag,
3012 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003013 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003014{
3015 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003016 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3017 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003018}
3019
3020static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3021 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003022 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003023{
3024 struct alc_spec *spec = codec->spec;
3025 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3026}
3027
3028/*
3029 * Digital out
3030 */
3031static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3032 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003033 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003034{
3035 struct alc_spec *spec = codec->spec;
3036 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3037}
3038
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003039static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3040 struct hda_codec *codec,
3041 unsigned int stream_tag,
3042 unsigned int format,
3043 struct snd_pcm_substream *substream)
3044{
3045 struct alc_spec *spec = codec->spec;
3046 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3047 stream_tag, format, substream);
3048}
3049
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003050static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3051 struct hda_codec *codec,
3052 struct snd_pcm_substream *substream)
3053{
3054 struct alc_spec *spec = codec->spec;
3055 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3056}
3057
Linus Torvalds1da177e2005-04-16 15:20:36 -07003058static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3059 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003060 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003061{
3062 struct alc_spec *spec = codec->spec;
3063 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3064}
3065
3066/*
3067 * Analog capture
3068 */
Takashi Iwai63300792008-01-24 15:31:36 +01003069static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003070 struct hda_codec *codec,
3071 unsigned int stream_tag,
3072 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003073 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003074{
3075 struct alc_spec *spec = codec->spec;
3076
Takashi Iwai63300792008-01-24 15:31:36 +01003077 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07003078 stream_tag, 0, format);
3079 return 0;
3080}
3081
Takashi Iwai63300792008-01-24 15:31:36 +01003082static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003083 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003084 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003085{
3086 struct alc_spec *spec = codec->spec;
3087
Takashi Iwai888afa12008-03-18 09:57:50 +01003088 snd_hda_codec_cleanup_stream(codec,
3089 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003090 return 0;
3091}
3092
3093
3094/*
3095 */
3096static struct hda_pcm_stream alc880_pcm_analog_playback = {
3097 .substreams = 1,
3098 .channels_min = 2,
3099 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003100 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003101 .ops = {
3102 .open = alc880_playback_pcm_open,
3103 .prepare = alc880_playback_pcm_prepare,
3104 .cleanup = alc880_playback_pcm_cleanup
3105 },
3106};
3107
3108static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01003109 .substreams = 1,
3110 .channels_min = 2,
3111 .channels_max = 2,
3112 /* NID is set in alc_build_pcms */
3113};
3114
3115static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3116 .substreams = 1,
3117 .channels_min = 2,
3118 .channels_max = 2,
3119 /* NID is set in alc_build_pcms */
3120};
3121
3122static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3123 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003124 .channels_min = 2,
3125 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003126 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003127 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01003128 .prepare = alc880_alt_capture_pcm_prepare,
3129 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003130 },
3131};
3132
3133static struct hda_pcm_stream alc880_pcm_digital_playback = {
3134 .substreams = 1,
3135 .channels_min = 2,
3136 .channels_max = 2,
3137 /* NID is set in alc_build_pcms */
3138 .ops = {
3139 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003140 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003141 .prepare = alc880_dig_playback_pcm_prepare,
3142 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003143 },
3144};
3145
3146static struct hda_pcm_stream alc880_pcm_digital_capture = {
3147 .substreams = 1,
3148 .channels_min = 2,
3149 .channels_max = 2,
3150 /* NID is set in alc_build_pcms */
3151};
3152
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003153/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01003154static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003155 .substreams = 0,
3156 .channels_min = 0,
3157 .channels_max = 0,
3158};
3159
Linus Torvalds1da177e2005-04-16 15:20:36 -07003160static int alc_build_pcms(struct hda_codec *codec)
3161{
3162 struct alc_spec *spec = codec->spec;
3163 struct hda_pcm *info = spec->pcm_rec;
3164 int i;
3165
3166 codec->num_pcms = 1;
3167 codec->pcm_info = info;
3168
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003169 if (spec->no_analog)
3170 goto skip_analog;
3171
Linus Torvalds1da177e2005-04-16 15:20:36 -07003172 info->name = spec->stream_name_analog;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003173 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003174 if (snd_BUG_ON(!spec->multiout.dac_nids))
3175 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003176 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3177 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3178 }
3179 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003180 if (snd_BUG_ON(!spec->adc_nids))
3181 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003182 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3183 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3184 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003185
Takashi Iwai4a471b72005-12-07 13:56:29 +01003186 if (spec->channel_mode) {
3187 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3188 for (i = 0; i < spec->num_channel_mode; i++) {
3189 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3190 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3191 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003192 }
3193 }
3194
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003195 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02003196 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003197 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003198 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08003199 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003200 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003201 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01003202 if (spec->dig_out_type)
3203 info->pcm_type = spec->dig_out_type;
3204 else
3205 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003206 if (spec->multiout.dig_out_nid &&
3207 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003208 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
3209 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3210 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01003211 if (spec->dig_in_nid &&
3212 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003213 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
3214 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3215 }
Takashi Iwai963f8032008-08-11 10:04:40 +02003216 /* FIXME: do we need this for all Realtek codec models? */
3217 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003218 }
3219
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003220 if (spec->no_analog)
3221 return 0;
3222
Takashi Iwaie08a0072006-09-07 17:52:14 +02003223 /* If the use of more than one ADC is requested for the current
3224 * model, configure a second analog capture-only PCM.
3225 */
3226 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01003227 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
3228 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003229 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003230 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003231 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01003232 if (spec->alt_dac_nid) {
3233 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3234 *spec->stream_analog_alt_playback;
3235 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3236 spec->alt_dac_nid;
3237 } else {
3238 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3239 alc_pcm_null_stream;
3240 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
3241 }
3242 if (spec->num_adc_nids > 1) {
3243 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3244 *spec->stream_analog_alt_capture;
3245 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
3246 spec->adc_nids[1];
3247 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
3248 spec->num_adc_nids - 1;
3249 } else {
3250 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3251 alc_pcm_null_stream;
3252 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003253 }
3254 }
3255
Linus Torvalds1da177e2005-04-16 15:20:36 -07003256 return 0;
3257}
3258
Takashi Iwai603c4012008-07-30 15:01:44 +02003259static void alc_free_kctls(struct hda_codec *codec)
3260{
3261 struct alc_spec *spec = codec->spec;
3262
3263 if (spec->kctls.list) {
3264 struct snd_kcontrol_new *kctl = spec->kctls.list;
3265 int i;
3266 for (i = 0; i < spec->kctls.used; i++)
3267 kfree(kctl[i].name);
3268 }
3269 snd_array_free(&spec->kctls);
3270}
3271
Linus Torvalds1da177e2005-04-16 15:20:36 -07003272static void alc_free(struct hda_codec *codec)
3273{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003274 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003275
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003276 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003277 return;
3278
Takashi Iwai603c4012008-07-30 15:01:44 +02003279 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003280 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09003281 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003282}
3283
Takashi Iwaie044c392008-10-27 16:56:24 +01003284#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01003285static int alc_resume(struct hda_codec *codec)
3286{
Takashi Iwaie044c392008-10-27 16:56:24 +01003287 codec->patch_ops.init(codec);
3288 snd_hda_codec_resume_amp(codec);
3289 snd_hda_codec_resume_cache(codec);
3290 return 0;
3291}
Takashi Iwaie044c392008-10-27 16:56:24 +01003292#endif
3293
Linus Torvalds1da177e2005-04-16 15:20:36 -07003294/*
3295 */
3296static struct hda_codec_ops alc_patch_ops = {
3297 .build_controls = alc_build_controls,
3298 .build_pcms = alc_build_pcms,
3299 .init = alc_init,
3300 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003301 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01003302#ifdef SND_HDA_NEEDS_RESUME
3303 .resume = alc_resume,
3304#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02003305#ifdef CONFIG_SND_HDA_POWER_SAVE
3306 .check_power_status = alc_check_power_status,
3307#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003308};
3309
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003310
3311/*
3312 * Test configuration for debugging
3313 *
3314 * Almost all inputs/outputs are enabled. I/O pins can be configured via
3315 * enum controls.
3316 */
3317#ifdef CONFIG_SND_DEBUG
3318static hda_nid_t alc880_test_dac_nids[4] = {
3319 0x02, 0x03, 0x04, 0x05
3320};
3321
3322static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003323 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003324 .items = {
3325 { "In-1", 0x0 },
3326 { "In-2", 0x1 },
3327 { "In-3", 0x2 },
3328 { "In-4", 0x3 },
3329 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003330 { "Front", 0x5 },
3331 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003332 },
3333};
3334
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003335static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003336 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003337 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003338 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003339 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003340};
3341
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003342static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
3343 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003344{
3345 static char *texts[] = {
3346 "N/A", "Line Out", "HP Out",
3347 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
3348 };
3349 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3350 uinfo->count = 1;
3351 uinfo->value.enumerated.items = 8;
3352 if (uinfo->value.enumerated.item >= 8)
3353 uinfo->value.enumerated.item = 7;
3354 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3355 return 0;
3356}
3357
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003358static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
3359 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003360{
3361 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3362 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3363 unsigned int pin_ctl, item = 0;
3364
3365 pin_ctl = snd_hda_codec_read(codec, nid, 0,
3366 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3367 if (pin_ctl & AC_PINCTL_OUT_EN) {
3368 if (pin_ctl & AC_PINCTL_HP_EN)
3369 item = 2;
3370 else
3371 item = 1;
3372 } else if (pin_ctl & AC_PINCTL_IN_EN) {
3373 switch (pin_ctl & AC_PINCTL_VREFEN) {
3374 case AC_PINCTL_VREF_HIZ: item = 3; break;
3375 case AC_PINCTL_VREF_50: item = 4; break;
3376 case AC_PINCTL_VREF_GRD: item = 5; break;
3377 case AC_PINCTL_VREF_80: item = 6; break;
3378 case AC_PINCTL_VREF_100: item = 7; break;
3379 }
3380 }
3381 ucontrol->value.enumerated.item[0] = item;
3382 return 0;
3383}
3384
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003385static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
3386 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003387{
3388 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3389 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3390 static unsigned int ctls[] = {
3391 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
3392 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
3393 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
3394 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
3395 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
3396 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
3397 };
3398 unsigned int old_ctl, new_ctl;
3399
3400 old_ctl = snd_hda_codec_read(codec, nid, 0,
3401 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3402 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
3403 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003404 int val;
3405 snd_hda_codec_write_cache(codec, nid, 0,
3406 AC_VERB_SET_PIN_WIDGET_CONTROL,
3407 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003408 val = ucontrol->value.enumerated.item[0] >= 3 ?
3409 HDA_AMP_MUTE : 0;
3410 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3411 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003412 return 1;
3413 }
3414 return 0;
3415}
3416
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003417static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
3418 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003419{
3420 static char *texts[] = {
3421 "Front", "Surround", "CLFE", "Side"
3422 };
3423 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3424 uinfo->count = 1;
3425 uinfo->value.enumerated.items = 4;
3426 if (uinfo->value.enumerated.item >= 4)
3427 uinfo->value.enumerated.item = 3;
3428 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3429 return 0;
3430}
3431
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003432static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
3433 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003434{
3435 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3436 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3437 unsigned int sel;
3438
3439 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
3440 ucontrol->value.enumerated.item[0] = sel & 3;
3441 return 0;
3442}
3443
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003444static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
3445 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003446{
3447 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3448 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3449 unsigned int sel;
3450
3451 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
3452 if (ucontrol->value.enumerated.item[0] != sel) {
3453 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003454 snd_hda_codec_write_cache(codec, nid, 0,
3455 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003456 return 1;
3457 }
3458 return 0;
3459}
3460
3461#define PIN_CTL_TEST(xname,nid) { \
3462 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3463 .name = xname, \
3464 .info = alc_test_pin_ctl_info, \
3465 .get = alc_test_pin_ctl_get, \
3466 .put = alc_test_pin_ctl_put, \
3467 .private_value = nid \
3468 }
3469
3470#define PIN_SRC_TEST(xname,nid) { \
3471 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3472 .name = xname, \
3473 .info = alc_test_pin_src_info, \
3474 .get = alc_test_pin_src_get, \
3475 .put = alc_test_pin_src_put, \
3476 .private_value = nid \
3477 }
3478
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003479static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003480 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3481 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3482 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
3483 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003484 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3485 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
3486 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
3487 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003488 PIN_CTL_TEST("Front Pin Mode", 0x14),
3489 PIN_CTL_TEST("Surround Pin Mode", 0x15),
3490 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
3491 PIN_CTL_TEST("Side Pin Mode", 0x17),
3492 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
3493 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
3494 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
3495 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
3496 PIN_SRC_TEST("In-1 Pin Source", 0x18),
3497 PIN_SRC_TEST("In-2 Pin Source", 0x19),
3498 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
3499 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
3500 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
3501 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
3502 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
3503 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
3504 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
3505 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
3506 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
3507 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
3508 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
3509 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003510 {
3511 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3512 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01003513 .info = alc_ch_mode_info,
3514 .get = alc_ch_mode_get,
3515 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003516 },
3517 { } /* end */
3518};
3519
3520static struct hda_verb alc880_test_init_verbs[] = {
3521 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003522 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3523 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3524 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3525 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3526 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3527 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3528 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3529 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003530 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003531 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3532 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3533 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3534 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003535 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003536 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3537 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3538 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3539 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003540 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003541 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3542 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3543 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3544 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003545 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02003546 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3547 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02003548 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3549 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3550 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003551 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02003552 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3553 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3554 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3555 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003556 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02003557 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003558 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003559 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003560 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003561 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003562 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003563 /* Analog input/passthru */
3564 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3565 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3566 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3567 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3568 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003569 { }
3570};
3571#endif
3572
Linus Torvalds1da177e2005-04-16 15:20:36 -07003573/*
3574 */
3575
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003576static const char *alc880_models[ALC880_MODEL_LAST] = {
3577 [ALC880_3ST] = "3stack",
3578 [ALC880_TCL_S700] = "tcl",
3579 [ALC880_3ST_DIG] = "3stack-digout",
3580 [ALC880_CLEVO] = "clevo",
3581 [ALC880_5ST] = "5stack",
3582 [ALC880_5ST_DIG] = "5stack-digout",
3583 [ALC880_W810] = "w810",
3584 [ALC880_Z71V] = "z71v",
3585 [ALC880_6ST] = "6stack",
3586 [ALC880_6ST_DIG] = "6stack-digout",
3587 [ALC880_ASUS] = "asus",
3588 [ALC880_ASUS_W1V] = "asus-w1v",
3589 [ALC880_ASUS_DIG] = "asus-dig",
3590 [ALC880_ASUS_DIG2] = "asus-dig2",
3591 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003592 [ALC880_UNIWILL_P53] = "uniwill-p53",
3593 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003594 [ALC880_F1734] = "F1734",
3595 [ALC880_LG] = "lg",
3596 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003597 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003598#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003599 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003600#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003601 [ALC880_AUTO] = "auto",
3602};
3603
3604static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003605 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003606 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
3607 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
3608 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
3609 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
3610 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
3611 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
3612 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
3613 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003614 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
3615 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003616 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
3617 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
3618 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
3619 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
3620 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
3621 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
3622 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
3623 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
3624 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
3625 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02003626 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003627 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
3628 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
3629 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01003630 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003631 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003632 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
3633 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003634 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
3635 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003636 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
3637 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
3638 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
3639 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003640 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
3641 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003642 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003643 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003644 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003645 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003646 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
3647 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003648 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003649 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003650 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003651 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003652 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02003653 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003654 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003655 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003656 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003657 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
3658 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003659 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003660 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
3661 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
3662 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
3663 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003664 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
3665 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003666 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003667 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003668 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
3669 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003670 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
3671 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
3672 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01003673 /* default Intel */
3674 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003675 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
3676 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003677 {}
3678};
3679
Takashi Iwai16ded522005-06-10 19:58:24 +02003680/*
Kailang Yangdf694da2005-12-05 19:42:22 +01003681 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02003682 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003683static struct alc_config_preset alc880_presets[] = {
3684 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003685 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003686 .init_verbs = { alc880_volume_init_verbs,
3687 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003688 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003689 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003690 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3691 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003692 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003693 .input_mux = &alc880_capture_source,
3694 },
3695 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003696 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003697 .init_verbs = { alc880_volume_init_verbs,
3698 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003699 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003700 .dac_nids = alc880_dac_nids,
3701 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003702 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3703 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003704 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003705 .input_mux = &alc880_capture_source,
3706 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003707 [ALC880_TCL_S700] = {
3708 .mixers = { alc880_tcl_s700_mixer },
3709 .init_verbs = { alc880_volume_init_verbs,
3710 alc880_pin_tcl_S700_init_verbs,
3711 alc880_gpio2_init_verbs },
3712 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3713 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01003714 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
3715 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01003716 .hp_nid = 0x03,
3717 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3718 .channel_mode = alc880_2_jack_modes,
3719 .input_mux = &alc880_capture_source,
3720 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003721 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003722 .mixers = { alc880_three_stack_mixer,
3723 alc880_five_stack_mixer},
3724 .init_verbs = { alc880_volume_init_verbs,
3725 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003726 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3727 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003728 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3729 .channel_mode = alc880_fivestack_modes,
3730 .input_mux = &alc880_capture_source,
3731 },
3732 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003733 .mixers = { alc880_three_stack_mixer,
3734 alc880_five_stack_mixer },
3735 .init_verbs = { alc880_volume_init_verbs,
3736 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003737 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3738 .dac_nids = alc880_dac_nids,
3739 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003740 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3741 .channel_mode = alc880_fivestack_modes,
3742 .input_mux = &alc880_capture_source,
3743 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003744 [ALC880_6ST] = {
3745 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003746 .init_verbs = { alc880_volume_init_verbs,
3747 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003748 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3749 .dac_nids = alc880_6st_dac_nids,
3750 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3751 .channel_mode = alc880_sixstack_modes,
3752 .input_mux = &alc880_6stack_capture_source,
3753 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003754 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003755 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003756 .init_verbs = { alc880_volume_init_verbs,
3757 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003758 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3759 .dac_nids = alc880_6st_dac_nids,
3760 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003761 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3762 .channel_mode = alc880_sixstack_modes,
3763 .input_mux = &alc880_6stack_capture_source,
3764 },
3765 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003766 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003767 .init_verbs = { alc880_volume_init_verbs,
3768 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003769 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003770 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
3771 .dac_nids = alc880_w810_dac_nids,
3772 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003773 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3774 .channel_mode = alc880_w810_modes,
3775 .input_mux = &alc880_capture_source,
3776 },
3777 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003778 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003779 .init_verbs = { alc880_volume_init_verbs,
3780 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003781 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
3782 .dac_nids = alc880_z71v_dac_nids,
3783 .dig_out_nid = ALC880_DIGOUT_NID,
3784 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003785 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3786 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02003787 .input_mux = &alc880_capture_source,
3788 },
3789 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003790 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003791 .init_verbs = { alc880_volume_init_verbs,
3792 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003793 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
3794 .dac_nids = alc880_f1734_dac_nids,
3795 .hp_nid = 0x02,
3796 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3797 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01003798 .input_mux = &alc880_f1734_capture_source,
3799 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003800 .init_hook = alc880_uniwill_p53_init_hook,
Takashi Iwai16ded522005-06-10 19:58:24 +02003801 },
3802 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003803 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003804 .init_verbs = { alc880_volume_init_verbs,
3805 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003806 alc880_gpio1_init_verbs },
3807 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3808 .dac_nids = alc880_asus_dac_nids,
3809 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3810 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003811 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003812 .input_mux = &alc880_capture_source,
3813 },
3814 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003815 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003816 .init_verbs = { alc880_volume_init_verbs,
3817 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003818 alc880_gpio1_init_verbs },
3819 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3820 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003821 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003822 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3823 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003824 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003825 .input_mux = &alc880_capture_source,
3826 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003827 [ALC880_ASUS_DIG2] = {
3828 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003829 .init_verbs = { alc880_volume_init_verbs,
3830 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01003831 alc880_gpio2_init_verbs }, /* use GPIO2 */
3832 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3833 .dac_nids = alc880_asus_dac_nids,
3834 .dig_out_nid = ALC880_DIGOUT_NID,
3835 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3836 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003837 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003838 .input_mux = &alc880_capture_source,
3839 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003840 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003841 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003842 .init_verbs = { alc880_volume_init_verbs,
3843 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003844 alc880_gpio1_init_verbs },
3845 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3846 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003847 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003848 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3849 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003850 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003851 .input_mux = &alc880_capture_source,
3852 },
3853 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01003854 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02003855 .init_verbs = { alc880_volume_init_verbs,
3856 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003857 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3858 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003859 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003860 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3861 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003862 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003863 .input_mux = &alc880_capture_source,
3864 },
Kailang Yangccc656c2006-10-17 12:32:26 +02003865 [ALC880_UNIWILL] = {
3866 .mixers = { alc880_uniwill_mixer },
3867 .init_verbs = { alc880_volume_init_verbs,
3868 alc880_uniwill_init_verbs },
3869 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3870 .dac_nids = alc880_asus_dac_nids,
3871 .dig_out_nid = ALC880_DIGOUT_NID,
3872 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3873 .channel_mode = alc880_threestack_modes,
3874 .need_dac_fix = 1,
3875 .input_mux = &alc880_capture_source,
3876 .unsol_event = alc880_uniwill_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003877 .init_hook = alc880_uniwill_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02003878 },
3879 [ALC880_UNIWILL_P53] = {
3880 .mixers = { alc880_uniwill_p53_mixer },
3881 .init_verbs = { alc880_volume_init_verbs,
3882 alc880_uniwill_p53_init_verbs },
3883 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3884 .dac_nids = alc880_asus_dac_nids,
3885 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003886 .channel_mode = alc880_threestack_modes,
3887 .input_mux = &alc880_capture_source,
3888 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003889 .init_hook = alc880_uniwill_p53_init_hook,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003890 },
3891 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01003892 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003893 .init_verbs = { alc880_volume_init_verbs,
3894 alc880_uniwill_p53_init_verbs,
3895 alc880_beep_init_verbs },
3896 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3897 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02003898 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003899 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3900 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02003901 .input_mux = &alc880_capture_source,
3902 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003903 .init_hook = alc880_uniwill_p53_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02003904 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003905 [ALC880_CLEVO] = {
3906 .mixers = { alc880_three_stack_mixer },
3907 .init_verbs = { alc880_volume_init_verbs,
3908 alc880_pin_clevo_init_verbs },
3909 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3910 .dac_nids = alc880_dac_nids,
3911 .hp_nid = 0x03,
3912 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3913 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003914 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003915 .input_mux = &alc880_capture_source,
3916 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003917 [ALC880_LG] = {
3918 .mixers = { alc880_lg_mixer },
3919 .init_verbs = { alc880_volume_init_verbs,
3920 alc880_lg_init_verbs },
3921 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
3922 .dac_nids = alc880_lg_dac_nids,
3923 .dig_out_nid = ALC880_DIGOUT_NID,
3924 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
3925 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003926 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003927 .input_mux = &alc880_lg_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003928 .unsol_event = alc_automute_amp_unsol_event,
3929 .init_hook = alc880_lg_init_hook,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003930#ifdef CONFIG_SND_HDA_POWER_SAVE
3931 .loopbacks = alc880_lg_loopbacks,
3932#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003933 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003934 [ALC880_LG_LW] = {
3935 .mixers = { alc880_lg_lw_mixer },
3936 .init_verbs = { alc880_volume_init_verbs,
3937 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003938 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01003939 .dac_nids = alc880_dac_nids,
3940 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003941 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
3942 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01003943 .input_mux = &alc880_lg_lw_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003944 .unsol_event = alc_automute_amp_unsol_event,
3945 .init_hook = alc880_lg_lw_init_hook,
Takashi Iwaid6815182006-03-23 16:06:23 +01003946 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003947 [ALC880_MEDION_RIM] = {
3948 .mixers = { alc880_medion_rim_mixer },
3949 .init_verbs = { alc880_volume_init_verbs,
3950 alc880_medion_rim_init_verbs,
3951 alc_gpio2_init_verbs },
3952 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3953 .dac_nids = alc880_dac_nids,
3954 .dig_out_nid = ALC880_DIGOUT_NID,
3955 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3956 .channel_mode = alc880_2_jack_modes,
3957 .input_mux = &alc880_medion_rim_capture_source,
3958 .unsol_event = alc880_medion_rim_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003959 .init_hook = alc880_medion_rim_init_hook,
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003960 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003961#ifdef CONFIG_SND_DEBUG
3962 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003963 .mixers = { alc880_test_mixer },
3964 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003965 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
3966 .dac_nids = alc880_test_dac_nids,
3967 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003968 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
3969 .channel_mode = alc880_test_modes,
3970 .input_mux = &alc880_test_capture_source,
3971 },
3972#endif
3973};
3974
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003975/*
3976 * Automatic parse of I/O pins from the BIOS configuration
3977 */
3978
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003979enum {
3980 ALC_CTL_WIDGET_VOL,
3981 ALC_CTL_WIDGET_MUTE,
3982 ALC_CTL_BIND_MUTE,
3983};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003984static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003985 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
3986 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01003987 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003988};
3989
3990/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003991static int add_control(struct alc_spec *spec, int type, const char *name,
3992 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003993{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003994 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003995
Takashi Iwai603c4012008-07-30 15:01:44 +02003996 snd_array_init(&spec->kctls, sizeof(*knew), 32);
3997 knew = snd_array_new(&spec->kctls);
3998 if (!knew)
3999 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004000 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07004001 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004002 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004003 return -ENOMEM;
4004 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004005 return 0;
4006}
4007
4008#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
4009#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
4010#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
4011#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
4012#define alc880_is_input_pin(nid) ((nid) >= 0x18)
4013#define alc880_input_pin_idx(nid) ((nid) - 0x18)
4014#define alc880_idx_to_dac(nid) ((nid) + 0x02)
4015#define alc880_dac_to_idx(nid) ((nid) - 0x02)
4016#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
4017#define alc880_idx_to_selector(nid) ((nid) + 0x10)
4018#define ALC880_PIN_CD_NID 0x1c
4019
4020/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004021static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
4022 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004023{
4024 hda_nid_t nid;
4025 int assigned[4];
4026 int i, j;
4027
4028 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004029 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004030
4031 /* check the pins hardwired to audio widget */
4032 for (i = 0; i < cfg->line_outs; i++) {
4033 nid = cfg->line_out_pins[i];
4034 if (alc880_is_fixed_pin(nid)) {
4035 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01004036 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004037 assigned[idx] = 1;
4038 }
4039 }
4040 /* left pins can be connect to any audio widget */
4041 for (i = 0; i < cfg->line_outs; i++) {
4042 nid = cfg->line_out_pins[i];
4043 if (alc880_is_fixed_pin(nid))
4044 continue;
4045 /* search for an empty channel */
4046 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004047 if (!assigned[j]) {
4048 spec->multiout.dac_nids[i] =
4049 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004050 assigned[j] = 1;
4051 break;
4052 }
4053 }
4054 }
4055 spec->multiout.num_dacs = cfg->line_outs;
4056 return 0;
4057}
4058
4059/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01004060static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
4061 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004062{
4063 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004064 static const char *chname[4] = {
4065 "Front", "Surround", NULL /*CLFE*/, "Side"
4066 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004067 hda_nid_t nid;
4068 int i, err;
4069
4070 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004071 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004072 continue;
4073 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4074 if (i == 2) {
4075 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004076 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4077 "Center Playback Volume",
4078 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
4079 HDA_OUTPUT));
4080 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004081 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004082 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4083 "LFE Playback Volume",
4084 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
4085 HDA_OUTPUT));
4086 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004087 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004088 err = add_control(spec, ALC_CTL_BIND_MUTE,
4089 "Center Playback Switch",
4090 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
4091 HDA_INPUT));
4092 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004093 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004094 err = add_control(spec, ALC_CTL_BIND_MUTE,
4095 "LFE Playback Switch",
4096 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
4097 HDA_INPUT));
4098 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004099 return err;
4100 } else {
4101 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004102 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4103 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4104 HDA_OUTPUT));
4105 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004106 return err;
4107 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004108 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4109 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4110 HDA_INPUT));
4111 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004112 return err;
4113 }
4114 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004115 return 0;
4116}
4117
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004118/* add playback controls for speaker and HP outputs */
4119static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
4120 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004121{
4122 hda_nid_t nid;
4123 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004124 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004125
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004126 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004127 return 0;
4128
4129 if (alc880_is_fixed_pin(pin)) {
4130 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01004131 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004132 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004133 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004134 else
4135 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004136 /* control HP volume/switch on the output mixer amp */
4137 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004138 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004139 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4140 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
4141 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004142 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004143 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004144 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4145 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
4146 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004147 return err;
4148 } else if (alc880_is_multi_pin(pin)) {
4149 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004150 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004151 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004152 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4153 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
4154 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004155 return err;
4156 }
4157 return 0;
4158}
4159
4160/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004161static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4162 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01004163 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004164{
4165 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01004166 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004167
4168 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004169 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4170 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4171 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004172 return err;
4173 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004174 err = add_control(spec, ALC_CTL_WIDGET_MUTE, 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 return 0;
4179}
4180
4181/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01004182static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
4183 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004184{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004185 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004186 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004187
4188 for (i = 0; i < AUTO_PIN_LAST; i++) {
4189 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01004190 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01004191 err = new_analog_input(spec, cfg->input_pins[i],
4192 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01004193 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004194 if (err < 0)
4195 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004196 imux->items[imux->num_items].label =
4197 auto_pin_cfg_labels[i];
4198 imux->items[imux->num_items].index =
4199 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004200 imux->num_items++;
4201 }
4202 }
4203 return 0;
4204}
4205
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004206static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
4207 unsigned int pin_type)
4208{
4209 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4210 pin_type);
4211 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01004212 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4213 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004214}
4215
Kailang Yangdf694da2005-12-05 19:42:22 +01004216static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
4217 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004218 int dac_idx)
4219{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004220 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004221 /* need the manual connection? */
4222 if (alc880_is_multi_pin(nid)) {
4223 struct alc_spec *spec = codec->spec;
4224 int idx = alc880_multi_pin_idx(nid);
4225 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
4226 AC_VERB_SET_CONNECT_SEL,
4227 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
4228 }
4229}
4230
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004231static int get_pin_type(int line_out_type)
4232{
4233 if (line_out_type == AUTO_PIN_HP_OUT)
4234 return PIN_HP;
4235 else
4236 return PIN_OUT;
4237}
4238
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004239static void alc880_auto_init_multi_out(struct hda_codec *codec)
4240{
4241 struct alc_spec *spec = codec->spec;
4242 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02004243
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004244 for (i = 0; i < spec->autocfg.line_outs; i++) {
4245 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004246 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4247 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004248 }
4249}
4250
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004251static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004252{
4253 struct alc_spec *spec = codec->spec;
4254 hda_nid_t pin;
4255
Takashi Iwai82bc9552006-03-21 11:24:42 +01004256 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004257 if (pin) /* connect to front */
4258 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004259 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004260 if (pin) /* connect to front */
4261 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
4262}
4263
4264static void alc880_auto_init_analog_input(struct hda_codec *codec)
4265{
4266 struct alc_spec *spec = codec->spec;
4267 int i;
4268
4269 for (i = 0; i < AUTO_PIN_LAST; i++) {
4270 hda_nid_t nid = spec->autocfg.input_pins[i];
4271 if (alc880_is_input_pin(nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01004272 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01004273 if (nid != ALC880_PIN_CD_NID &&
4274 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004275 snd_hda_codec_write(codec, nid, 0,
4276 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004277 AMP_OUT_MUTE);
4278 }
4279 }
4280}
4281
4282/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004283/* return 1 if successful, 0 if the proper config is not found,
4284 * or a negative error code
4285 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004286static int alc880_parse_auto_config(struct hda_codec *codec)
4287{
4288 struct alc_spec *spec = codec->spec;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004289 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +01004290 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004291
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004292 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4293 alc880_ignore);
4294 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004295 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004296 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004297 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01004298
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004299 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
4300 if (err < 0)
4301 return err;
4302 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
4303 if (err < 0)
4304 return err;
4305 err = alc880_auto_create_extra_out(spec,
4306 spec->autocfg.speaker_pins[0],
4307 "Speaker");
4308 if (err < 0)
4309 return err;
4310 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
4311 "Headphone");
4312 if (err < 0)
4313 return err;
4314 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
4315 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004316 return err;
4317
4318 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4319
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004320 /* check multiple SPDIF-out (for recent codecs) */
4321 for (i = 0; i < spec->autocfg.dig_outs; i++) {
4322 hda_nid_t dig_nid;
4323 err = snd_hda_get_connections(codec,
4324 spec->autocfg.dig_out_pins[i],
4325 &dig_nid, 1);
4326 if (err < 0)
4327 continue;
4328 if (!i)
4329 spec->multiout.dig_out_nid = dig_nid;
4330 else {
4331 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
4332 spec->slave_dig_outs[i - 1] = dig_nid;
4333 if (i == ARRAY_SIZE(spec->slave_dig_outs) - 1)
4334 break;
4335 }
4336 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004337 if (spec->autocfg.dig_in_pin)
4338 spec->dig_in_nid = ALC880_DIGIN_NID;
4339
Takashi Iwai603c4012008-07-30 15:01:44 +02004340 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01004341 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004342
Takashi Iwaid88897e2008-10-31 15:01:37 +01004343 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004344
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004345 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004346 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004347
Takashi Iwai4a79ba32009-04-22 16:31:35 +02004348 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
4349
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004350 return 1;
4351}
4352
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004353/* additional initialization for auto-configuration model */
4354static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004355{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004356 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004357 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004358 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004359 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004360 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02004361 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004362}
4363
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004364static void set_capture_mixer(struct alc_spec *spec)
4365{
Takashi Iwaia23b6882009-03-23 15:21:36 +01004366 static struct snd_kcontrol_new *caps[2][3] = {
4367 { alc_capture_mixer_nosrc1,
4368 alc_capture_mixer_nosrc2,
4369 alc_capture_mixer_nosrc3 },
4370 { alc_capture_mixer1,
4371 alc_capture_mixer2,
4372 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004373 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01004374 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
4375 int mux;
4376 if (spec->input_mux && spec->input_mux->num_items > 1)
4377 mux = 1;
4378 else
4379 mux = 0;
4380 spec->cap_mixer = caps[mux][spec->num_adc_nids - 1];
4381 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004382}
4383
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004384#define set_beep_amp(spec, nid, idx, dir) \
4385 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
4386
4387/*
4388 * OK, here we have finally the patch for ALC880
4389 */
4390
Linus Torvalds1da177e2005-04-16 15:20:36 -07004391static int patch_alc880(struct hda_codec *codec)
4392{
4393 struct alc_spec *spec;
4394 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01004395 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004396
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004397 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004398 if (spec == NULL)
4399 return -ENOMEM;
4400
4401 codec->spec = spec;
4402
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004403 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
4404 alc880_models,
4405 alc880_cfg_tbl);
4406 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004407 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
4408 "trying auto-probe from BIOS...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004409 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004410 }
4411
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004412 if (board_config == ALC880_AUTO) {
4413 /* automatic parse from the BIOS config */
4414 err = alc880_parse_auto_config(codec);
4415 if (err < 0) {
4416 alc_free(codec);
4417 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004418 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004419 printk(KERN_INFO
4420 "hda_codec: Cannot set up configuration "
4421 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004422 board_config = ALC880_3ST;
4423 }
4424 }
4425
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09004426 err = snd_hda_attach_beep_device(codec, 0x1);
4427 if (err < 0) {
4428 alc_free(codec);
4429 return err;
4430 }
4431
Kailang Yangdf694da2005-12-05 19:42:22 +01004432 if (board_config != ALC880_AUTO)
4433 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004434
4435 spec->stream_name_analog = "ALC880 Analog";
4436 spec->stream_analog_playback = &alc880_pcm_analog_playback;
4437 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01004438 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004439
4440 spec->stream_name_digital = "ALC880 Digital";
4441 spec->stream_digital_playback = &alc880_pcm_digital_playback;
4442 spec->stream_digital_capture = &alc880_pcm_digital_capture;
4443
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004444 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004445 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01004446 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004447 /* get type */
4448 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004449 if (wcap != AC_WID_AUD_IN) {
4450 spec->adc_nids = alc880_adc_nids_alt;
4451 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004452 } else {
4453 spec->adc_nids = alc880_adc_nids;
4454 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004455 }
4456 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004457 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004458 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004459
Takashi Iwai2134ea42008-01-10 16:53:55 +01004460 spec->vmaster_nid = 0x0c;
4461
Linus Torvalds1da177e2005-04-16 15:20:36 -07004462 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004463 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004464 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02004465#ifdef CONFIG_SND_HDA_POWER_SAVE
4466 if (!spec->loopback.amplist)
4467 spec->loopback.amplist = alc880_loopbacks;
4468#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01004469 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004470
4471 return 0;
4472}
4473
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004474
Linus Torvalds1da177e2005-04-16 15:20:36 -07004475/*
4476 * ALC260 support
4477 */
4478
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004479static hda_nid_t alc260_dac_nids[1] = {
4480 /* front */
4481 0x02,
4482};
4483
4484static hda_nid_t alc260_adc_nids[1] = {
4485 /* ADC0 */
4486 0x04,
4487};
4488
Kailang Yangdf694da2005-12-05 19:42:22 +01004489static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004490 /* ADC1 */
4491 0x05,
4492};
4493
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004494/* NIDs used when simultaneous access to both ADCs makes sense. Note that
4495 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
4496 */
4497static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004498 /* ADC0, ADC1 */
4499 0x04, 0x05
4500};
4501
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004502#define ALC260_DIGOUT_NID 0x03
4503#define ALC260_DIGIN_NID 0x06
4504
4505static struct hda_input_mux alc260_capture_source = {
4506 .num_items = 4,
4507 .items = {
4508 { "Mic", 0x0 },
4509 { "Front Mic", 0x1 },
4510 { "Line", 0x2 },
4511 { "CD", 0x4 },
4512 },
4513};
4514
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004515/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004516 * headphone jack and the internal CD lines since these are the only pins at
4517 * which audio can appear. For flexibility, also allow the option of
4518 * recording the mixer output on the second ADC (ADC0 doesn't have a
4519 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004520 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004521static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
4522 {
4523 .num_items = 3,
4524 .items = {
4525 { "Mic/Line", 0x0 },
4526 { "CD", 0x4 },
4527 { "Headphone", 0x2 },
4528 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004529 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004530 {
4531 .num_items = 4,
4532 .items = {
4533 { "Mic/Line", 0x0 },
4534 { "CD", 0x4 },
4535 { "Headphone", 0x2 },
4536 { "Mixer", 0x5 },
4537 },
4538 },
4539
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004540};
4541
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004542/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
4543 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004544 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004545static struct hda_input_mux alc260_acer_capture_sources[2] = {
4546 {
4547 .num_items = 4,
4548 .items = {
4549 { "Mic", 0x0 },
4550 { "Line", 0x2 },
4551 { "CD", 0x4 },
4552 { "Headphone", 0x5 },
4553 },
4554 },
4555 {
4556 .num_items = 5,
4557 .items = {
4558 { "Mic", 0x0 },
4559 { "Line", 0x2 },
4560 { "CD", 0x4 },
4561 { "Headphone", 0x6 },
4562 { "Mixer", 0x5 },
4563 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004564 },
4565};
Michael Schwingencc959482009-02-22 18:58:45 +01004566
4567/* Maxdata Favorit 100XS */
4568static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
4569 {
4570 .num_items = 2,
4571 .items = {
4572 { "Line/Mic", 0x0 },
4573 { "CD", 0x4 },
4574 },
4575 },
4576 {
4577 .num_items = 3,
4578 .items = {
4579 { "Line/Mic", 0x0 },
4580 { "CD", 0x4 },
4581 { "Mixer", 0x5 },
4582 },
4583 },
4584};
4585
Linus Torvalds1da177e2005-04-16 15:20:36 -07004586/*
4587 * This is just place-holder, so there's something for alc_build_pcms to look
4588 * at when it calculates the maximum number of channels. ALC260 has no mixer
4589 * element which allows changing the channel mode, so the verb list is
4590 * never used.
4591 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004592static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004593 { 2, NULL },
4594};
4595
Kailang Yangdf694da2005-12-05 19:42:22 +01004596
4597/* Mixer combinations
4598 *
4599 * basic: base_output + input + pc_beep + capture
4600 * HP: base_output + input + capture_alt
4601 * HP_3013: hp_3013 + input + capture
4602 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004603 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01004604 */
4605
4606static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004607 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004608 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004609 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4610 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4611 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4612 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4613 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004614};
Kailang Yangdf694da2005-12-05 19:42:22 +01004615
4616static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004617 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4618 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4619 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4620 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4621 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4622 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4623 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
4624 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004625 { } /* end */
4626};
4627
Takashi Iwaibec15c32008-01-28 18:16:30 +01004628/* update HP, line and mono out pins according to the master switch */
4629static void alc260_hp_master_update(struct hda_codec *codec,
4630 hda_nid_t hp, hda_nid_t line,
4631 hda_nid_t mono)
4632{
4633 struct alc_spec *spec = codec->spec;
4634 unsigned int val = spec->master_sw ? PIN_HP : 0;
4635 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004636 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004637 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004638 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004639 val);
4640 /* mono (speaker) depending on the HP jack sense */
4641 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004642 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004643 val);
4644}
4645
4646static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
4647 struct snd_ctl_elem_value *ucontrol)
4648{
4649 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4650 struct alc_spec *spec = codec->spec;
4651 *ucontrol->value.integer.value = spec->master_sw;
4652 return 0;
4653}
4654
4655static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
4656 struct snd_ctl_elem_value *ucontrol)
4657{
4658 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4659 struct alc_spec *spec = codec->spec;
4660 int val = !!*ucontrol->value.integer.value;
4661 hda_nid_t hp, line, mono;
4662
4663 if (val == spec->master_sw)
4664 return 0;
4665 spec->master_sw = val;
4666 hp = (kcontrol->private_value >> 16) & 0xff;
4667 line = (kcontrol->private_value >> 8) & 0xff;
4668 mono = kcontrol->private_value & 0xff;
4669 alc260_hp_master_update(codec, hp, line, mono);
4670 return 1;
4671}
4672
4673static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
4674 {
4675 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4676 .name = "Master Playback Switch",
4677 .info = snd_ctl_boolean_mono_info,
4678 .get = alc260_hp_master_sw_get,
4679 .put = alc260_hp_master_sw_put,
4680 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
4681 },
4682 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4683 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
4684 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4685 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4686 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
4687 HDA_OUTPUT),
4688 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4689 { } /* end */
4690};
4691
4692static struct hda_verb alc260_hp_unsol_verbs[] = {
4693 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4694 {},
4695};
4696
4697static void alc260_hp_automute(struct hda_codec *codec)
4698{
4699 struct alc_spec *spec = codec->spec;
4700 unsigned int present;
4701
4702 present = snd_hda_codec_read(codec, 0x10, 0,
4703 AC_VERB_GET_PIN_SENSE, 0);
4704 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4705 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
4706}
4707
4708static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
4709{
4710 if ((res >> 26) == ALC880_HP_EVENT)
4711 alc260_hp_automute(codec);
4712}
4713
Kailang Yangdf694da2005-12-05 19:42:22 +01004714static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01004715 {
4716 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4717 .name = "Master Playback Switch",
4718 .info = snd_ctl_boolean_mono_info,
4719 .get = alc260_hp_master_sw_get,
4720 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004721 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01004722 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004723 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4724 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4725 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
4726 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
4727 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4728 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01004729 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4730 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02004731 { } /* end */
4732};
4733
Kailang Yang3f878302008-08-26 13:02:23 +02004734static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
4735 .ops = &snd_hda_bind_vol,
4736 .values = {
4737 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
4738 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
4739 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
4740 0
4741 },
4742};
4743
4744static struct hda_bind_ctls alc260_dc7600_bind_switch = {
4745 .ops = &snd_hda_bind_sw,
4746 .values = {
4747 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
4748 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
4749 0
4750 },
4751};
4752
4753static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
4754 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
4755 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
4756 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
4757 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4758 { } /* end */
4759};
4760
Takashi Iwaibec15c32008-01-28 18:16:30 +01004761static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
4762 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4763 {},
4764};
4765
4766static void alc260_hp_3013_automute(struct hda_codec *codec)
4767{
4768 struct alc_spec *spec = codec->spec;
4769 unsigned int present;
4770
4771 present = snd_hda_codec_read(codec, 0x15, 0,
4772 AC_VERB_GET_PIN_SENSE, 0);
4773 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004774 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01004775}
4776
4777static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
4778 unsigned int res)
4779{
4780 if ((res >> 26) == ALC880_HP_EVENT)
4781 alc260_hp_3013_automute(codec);
4782}
4783
Kailang Yang3f878302008-08-26 13:02:23 +02004784static void alc260_hp_3012_automute(struct hda_codec *codec)
4785{
4786 unsigned int present, bits;
4787
4788 present = snd_hda_codec_read(codec, 0x10, 0,
4789 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
4790
4791 bits = present ? 0 : PIN_OUT;
4792 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4793 bits);
4794 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4795 bits);
4796 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4797 bits);
4798}
4799
4800static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
4801 unsigned int res)
4802{
4803 if ((res >> 26) == ALC880_HP_EVENT)
4804 alc260_hp_3012_automute(codec);
4805}
4806
4807/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004808 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
4809 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004810static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004811 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004812 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004813 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004814 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4815 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4816 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
4817 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004818 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004819 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4820 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004821 { } /* end */
4822};
4823
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004824/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
4825 * versions of the ALC260 don't act on requests to enable mic bias from NID
4826 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
4827 * datasheet doesn't mention this restriction. At this stage it's not clear
4828 * whether this behaviour is intentional or is a hardware bug in chip
4829 * revisions available in early 2006. Therefore for now allow the
4830 * "Headphone Jack Mode" control to span all choices, but if it turns out
4831 * that the lack of mic bias for this NID is intentional we could change the
4832 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4833 *
4834 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
4835 * don't appear to make the mic bias available from the "line" jack, even
4836 * though the NID used for this jack (0x14) can supply it. The theory is
4837 * that perhaps Acer have included blocking capacitors between the ALC260
4838 * and the output jack. If this turns out to be the case for all such
4839 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
4840 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01004841 *
4842 * The C20x Tablet series have a mono internal speaker which is controlled
4843 * via the chip's Mono sum widget and pin complex, so include the necessary
4844 * controls for such models. On models without a "mono speaker" the control
4845 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004846 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004847static struct snd_kcontrol_new alc260_acer_mixer[] = {
4848 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4849 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004850 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004851 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01004852 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004853 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01004854 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004855 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4856 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4857 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4858 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4859 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4860 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4861 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4862 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004863 { } /* end */
4864};
4865
Michael Schwingencc959482009-02-22 18:58:45 +01004866/* Maxdata Favorit 100XS: one output and one input (0x12) jack
4867 */
4868static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
4869 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4870 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
4871 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
4872 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4873 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4874 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4875 { } /* end */
4876};
4877
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004878/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
4879 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
4880 */
4881static struct snd_kcontrol_new alc260_will_mixer[] = {
4882 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4883 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4884 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4885 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4886 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4887 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4888 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4889 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4890 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4891 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004892 { } /* end */
4893};
4894
4895/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
4896 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
4897 */
4898static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
4899 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4900 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4901 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4902 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4903 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4904 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
4905 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
4906 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4907 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4908 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4909 { } /* end */
4910};
4911
Kailang Yangdf694da2005-12-05 19:42:22 +01004912/*
4913 * initialization verbs
4914 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004915static struct hda_verb alc260_init_verbs[] = {
4916 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004917 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004918 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004919 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004920 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004921 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004922 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004923 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004924 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02004925 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004926 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01004927 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004928 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02004929 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004930 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02004931 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004932 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02004933 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4934 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02004935 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004936 /* set connection select to line in (default select for this ADC) */
4937 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02004938 /* mute capture amp left and right */
4939 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4940 /* set connection select to line in (default select for this ADC) */
4941 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02004942 /* set vol=0 Line-Out mixer amp left and right */
4943 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4944 /* unmute pin widget amp left and right (no gain on this amp) */
4945 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4946 /* set vol=0 HP mixer amp left and right */
4947 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4948 /* unmute pin widget amp left and right (no gain on this amp) */
4949 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4950 /* set vol=0 Mono mixer amp left and right */
4951 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4952 /* unmute pin widget amp left and right (no gain on this amp) */
4953 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4954 /* unmute LINE-2 out pin */
4955 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004956 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4957 * Line In 2 = 0x03
4958 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004959 /* mute analog inputs */
4960 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4961 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4962 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4963 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4964 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004965 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004966 /* mute Front out path */
4967 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4968 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4969 /* mute Headphone out path */
4970 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4971 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4972 /* mute Mono out path */
4973 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4974 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004975 { }
4976};
4977
Takashi Iwai474167d2006-05-17 17:17:43 +02004978#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01004979static struct hda_verb alc260_hp_init_verbs[] = {
4980 /* Headphone and output */
4981 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4982 /* mono output */
4983 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4984 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4985 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4986 /* Mic2 (front panel) pin widget for input and vref at 80% */
4987 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4988 /* Line In pin widget for input */
4989 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4990 /* Line-2 pin widget for output */
4991 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4992 /* CD pin widget for input */
4993 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4994 /* unmute amp left and right */
4995 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4996 /* set connection select to line in (default select for this ADC) */
4997 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4998 /* unmute Line-Out mixer amp left and right (volume = 0) */
4999 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5000 /* mute pin widget amp left and right (no gain on this amp) */
5001 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5002 /* unmute HP mixer amp left and right (volume = 0) */
5003 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5004 /* mute pin widget amp left and right (no gain on this amp) */
5005 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005006 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5007 * Line In 2 = 0x03
5008 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005009 /* mute analog inputs */
5010 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5011 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5012 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5013 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5014 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005015 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5016 /* Unmute Front out path */
5017 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5018 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5019 /* Unmute Headphone out path */
5020 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5021 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5022 /* Unmute Mono out path */
5023 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5024 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5025 { }
5026};
Takashi Iwai474167d2006-05-17 17:17:43 +02005027#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005028
5029static struct hda_verb alc260_hp_3013_init_verbs[] = {
5030 /* Line out and output */
5031 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5032 /* mono output */
5033 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5034 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5035 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5036 /* Mic2 (front panel) pin widget for input and vref at 80% */
5037 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5038 /* Line In pin widget for input */
5039 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5040 /* Headphone pin widget for output */
5041 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5042 /* CD pin widget for input */
5043 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5044 /* unmute amp left and right */
5045 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5046 /* set connection select to line in (default select for this ADC) */
5047 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5048 /* unmute Line-Out mixer amp left and right (volume = 0) */
5049 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5050 /* mute pin widget amp left and right (no gain on this amp) */
5051 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5052 /* unmute HP mixer amp left and right (volume = 0) */
5053 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5054 /* mute pin widget amp left and right (no gain on this amp) */
5055 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005056 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5057 * Line In 2 = 0x03
5058 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005059 /* mute analog inputs */
5060 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5061 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5062 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5063 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5064 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005065 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5066 /* Unmute Front out path */
5067 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5068 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5069 /* Unmute Headphone out path */
5070 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5071 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5072 /* Unmute Mono out path */
5073 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5074 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5075 { }
5076};
5077
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005078/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005079 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
5080 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005081 */
5082static struct hda_verb alc260_fujitsu_init_verbs[] = {
5083 /* Disable all GPIOs */
5084 {0x01, AC_VERB_SET_GPIO_MASK, 0},
5085 /* Internal speaker is connected to headphone pin */
5086 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5087 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
5088 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005089 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
5090 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5091 /* Ensure all other unused pins are disabled and muted. */
5092 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5093 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005094 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005095 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005096 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005097 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5098 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5099 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005100
Jonathan Woithef7ace402006-02-28 11:46:14 +01005101 /* Disable digital (SPDIF) pins */
5102 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5103 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005104
Kailang Yangea1fb292008-08-26 12:58:38 +02005105 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01005106 * when acting as an output.
5107 */
5108 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5109
5110 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01005111 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5112 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5113 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5114 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5115 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5116 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5117 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5118 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5119 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005120
Jonathan Woithef7ace402006-02-28 11:46:14 +01005121 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
5122 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5123 /* Unmute Line1 pin widget output buffer since it starts as an output.
5124 * If the pin mode is changed by the user the pin mode control will
5125 * take care of enabling the pin's input/output buffers as needed.
5126 * Therefore there's no need to enable the input buffer at this
5127 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005128 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005129 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02005130 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005131 * mixer ctrl)
5132 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005133 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005134
Jonathan Woithef7ace402006-02-28 11:46:14 +01005135 /* Mute capture amp left and right */
5136 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005137 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01005138 * in (on mic1 pin)
5139 */
5140 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005141
Jonathan Woithef7ace402006-02-28 11:46:14 +01005142 /* Do the same for the second ADC: mute capture input amp and
5143 * set ADC connection to line in (on mic1 pin)
5144 */
5145 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5146 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005147
Jonathan Woithef7ace402006-02-28 11:46:14 +01005148 /* Mute all inputs to mixer widget (even unconnected ones) */
5149 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5150 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5151 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5152 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5153 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5154 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5155 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5156 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005157
5158 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005159};
5160
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005161/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
5162 * similar laptops (adapted from Fujitsu init verbs).
5163 */
5164static struct hda_verb alc260_acer_init_verbs[] = {
5165 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
5166 * the headphone jack. Turn this on and rely on the standard mute
5167 * methods whenever the user wants to turn these outputs off.
5168 */
5169 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5170 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5171 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5172 /* Internal speaker/Headphone jack is connected to Line-out pin */
5173 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5174 /* Internal microphone/Mic jack is connected to Mic1 pin */
5175 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5176 /* Line In jack is connected to Line1 pin */
5177 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01005178 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
5179 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005180 /* Ensure all other unused pins are disabled and muted. */
5181 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5182 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005183 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5184 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5185 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5186 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5187 /* Disable digital (SPDIF) pins */
5188 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5189 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5190
Kailang Yangea1fb292008-08-26 12:58:38 +02005191 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005192 * bus when acting as outputs.
5193 */
5194 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5195 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5196
5197 /* Start with output sum widgets muted and their output gains at min */
5198 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5199 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5200 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5201 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5202 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5203 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5204 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5205 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5206 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5207
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005208 /* Unmute Line-out pin widget amp left and right
5209 * (no equiv mixer ctrl)
5210 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005211 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01005212 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
5213 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005214 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5215 * inputs. If the pin mode is changed by the user the pin mode control
5216 * will take care of enabling the pin's input/output buffers as needed.
5217 * Therefore there's no need to enable the input buffer at this
5218 * stage.
5219 */
5220 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5221 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5222
5223 /* Mute capture amp left and right */
5224 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5225 /* Set ADC connection select to match default mixer setting - mic
5226 * (on mic1 pin)
5227 */
5228 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5229
5230 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005231 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005232 */
5233 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005234 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005235
5236 /* Mute all inputs to mixer widget (even unconnected ones) */
5237 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5238 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5239 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5240 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5241 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5242 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5243 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5244 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5245
5246 { }
5247};
5248
Michael Schwingencc959482009-02-22 18:58:45 +01005249/* Initialisation sequence for Maxdata Favorit 100XS
5250 * (adapted from Acer init verbs).
5251 */
5252static struct hda_verb alc260_favorit100_init_verbs[] = {
5253 /* GPIO 0 enables the output jack.
5254 * Turn this on and rely on the standard mute
5255 * methods whenever the user wants to turn these outputs off.
5256 */
5257 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5258 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5259 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5260 /* Line/Mic input jack is connected to Mic1 pin */
5261 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5262 /* Ensure all other unused pins are disabled and muted. */
5263 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5264 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5265 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5266 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5267 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5268 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5269 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5270 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5271 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5272 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5273 /* Disable digital (SPDIF) pins */
5274 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5275 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5276
5277 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
5278 * bus when acting as outputs.
5279 */
5280 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5281 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5282
5283 /* Start with output sum widgets muted and their output gains at min */
5284 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5285 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5286 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5287 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5288 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5289 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5290 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5291 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5292 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5293
5294 /* Unmute Line-out pin widget amp left and right
5295 * (no equiv mixer ctrl)
5296 */
5297 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5298 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5299 * inputs. If the pin mode is changed by the user the pin mode control
5300 * will take care of enabling the pin's input/output buffers as needed.
5301 * Therefore there's no need to enable the input buffer at this
5302 * stage.
5303 */
5304 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5305
5306 /* Mute capture amp left and right */
5307 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5308 /* Set ADC connection select to match default mixer setting - mic
5309 * (on mic1 pin)
5310 */
5311 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5312
5313 /* Do similar with the second ADC: mute capture input amp and
5314 * set ADC connection to mic to match ALSA's default state.
5315 */
5316 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5317 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5318
5319 /* Mute all inputs to mixer widget (even unconnected ones) */
5320 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5321 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5322 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5323 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5324 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5325 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5326 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5327 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5328
5329 { }
5330};
5331
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005332static struct hda_verb alc260_will_verbs[] = {
5333 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5334 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
5335 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
5336 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5337 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5338 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
5339 {}
5340};
5341
5342static struct hda_verb alc260_replacer_672v_verbs[] = {
5343 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5344 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5345 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
5346
5347 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5348 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5349 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5350
5351 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5352 {}
5353};
5354
5355/* toggle speaker-output according to the hp-jack state */
5356static void alc260_replacer_672v_automute(struct hda_codec *codec)
5357{
5358 unsigned int present;
5359
5360 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
5361 present = snd_hda_codec_read(codec, 0x0f, 0,
5362 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5363 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005364 snd_hda_codec_write_cache(codec, 0x01, 0,
5365 AC_VERB_SET_GPIO_DATA, 1);
5366 snd_hda_codec_write_cache(codec, 0x0f, 0,
5367 AC_VERB_SET_PIN_WIDGET_CONTROL,
5368 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005369 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005370 snd_hda_codec_write_cache(codec, 0x01, 0,
5371 AC_VERB_SET_GPIO_DATA, 0);
5372 snd_hda_codec_write_cache(codec, 0x0f, 0,
5373 AC_VERB_SET_PIN_WIDGET_CONTROL,
5374 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005375 }
5376}
5377
5378static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
5379 unsigned int res)
5380{
5381 if ((res >> 26) == ALC880_HP_EVENT)
5382 alc260_replacer_672v_automute(codec);
5383}
5384
Kailang Yang3f878302008-08-26 13:02:23 +02005385static struct hda_verb alc260_hp_dc7600_verbs[] = {
5386 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
5387 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5388 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5389 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5390 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5391 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5392 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5393 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5394 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5395 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5396 {}
5397};
5398
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005399/* Test configuration for debugging, modelled after the ALC880 test
5400 * configuration.
5401 */
5402#ifdef CONFIG_SND_DEBUG
5403static hda_nid_t alc260_test_dac_nids[1] = {
5404 0x02,
5405};
5406static hda_nid_t alc260_test_adc_nids[2] = {
5407 0x04, 0x05,
5408};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005409/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02005410 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005411 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005412 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005413static struct hda_input_mux alc260_test_capture_sources[2] = {
5414 {
5415 .num_items = 7,
5416 .items = {
5417 { "MIC1 pin", 0x0 },
5418 { "MIC2 pin", 0x1 },
5419 { "LINE1 pin", 0x2 },
5420 { "LINE2 pin", 0x3 },
5421 { "CD pin", 0x4 },
5422 { "LINE-OUT pin", 0x5 },
5423 { "HP-OUT pin", 0x6 },
5424 },
5425 },
5426 {
5427 .num_items = 8,
5428 .items = {
5429 { "MIC1 pin", 0x0 },
5430 { "MIC2 pin", 0x1 },
5431 { "LINE1 pin", 0x2 },
5432 { "LINE2 pin", 0x3 },
5433 { "CD pin", 0x4 },
5434 { "Mixer", 0x5 },
5435 { "LINE-OUT pin", 0x6 },
5436 { "HP-OUT pin", 0x7 },
5437 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005438 },
5439};
5440static struct snd_kcontrol_new alc260_test_mixer[] = {
5441 /* Output driver widgets */
5442 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5443 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5444 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5445 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
5446 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5447 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
5448
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005449 /* Modes for retasking pin widgets
5450 * Note: the ALC260 doesn't seem to act on requests to enable mic
5451 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
5452 * mention this restriction. At this stage it's not clear whether
5453 * this behaviour is intentional or is a hardware bug in chip
5454 * revisions available at least up until early 2006. Therefore for
5455 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
5456 * choices, but if it turns out that the lack of mic bias for these
5457 * NIDs is intentional we could change their modes from
5458 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5459 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005460 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
5461 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
5462 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
5463 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
5464 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
5465 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
5466
5467 /* Loopback mixer controls */
5468 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
5469 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
5470 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
5471 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
5472 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
5473 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
5474 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
5475 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
5476 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5477 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005478 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
5479 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
5480 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
5481 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005482
5483 /* Controls for GPIO pins, assuming they are configured as outputs */
5484 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
5485 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
5486 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
5487 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
5488
Jonathan Woithe92621f12006-02-28 11:47:47 +01005489 /* Switches to allow the digital IO pins to be enabled. The datasheet
5490 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02005491 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01005492 */
5493 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
5494 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
5495
Jonathan Woithef8225f62008-01-08 12:16:54 +01005496 /* A switch allowing EAPD to be enabled. Some laptops seem to use
5497 * this output to turn on an external amplifier.
5498 */
5499 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
5500 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
5501
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005502 { } /* end */
5503};
5504static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005505 /* Enable all GPIOs as outputs with an initial value of 0 */
5506 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
5507 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5508 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
5509
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005510 /* Enable retasking pins as output, initially without power amp */
5511 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5512 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5513 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5514 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5515 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5516 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5517
Jonathan Woithe92621f12006-02-28 11:47:47 +01005518 /* Disable digital (SPDIF) pins initially, but users can enable
5519 * them via a mixer switch. In the case of SPDIF-out, this initverb
5520 * payload also sets the generation to 0, output to be in "consumer"
5521 * PCM format, copyright asserted, no pre-emphasis and no validity
5522 * control.
5523 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005524 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5525 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5526
Kailang Yangea1fb292008-08-26 12:58:38 +02005527 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005528 * OUT1 sum bus when acting as an output.
5529 */
5530 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5531 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
5532 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5533 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
5534
5535 /* Start with output sum widgets muted and their output gains at min */
5536 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5537 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5538 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5539 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5540 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5541 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5542 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5543 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5544 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5545
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005546 /* Unmute retasking pin widget output buffers since the default
5547 * state appears to be output. As the pin mode is changed by the
5548 * user the pin mode control will take care of enabling the pin's
5549 * input/output buffers as needed.
5550 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005551 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5552 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5553 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5554 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5555 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5556 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5557 /* Also unmute the mono-out pin widget */
5558 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5559
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005560 /* Mute capture amp left and right */
5561 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005562 /* Set ADC connection select to match default mixer setting (mic1
5563 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005564 */
5565 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5566
5567 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01005568 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005569 */
5570 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5571 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5572
5573 /* Mute all inputs to mixer widget (even unconnected ones) */
5574 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5575 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5576 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5577 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5578 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5579 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5580 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5581 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5582
5583 { }
5584};
5585#endif
5586
Takashi Iwai63300792008-01-24 15:31:36 +01005587#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
5588#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07005589
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005590#define alc260_pcm_digital_playback alc880_pcm_digital_playback
5591#define alc260_pcm_digital_capture alc880_pcm_digital_capture
5592
Kailang Yangdf694da2005-12-05 19:42:22 +01005593/*
5594 * for BIOS auto-configuration
5595 */
5596
5597static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02005598 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01005599{
5600 hda_nid_t nid_vol;
5601 unsigned long vol_val, sw_val;
5602 char name[32];
5603 int err;
5604
5605 if (nid >= 0x0f && nid < 0x11) {
5606 nid_vol = nid - 0x7;
5607 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5608 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5609 } else if (nid == 0x11) {
5610 nid_vol = nid - 0x7;
5611 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
5612 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
5613 } else if (nid >= 0x12 && nid <= 0x15) {
5614 nid_vol = 0x08;
5615 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5616 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5617 } else
5618 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02005619
Takashi Iwai863b4512008-10-21 17:01:47 +02005620 if (!(*vol_bits & (1 << nid_vol))) {
5621 /* first control for the volume widget */
5622 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
5623 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
5624 if (err < 0)
5625 return err;
5626 *vol_bits |= (1 << nid_vol);
5627 }
Kailang Yangdf694da2005-12-05 19:42:22 +01005628 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005629 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
5630 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005631 return err;
5632 return 1;
5633}
5634
5635/* add playback controls from the parsed DAC table */
5636static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
5637 const struct auto_pin_cfg *cfg)
5638{
5639 hda_nid_t nid;
5640 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02005641 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005642
5643 spec->multiout.num_dacs = 1;
5644 spec->multiout.dac_nids = spec->private_dac_nids;
5645 spec->multiout.dac_nids[0] = 0x02;
5646
5647 nid = cfg->line_out_pins[0];
5648 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005649 err = alc260_add_playback_controls(spec, nid, "Front", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005650 if (err < 0)
5651 return err;
5652 }
5653
Takashi Iwai82bc9552006-03-21 11:24:42 +01005654 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005655 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005656 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005657 if (err < 0)
5658 return err;
5659 }
5660
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005661 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005662 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005663 err = alc260_add_playback_controls(spec, nid, "Headphone",
5664 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005665 if (err < 0)
5666 return err;
5667 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005668 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005669}
5670
5671/* create playback/capture controls for input pins */
5672static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
5673 const struct auto_pin_cfg *cfg)
5674{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005675 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005676 int i, err, idx;
5677
5678 for (i = 0; i < AUTO_PIN_LAST; i++) {
5679 if (cfg->input_pins[i] >= 0x12) {
5680 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005681 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005682 auto_pin_cfg_labels[i], idx,
5683 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005684 if (err < 0)
5685 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005686 imux->items[imux->num_items].label =
5687 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005688 imux->items[imux->num_items].index = idx;
5689 imux->num_items++;
5690 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005691 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01005692 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005693 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005694 auto_pin_cfg_labels[i], idx,
5695 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005696 if (err < 0)
5697 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005698 imux->items[imux->num_items].label =
5699 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005700 imux->items[imux->num_items].index = idx;
5701 imux->num_items++;
5702 }
5703 }
5704 return 0;
5705}
5706
5707static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
5708 hda_nid_t nid, int pin_type,
5709 int sel_idx)
5710{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005711 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01005712 /* need the manual connection? */
5713 if (nid >= 0x12) {
5714 int idx = nid - 0x12;
5715 snd_hda_codec_write(codec, idx + 0x0b, 0,
5716 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01005717 }
5718}
5719
5720static void alc260_auto_init_multi_out(struct hda_codec *codec)
5721{
5722 struct alc_spec *spec = codec->spec;
5723 hda_nid_t nid;
5724
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005725 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005726 if (nid) {
5727 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5728 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
5729 }
Kailang Yangea1fb292008-08-26 12:58:38 +02005730
Takashi Iwai82bc9552006-03-21 11:24:42 +01005731 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005732 if (nid)
5733 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
5734
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005735 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005736 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005737 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005738}
Kailang Yangdf694da2005-12-05 19:42:22 +01005739
5740#define ALC260_PIN_CD_NID 0x16
5741static void alc260_auto_init_analog_input(struct hda_codec *codec)
5742{
5743 struct alc_spec *spec = codec->spec;
5744 int i;
5745
5746 for (i = 0; i < AUTO_PIN_LAST; i++) {
5747 hda_nid_t nid = spec->autocfg.input_pins[i];
5748 if (nid >= 0x12) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01005749 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01005750 if (nid != ALC260_PIN_CD_NID &&
5751 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005752 snd_hda_codec_write(codec, nid, 0,
5753 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01005754 AMP_OUT_MUTE);
5755 }
5756 }
5757}
5758
5759/*
5760 * generic initialization of ADC, input mixers and output mixers
5761 */
5762static struct hda_verb alc260_volume_init_verbs[] = {
5763 /*
5764 * Unmute ADC0-1 and set the default input to mic-in
5765 */
5766 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5767 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5768 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5769 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005770
Kailang Yangdf694da2005-12-05 19:42:22 +01005771 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5772 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005773 * Note: PASD motherboards uses the Line In 2 as the input for
5774 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01005775 */
5776 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005777 /* mute analog inputs */
5778 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5779 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5780 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5781 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5782 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005783
5784 /*
5785 * Set up output mixers (0x08 - 0x0a)
5786 */
5787 /* set vol=0 to output mixers */
5788 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5789 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5790 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5791 /* set up input amps for analog loopback */
5792 /* Amp Indices: DAC = 0, mixer = 1 */
5793 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5794 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5795 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5796 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5797 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5798 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005799
Kailang Yangdf694da2005-12-05 19:42:22 +01005800 { }
5801};
5802
5803static int alc260_parse_auto_config(struct hda_codec *codec)
5804{
5805 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005806 int err;
5807 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
5808
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005809 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5810 alc260_ignore);
5811 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005812 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005813 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
5814 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01005815 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02005816 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01005817 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005818 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
5819 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005820 return err;
5821
5822 spec->multiout.max_channels = 2;
5823
Takashi Iwai0852d7a2009-02-11 11:35:15 +01005824 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01005825 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02005826 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01005827 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01005828
Takashi Iwaid88897e2008-10-31 15:01:37 +01005829 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01005830
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005831 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005832 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005833
Takashi Iwai4a79ba32009-04-22 16:31:35 +02005834 alc_ssid_check(codec, 0x10, 0x15, 0x0f);
5835
Kailang Yangdf694da2005-12-05 19:42:22 +01005836 return 1;
5837}
5838
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005839/* additional initialization for auto-configuration model */
5840static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01005841{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005842 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005843 alc260_auto_init_multi_out(codec);
5844 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005845 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02005846 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005847}
5848
Takashi Iwaicb53c622007-08-10 17:21:45 +02005849#ifdef CONFIG_SND_HDA_POWER_SAVE
5850static struct hda_amp_list alc260_loopbacks[] = {
5851 { 0x07, HDA_INPUT, 0 },
5852 { 0x07, HDA_INPUT, 1 },
5853 { 0x07, HDA_INPUT, 2 },
5854 { 0x07, HDA_INPUT, 3 },
5855 { 0x07, HDA_INPUT, 4 },
5856 { } /* end */
5857};
5858#endif
5859
Kailang Yangdf694da2005-12-05 19:42:22 +01005860/*
5861 * ALC260 configurations
5862 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005863static const char *alc260_models[ALC260_MODEL_LAST] = {
5864 [ALC260_BASIC] = "basic",
5865 [ALC260_HP] = "hp",
5866 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02005867 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005868 [ALC260_FUJITSU_S702X] = "fujitsu",
5869 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005870 [ALC260_WILL] = "will",
5871 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01005872 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005873#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005874 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005875#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005876 [ALC260_AUTO] = "auto",
5877};
5878
5879static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01005880 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005881 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01005882 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01005883 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01005884 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005885 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02005886 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02005887 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005888 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
5889 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
5890 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
5891 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
5892 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
5893 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
5894 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
5895 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
5896 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005897 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01005898 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02005899 {}
5900};
5901
Kailang Yangdf694da2005-12-05 19:42:22 +01005902static struct alc_config_preset alc260_presets[] = {
5903 [ALC260_BASIC] = {
5904 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005905 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01005906 .init_verbs = { alc260_init_verbs },
5907 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5908 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005909 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Kailang Yangdf694da2005-12-05 19:42:22 +01005910 .adc_nids = alc260_adc_nids,
5911 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5912 .channel_mode = alc260_modes,
5913 .input_mux = &alc260_capture_source,
5914 },
5915 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005916 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005917 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005918 .init_verbs = { alc260_init_verbs,
5919 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005920 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5921 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005922 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5923 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01005924 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5925 .channel_mode = alc260_modes,
5926 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005927 .unsol_event = alc260_hp_unsol_event,
5928 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005929 },
Kailang Yang3f878302008-08-26 13:02:23 +02005930 [ALC260_HP_DC7600] = {
5931 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005932 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02005933 .init_verbs = { alc260_init_verbs,
5934 alc260_hp_dc7600_verbs },
5935 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5936 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005937 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5938 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02005939 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5940 .channel_mode = alc260_modes,
5941 .input_mux = &alc260_capture_source,
5942 .unsol_event = alc260_hp_3012_unsol_event,
5943 .init_hook = alc260_hp_3012_automute,
5944 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005945 [ALC260_HP_3013] = {
5946 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005947 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005948 .init_verbs = { alc260_hp_3013_init_verbs,
5949 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005950 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5951 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005952 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5953 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01005954 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5955 .channel_mode = alc260_modes,
5956 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005957 .unsol_event = alc260_hp_3013_unsol_event,
5958 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005959 },
5960 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005961 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01005962 .init_verbs = { alc260_fujitsu_init_verbs },
5963 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5964 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005965 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5966 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01005967 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5968 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005969 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
5970 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01005971 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005972 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005973 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005974 .init_verbs = { alc260_acer_init_verbs },
5975 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5976 .dac_nids = alc260_dac_nids,
5977 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5978 .adc_nids = alc260_dual_adc_nids,
5979 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5980 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005981 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
5982 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005983 },
Michael Schwingencc959482009-02-22 18:58:45 +01005984 [ALC260_FAVORIT100] = {
5985 .mixers = { alc260_favorit100_mixer },
5986 .init_verbs = { alc260_favorit100_init_verbs },
5987 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5988 .dac_nids = alc260_dac_nids,
5989 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5990 .adc_nids = alc260_dual_adc_nids,
5991 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5992 .channel_mode = alc260_modes,
5993 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
5994 .input_mux = alc260_favorit100_capture_sources,
5995 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005996 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005997 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005998 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
5999 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6000 .dac_nids = alc260_dac_nids,
6001 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6002 .adc_nids = alc260_adc_nids,
6003 .dig_out_nid = ALC260_DIGOUT_NID,
6004 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6005 .channel_mode = alc260_modes,
6006 .input_mux = &alc260_capture_source,
6007 },
6008 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006009 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006010 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
6011 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6012 .dac_nids = alc260_dac_nids,
6013 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6014 .adc_nids = alc260_adc_nids,
6015 .dig_out_nid = ALC260_DIGOUT_NID,
6016 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6017 .channel_mode = alc260_modes,
6018 .input_mux = &alc260_capture_source,
6019 .unsol_event = alc260_replacer_672v_unsol_event,
6020 .init_hook = alc260_replacer_672v_automute,
6021 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006022#ifdef CONFIG_SND_DEBUG
6023 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006024 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006025 .init_verbs = { alc260_test_init_verbs },
6026 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
6027 .dac_nids = alc260_test_dac_nids,
6028 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
6029 .adc_nids = alc260_test_adc_nids,
6030 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6031 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006032 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
6033 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006034 },
6035#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006036};
6037
Linus Torvalds1da177e2005-04-16 15:20:36 -07006038static int patch_alc260(struct hda_codec *codec)
6039{
6040 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006041 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006042
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006043 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006044 if (spec == NULL)
6045 return -ENOMEM;
6046
6047 codec->spec = spec;
6048
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006049 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
6050 alc260_models,
6051 alc260_cfg_tbl);
6052 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006053 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
6054 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006055 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02006056 }
6057
Kailang Yangdf694da2005-12-05 19:42:22 +01006058 if (board_config == ALC260_AUTO) {
6059 /* automatic parse from the BIOS config */
6060 err = alc260_parse_auto_config(codec);
6061 if (err < 0) {
6062 alc_free(codec);
6063 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006064 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006065 printk(KERN_INFO
6066 "hda_codec: Cannot set up configuration "
6067 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006068 board_config = ALC260_BASIC;
6069 }
Takashi Iwai16ded522005-06-10 19:58:24 +02006070 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006071
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09006072 err = snd_hda_attach_beep_device(codec, 0x1);
6073 if (err < 0) {
6074 alc_free(codec);
6075 return err;
6076 }
6077
Kailang Yangdf694da2005-12-05 19:42:22 +01006078 if (board_config != ALC260_AUTO)
6079 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006080
6081 spec->stream_name_analog = "ALC260 Analog";
6082 spec->stream_analog_playback = &alc260_pcm_analog_playback;
6083 spec->stream_analog_capture = &alc260_pcm_analog_capture;
6084
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006085 spec->stream_name_digital = "ALC260 Digital";
6086 spec->stream_digital_playback = &alc260_pcm_digital_playback;
6087 spec->stream_digital_capture = &alc260_pcm_digital_capture;
6088
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006089 if (!spec->adc_nids && spec->input_mux) {
6090 /* check whether NID 0x04 is valid */
6091 unsigned int wcap = get_wcaps(codec, 0x04);
6092 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
6093 /* get type */
6094 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
6095 spec->adc_nids = alc260_adc_nids_alt;
6096 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
6097 } else {
6098 spec->adc_nids = alc260_adc_nids;
6099 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
6100 }
6101 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006102 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006103 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006104
Takashi Iwai2134ea42008-01-10 16:53:55 +01006105 spec->vmaster_nid = 0x08;
6106
Linus Torvalds1da177e2005-04-16 15:20:36 -07006107 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006108 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006109 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006110#ifdef CONFIG_SND_HDA_POWER_SAVE
6111 if (!spec->loopback.amplist)
6112 spec->loopback.amplist = alc260_loopbacks;
6113#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01006114 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006115
6116 return 0;
6117}
6118
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006119
Linus Torvalds1da177e2005-04-16 15:20:36 -07006120/*
6121 * ALC882 support
6122 *
6123 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
6124 * configuration. Each pin widget can choose any input DACs and a mixer.
6125 * Each ADC is connected from a mixer of all inputs. This makes possible
6126 * 6-channel independent captures.
6127 *
6128 * In addition, an independent DAC for the multi-playback (not used in this
6129 * driver yet).
6130 */
Kailang Yangdf694da2005-12-05 19:42:22 +01006131#define ALC882_DIGOUT_NID 0x06
6132#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07006133
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01006134static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07006135 { 8, NULL }
6136};
6137
6138static hda_nid_t alc882_dac_nids[4] = {
6139 /* front, rear, clfe, rear_surr */
6140 0x02, 0x03, 0x04, 0x05
6141};
6142
Kailang Yangdf694da2005-12-05 19:42:22 +01006143/* identical with ALC880 */
6144#define alc882_adc_nids alc880_adc_nids
6145#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07006146
Takashi Iwaie1406342008-02-11 18:32:32 +01006147static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
6148static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
6149
Linus Torvalds1da177e2005-04-16 15:20:36 -07006150/* input MUX */
6151/* FIXME: should be a matrix-type input source selection */
6152
6153static struct hda_input_mux alc882_capture_source = {
6154 .num_items = 4,
6155 .items = {
6156 { "Mic", 0x0 },
6157 { "Front Mic", 0x1 },
6158 { "Line", 0x2 },
6159 { "CD", 0x4 },
6160 },
6161};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006162
6163static struct hda_input_mux mb5_capture_source = {
6164 .num_items = 3,
6165 .items = {
6166 { "Mic", 0x1 },
6167 { "Line", 0x2 },
6168 { "CD", 0x4 },
6169 },
6170};
6171
Kailang Yangdf694da2005-12-05 19:42:22 +01006172/*
Kailang Yang272a5272007-05-14 11:00:38 +02006173 * 2ch mode
6174 */
6175static struct hda_verb alc882_3ST_ch2_init[] = {
6176 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6177 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6178 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6179 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6180 { } /* end */
6181};
6182
6183/*
6184 * 6ch mode
6185 */
6186static struct hda_verb alc882_3ST_ch6_init[] = {
6187 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6188 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6189 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6190 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6191 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6192 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6193 { } /* end */
6194};
6195
6196static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
6197 { 2, alc882_3ST_ch2_init },
6198 { 6, alc882_3ST_ch6_init },
6199};
6200
6201/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006202 * 6ch mode
6203 */
6204static struct hda_verb alc882_sixstack_ch6_init[] = {
6205 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6206 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6207 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6208 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6209 { } /* end */
6210};
6211
6212/*
6213 * 8ch mode
6214 */
6215static struct hda_verb alc882_sixstack_ch8_init[] = {
6216 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6217 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6218 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6219 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6220 { } /* end */
6221};
6222
6223static struct hda_channel_mode alc882_sixstack_modes[2] = {
6224 { 6, alc882_sixstack_ch6_init },
6225 { 8, alc882_sixstack_ch8_init },
6226};
6227
Takashi Iwai87350ad2007-08-16 18:19:38 +02006228/*
6229 * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
6230 */
6231
6232/*
6233 * 2ch mode
6234 */
6235static struct hda_verb alc885_mbp_ch2_init[] = {
6236 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6237 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6238 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6239 { } /* end */
6240};
6241
6242/*
6243 * 6ch mode
6244 */
6245static struct hda_verb alc885_mbp_ch6_init[] = {
6246 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6247 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6248 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6249 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6250 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6251 { } /* end */
6252};
6253
6254static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
6255 { 2, alc885_mbp_ch2_init },
6256 { 6, alc885_mbp_ch6_init },
6257};
6258
6259
Linus Torvalds1da177e2005-04-16 15:20:36 -07006260/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6261 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6262 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01006263static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02006264 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006265 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006266 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006267 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006268 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6269 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006270 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6271 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006272 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006273 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006274 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6275 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6276 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6277 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6278 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6279 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006280 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006281 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6282 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006283 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006284 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006285 { } /* end */
6286};
6287
Takashi Iwai87350ad2007-08-16 18:19:38 +02006288static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01006289 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6290 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
6291 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
6292 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
6293 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6294 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006295 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
6296 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01006297 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006298 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
6299 { } /* end */
6300};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006301
6302static struct snd_kcontrol_new alc885_mb5_mixer[] = {
6303 HDA_CODEC_VOLUME("Front Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
6304 HDA_BIND_MUTE ("Front Playback Switch", 0x0d, 0x02, HDA_INPUT),
6305 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6306 HDA_BIND_MUTE ("Line-Out Playback Switch", 0x0c, 0x02, HDA_INPUT),
6307 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6308 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6309 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
6310 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
6311 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
6312 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0x00, HDA_INPUT),
6313 { } /* end */
6314};
Kailang Yangbdd148a2007-05-08 15:19:08 +02006315static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
6316 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6317 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6318 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6319 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6320 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6321 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6322 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6323 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6324 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02006325 { } /* end */
6326};
6327
Kailang Yang272a5272007-05-14 11:00:38 +02006328static struct snd_kcontrol_new alc882_targa_mixer[] = {
6329 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6330 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6331 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6332 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6333 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6334 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6335 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6336 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6337 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006338 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006339 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6340 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006341 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006342 { } /* end */
6343};
6344
6345/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
6346 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
6347 */
6348static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
6349 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6350 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6351 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6352 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
6353 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6354 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6355 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6356 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6357 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
6358 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
6359 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6360 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006361 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006362 { } /* end */
6363};
6364
Takashi Iwai914759b2007-09-06 14:52:04 +02006365static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
6366 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6367 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6368 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6369 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6370 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6371 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6372 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6373 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6374 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6375 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02006376 { } /* end */
6377};
6378
Kailang Yangdf694da2005-12-05 19:42:22 +01006379static struct snd_kcontrol_new alc882_chmode_mixer[] = {
6380 {
6381 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6382 .name = "Channel Mode",
6383 .info = alc_ch_mode_info,
6384 .get = alc_ch_mode_get,
6385 .put = alc_ch_mode_put,
6386 },
6387 { } /* end */
6388};
6389
Linus Torvalds1da177e2005-04-16 15:20:36 -07006390static struct hda_verb alc882_init_verbs[] = {
6391 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006392 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6393 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6394 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006395 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006396 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6397 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6398 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006399 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006400 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6401 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6402 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006403 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006404 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6405 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6406 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006407
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006408 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006409 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006410 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006411 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006412 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006413 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006414 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006415 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006416 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006417 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006418 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006419 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006420 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006421 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006422 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006423 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006424 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006425 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006426 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6427 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006428 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006429 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6430 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006431 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006432 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6433 /* Line-2 In: Headphone output (output 0 - 0x0c) */
6434 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6435 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6436 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006437 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006438 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006439
6440 /* FIXME: use matrix-type input source selection */
6441 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6442 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02006443 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6444 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6445 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6446 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006447 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006448 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6449 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6450 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6451 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006452 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006453 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6454 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6455 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6456 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6457 /* ADC1: mute amp left and right */
6458 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006459 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02006460 /* ADC2: mute amp left and right */
6461 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006462 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02006463 /* ADC3: mute amp left and right */
6464 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006465 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006466
6467 { }
6468};
6469
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006470static struct hda_verb alc882_eapd_verbs[] = {
6471 /* change to EAPD mode */
6472 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006473 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006474 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006475};
6476
Tobin Davis9102cd12006-12-15 10:02:12 +01006477/* Mac Pro test */
6478static struct snd_kcontrol_new alc882_macpro_mixer[] = {
6479 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6480 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6481 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
6482 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
6483 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006484 /* FIXME: this looks suspicious...
Tobin Davis9102cd12006-12-15 10:02:12 +01006485 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
6486 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006487 */
Tobin Davis9102cd12006-12-15 10:02:12 +01006488 { } /* end */
6489};
6490
6491static struct hda_verb alc882_macpro_init_verbs[] = {
6492 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6493 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6494 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6495 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6496 /* Front Pin: output 0 (0x0c) */
6497 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6498 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6499 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6500 /* Front Mic pin: input vref at 80% */
6501 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6502 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6503 /* Speaker: output */
6504 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6505 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6506 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
6507 /* Headphone output (output 0 - 0x0c) */
6508 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6509 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6510 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6511
6512 /* FIXME: use matrix-type input source selection */
6513 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6514 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6515 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6516 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6517 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6518 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6519 /* Input mixer2 */
6520 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6521 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6522 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6523 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6524 /* Input mixer3 */
6525 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6526 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6527 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6528 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6529 /* ADC1: mute amp left and right */
6530 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6531 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6532 /* ADC2: mute amp left and right */
6533 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6534 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6535 /* ADC3: mute amp left and right */
6536 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6537 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6538
6539 { }
6540};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006541
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006542/* Macbook 5,1 */
6543static struct hda_verb alc885_mb5_init_verbs[] = {
6544 /* Front mixer */
6545 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6546 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6547 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6548 /* LineOut mixer */
6549 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6550 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6551 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6552 /* Front Pin: output 0 (0x0d) */
6553 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
6554 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6555 {0x18, AC_VERB_SET_CONNECT_SEL, 0x01},
6556 /* HP Pin: output 0 (0x0c) */
6557 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6558 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6559 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6560 /* Front Mic pin: input vref at 80% */
6561 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6562 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6563 /* Line In pin */
6564 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6565 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6566
6567 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6568 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6569 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6570 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6571 { }
6572};
6573
Takashi Iwai87350ad2007-08-16 18:19:38 +02006574/* Macbook Pro rev3 */
6575static struct hda_verb alc885_mbp3_init_verbs[] = {
6576 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6577 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6578 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6579 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6580 /* Rear mixer */
6581 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6582 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6583 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6584 /* Front Pin: output 0 (0x0c) */
6585 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6586 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6587 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6588 /* HP Pin: output 0 (0x0d) */
6589 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
6590 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6591 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6592 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6593 /* Mic (rear) pin: input vref at 80% */
6594 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6595 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6596 /* Front Mic pin: input vref at 80% */
6597 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6598 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6599 /* Line In pin: use output 1 when in LineOut mode */
6600 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6601 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6602 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
6603
6604 /* FIXME: use matrix-type input source selection */
6605 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6606 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6607 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6608 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6609 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6610 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6611 /* Input mixer2 */
6612 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6613 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6614 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6615 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6616 /* Input mixer3 */
6617 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6618 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6619 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6620 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6621 /* ADC1: mute amp left and right */
6622 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6623 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6624 /* ADC2: mute amp left and right */
6625 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6626 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6627 /* ADC3: mute amp left and right */
6628 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6629 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6630
6631 { }
6632};
6633
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006634/* iMac 24 mixer. */
6635static struct snd_kcontrol_new alc885_imac24_mixer[] = {
6636 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6637 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
6638 { } /* end */
6639};
6640
6641/* iMac 24 init verbs. */
6642static struct hda_verb alc885_imac24_init_verbs[] = {
6643 /* Internal speakers: output 0 (0x0c) */
6644 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6645 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6646 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6647 /* Internal speakers: output 0 (0x0c) */
6648 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6649 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6650 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
6651 /* Headphone: output 0 (0x0c) */
6652 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6653 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6654 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6655 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6656 /* Front Mic: input vref at 80% */
6657 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6658 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6659 { }
6660};
6661
6662/* Toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006663static void alc885_imac24_automute_init_hook(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006664{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006665 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006666
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006667 spec->autocfg.hp_pins[0] = 0x14;
6668 spec->autocfg.speaker_pins[0] = 0x18;
6669 spec->autocfg.speaker_pins[1] = 0x1a;
6670 alc_automute_amp(codec);
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006671}
6672
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006673static void alc885_mbp3_init_hook(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006674{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006675 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006676
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006677 spec->autocfg.hp_pins[0] = 0x15;
6678 spec->autocfg.speaker_pins[0] = 0x14;
6679 alc_automute_amp(codec);
Takashi Iwai87350ad2007-08-16 18:19:38 +02006680}
6681
6682
Kailang Yang272a5272007-05-14 11:00:38 +02006683static struct hda_verb alc882_targa_verbs[] = {
6684 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6685 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6686
6687 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6688 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006689
Kailang Yang272a5272007-05-14 11:00:38 +02006690 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6691 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6692 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6693
6694 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6695 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
6696 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
6697 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
6698 { } /* end */
6699};
6700
6701/* toggle speaker-output according to the hp-jack state */
6702static void alc882_targa_automute(struct hda_codec *codec)
6703{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006704 struct alc_spec *spec = codec->spec;
6705 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006706 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006707 spec->jack_present ? 1 : 3);
6708}
6709
6710static void alc882_targa_init_hook(struct hda_codec *codec)
6711{
6712 struct alc_spec *spec = codec->spec;
6713
6714 spec->autocfg.hp_pins[0] = 0x14;
6715 spec->autocfg.speaker_pins[0] = 0x1b;
6716 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02006717}
6718
6719static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
6720{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006721 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02006722 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02006723}
6724
6725static struct hda_verb alc882_asus_a7j_verbs[] = {
6726 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6727 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6728
6729 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6730 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6731 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006732
Kailang Yang272a5272007-05-14 11:00:38 +02006733 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6734 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6735 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6736
6737 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6738 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6739 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6740 { } /* end */
6741};
6742
Takashi Iwai914759b2007-09-06 14:52:04 +02006743static struct hda_verb alc882_asus_a7m_verbs[] = {
6744 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6745 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6746
6747 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6748 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6749 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006750
Takashi Iwai914759b2007-09-06 14:52:04 +02006751 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6752 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6753 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6754
6755 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6756 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6757 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6758 { } /* end */
6759};
6760
Tobin Davis9102cd12006-12-15 10:02:12 +01006761static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
6762{
6763 unsigned int gpiostate, gpiomask, gpiodir;
6764
6765 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
6766 AC_VERB_GET_GPIO_DATA, 0);
6767
6768 if (!muted)
6769 gpiostate |= (1 << pin);
6770 else
6771 gpiostate &= ~(1 << pin);
6772
6773 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
6774 AC_VERB_GET_GPIO_MASK, 0);
6775 gpiomask |= (1 << pin);
6776
6777 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
6778 AC_VERB_GET_GPIO_DIRECTION, 0);
6779 gpiodir |= (1 << pin);
6780
6781
6782 snd_hda_codec_write(codec, codec->afg, 0,
6783 AC_VERB_SET_GPIO_MASK, gpiomask);
6784 snd_hda_codec_write(codec, codec->afg, 0,
6785 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
6786
6787 msleep(1);
6788
6789 snd_hda_codec_write(codec, codec->afg, 0,
6790 AC_VERB_SET_GPIO_DATA, gpiostate);
6791}
6792
Takashi Iwai7debbe52007-08-16 15:01:03 +02006793/* set up GPIO at initialization */
6794static void alc885_macpro_init_hook(struct hda_codec *codec)
6795{
6796 alc882_gpio_mute(codec, 0, 0);
6797 alc882_gpio_mute(codec, 1, 0);
6798}
6799
6800/* set up GPIO and update auto-muting at initialization */
6801static void alc885_imac24_init_hook(struct hda_codec *codec)
6802{
6803 alc885_macpro_init_hook(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006804 alc885_imac24_automute_init_hook(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02006805}
6806
Kailang Yangdf694da2005-12-05 19:42:22 +01006807/*
6808 * generic initialization of ADC, input mixers and output mixers
6809 */
6810static struct hda_verb alc882_auto_init_verbs[] = {
6811 /*
6812 * Unmute ADC0-2 and set the default input to mic-in
6813 */
6814 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6815 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6816 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6817 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6818 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6819 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6820
Takashi Iwaicb53c622007-08-10 17:21:45 +02006821 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01006822 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006823 * Note: PASD motherboards uses the Line In 2 as the input for
6824 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006825 */
6826 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006827 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6828 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6829 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6830 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6831 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006832
6833 /*
6834 * Set up output mixers (0x0c - 0x0f)
6835 */
6836 /* set vol=0 to output mixers */
6837 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6838 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6839 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6840 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6841 /* set up input amps for analog loopback */
6842 /* Amp Indices: DAC = 0, mixer = 1 */
6843 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6844 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6845 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6846 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6847 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6848 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6849 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6850 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6851 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6852 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6853
6854 /* FIXME: use matrix-type input source selection */
6855 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6856 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6857 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6858 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6859 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6860 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6861 /* Input mixer2 */
6862 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6863 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6864 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6865 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6866 /* Input mixer3 */
6867 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6868 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6869 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6870 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6871
6872 { }
6873};
6874
Takashi Iwaicb53c622007-08-10 17:21:45 +02006875#ifdef CONFIG_SND_HDA_POWER_SAVE
6876#define alc882_loopbacks alc880_loopbacks
6877#endif
6878
Kailang Yangdf694da2005-12-05 19:42:22 +01006879/* pcm configuration: identiacal with ALC880 */
6880#define alc882_pcm_analog_playback alc880_pcm_analog_playback
6881#define alc882_pcm_analog_capture alc880_pcm_analog_capture
6882#define alc882_pcm_digital_playback alc880_pcm_digital_playback
6883#define alc882_pcm_digital_capture alc880_pcm_digital_capture
6884
6885/*
6886 * configuration and preset
6887 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006888static const char *alc882_models[ALC882_MODEL_LAST] = {
6889 [ALC882_3ST_DIG] = "3stack-dig",
6890 [ALC882_6ST_DIG] = "6stack-dig",
6891 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02006892 [ALC882_W2JC] = "w2jc",
Takashi Iwai0438a002007-09-06 14:54:11 +02006893 [ALC882_TARGA] = "targa",
6894 [ALC882_ASUS_A7J] = "asus-a7j",
6895 [ALC882_ASUS_A7M] = "asus-a7m",
Tobin Davis9102cd12006-12-15 10:02:12 +01006896 [ALC885_MACPRO] = "macpro",
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006897 [ALC885_MB5] = "mb5",
Takashi Iwai87350ad2007-08-16 18:19:38 +02006898 [ALC885_MBP3] = "mbp3",
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006899 [ALC885_IMAC24] = "imac24",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006900 [ALC882_AUTO] = "auto",
6901};
6902
6903static struct snd_pci_quirk alc882_cfg_tbl[] = {
6904 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02006905 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Kailang Yangac8842a2007-09-20 12:51:39 +02006906 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
Takashi Iwai914759b2007-09-06 14:52:04 +02006907 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006908 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Claudio Matsuokac5d9f1c2007-07-19 23:18:32 +02006909 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
Tobin Davis7b9470d2006-12-28 13:56:48 +01006910 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006911 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Jiang zhe44447042008-01-28 12:28:24 +01006912 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006913 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
6914 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
6915 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yangdf694da2005-12-05 19:42:22 +01006916 {}
6917};
6918
6919static struct alc_config_preset alc882_presets[] = {
6920 [ALC882_3ST_DIG] = {
6921 .mixers = { alc882_base_mixer },
6922 .init_verbs = { alc882_init_verbs },
6923 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6924 .dac_nids = alc882_dac_nids,
6925 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006926 .dig_in_nid = ALC882_DIGIN_NID,
6927 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6928 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006929 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01006930 .input_mux = &alc882_capture_source,
6931 },
6932 [ALC882_6ST_DIG] = {
6933 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6934 .init_verbs = { alc882_init_verbs },
6935 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6936 .dac_nids = alc882_dac_nids,
6937 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006938 .dig_in_nid = ALC882_DIGIN_NID,
6939 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6940 .channel_mode = alc882_sixstack_modes,
6941 .input_mux = &alc882_capture_source,
6942 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006943 [ALC882_ARIMA] = {
6944 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6945 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
6946 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6947 .dac_nids = alc882_dac_nids,
6948 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6949 .channel_mode = alc882_sixstack_modes,
6950 .input_mux = &alc882_capture_source,
6951 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02006952 [ALC882_W2JC] = {
6953 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
6954 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6955 alc880_gpio1_init_verbs },
6956 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6957 .dac_nids = alc882_dac_nids,
6958 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6959 .channel_mode = alc880_threestack_modes,
6960 .need_dac_fix = 1,
6961 .input_mux = &alc882_capture_source,
6962 .dig_out_nid = ALC882_DIGOUT_NID,
6963 },
Takashi Iwai87350ad2007-08-16 18:19:38 +02006964 [ALC885_MBP3] = {
6965 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
6966 .init_verbs = { alc885_mbp3_init_verbs,
6967 alc880_gpio1_init_verbs },
6968 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6969 .dac_nids = alc882_dac_nids,
6970 .channel_mode = alc885_mbp_6ch_modes,
6971 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
6972 .input_mux = &alc882_capture_source,
6973 .dig_out_nid = ALC882_DIGOUT_NID,
6974 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006975 .unsol_event = alc_automute_amp_unsol_event,
6976 .init_hook = alc885_mbp3_init_hook,
Takashi Iwai87350ad2007-08-16 18:19:38 +02006977 },
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006978 [ALC885_MB5] = {
6979 .mixers = { alc885_mb5_mixer },
6980 .init_verbs = { alc885_mb5_init_verbs,
6981 alc880_gpio1_init_verbs },
6982 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6983 .dac_nids = alc882_dac_nids,
6984 .channel_mode = alc885_mbp_6ch_modes,
6985 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
6986 .input_mux = &mb5_capture_source,
6987 .dig_out_nid = ALC882_DIGOUT_NID,
6988 .dig_in_nid = ALC882_DIGIN_NID,
6989 },
Tobin Davis9102cd12006-12-15 10:02:12 +01006990 [ALC885_MACPRO] = {
6991 .mixers = { alc882_macpro_mixer },
6992 .init_verbs = { alc882_macpro_init_verbs },
6993 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6994 .dac_nids = alc882_dac_nids,
6995 .dig_out_nid = ALC882_DIGOUT_NID,
6996 .dig_in_nid = ALC882_DIGIN_NID,
6997 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6998 .channel_mode = alc882_ch_modes,
6999 .input_mux = &alc882_capture_source,
Takashi Iwai7debbe52007-08-16 15:01:03 +02007000 .init_hook = alc885_macpro_init_hook,
Tobin Davis9102cd12006-12-15 10:02:12 +01007001 },
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007002 [ALC885_IMAC24] = {
7003 .mixers = { alc885_imac24_mixer },
7004 .init_verbs = { alc885_imac24_init_verbs },
7005 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7006 .dac_nids = alc882_dac_nids,
7007 .dig_out_nid = ALC882_DIGOUT_NID,
7008 .dig_in_nid = ALC882_DIGIN_NID,
7009 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
7010 .channel_mode = alc882_ch_modes,
7011 .input_mux = &alc882_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007012 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai7debbe52007-08-16 15:01:03 +02007013 .init_hook = alc885_imac24_init_hook,
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007014 },
Kailang Yang272a5272007-05-14 11:00:38 +02007015 [ALC882_TARGA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007016 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Kailang Yang272a5272007-05-14 11:00:38 +02007017 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
7018 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7019 .dac_nids = alc882_dac_nids,
7020 .dig_out_nid = ALC882_DIGOUT_NID,
7021 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
7022 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01007023 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02007024 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
7025 .channel_mode = alc882_3ST_6ch_modes,
7026 .need_dac_fix = 1,
7027 .input_mux = &alc882_capture_source,
7028 .unsol_event = alc882_targa_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007029 .init_hook = alc882_targa_init_hook,
Kailang Yang272a5272007-05-14 11:00:38 +02007030 },
7031 [ALC882_ASUS_A7J] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007032 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Kailang Yang272a5272007-05-14 11:00:38 +02007033 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
7034 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7035 .dac_nids = alc882_dac_nids,
7036 .dig_out_nid = ALC882_DIGOUT_NID,
7037 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
7038 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01007039 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02007040 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
7041 .channel_mode = alc882_3ST_6ch_modes,
7042 .need_dac_fix = 1,
7043 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02007044 },
Takashi Iwai914759b2007-09-06 14:52:04 +02007045 [ALC882_ASUS_A7M] = {
7046 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
7047 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
7048 alc880_gpio1_init_verbs,
7049 alc882_asus_a7m_verbs },
7050 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7051 .dac_nids = alc882_dac_nids,
7052 .dig_out_nid = ALC882_DIGOUT_NID,
7053 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
7054 .channel_mode = alc880_threestack_modes,
7055 .need_dac_fix = 1,
7056 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02007057 },
Kailang Yangdf694da2005-12-05 19:42:22 +01007058};
7059
7060
7061/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02007062 * Pin config fixes
7063 */
Kailang Yangea1fb292008-08-26 12:58:38 +02007064enum {
Takashi Iwaif95474e2007-07-10 00:47:43 +02007065 PINFIX_ABIT_AW9D_MAX
7066};
7067
7068static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
7069 { 0x15, 0x01080104 }, /* side */
7070 { 0x16, 0x01011012 }, /* rear */
7071 { 0x17, 0x01016011 }, /* clfe */
7072 { }
7073};
7074
7075static const struct alc_pincfg *alc882_pin_fixes[] = {
7076 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
7077};
7078
7079static struct snd_pci_quirk alc882_pinfix_tbl[] = {
7080 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
7081 {}
7082};
7083
7084/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007085 * BIOS auto configuration
7086 */
7087static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
7088 hda_nid_t nid, int pin_type,
7089 int dac_idx)
7090{
7091 /* set as output */
7092 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007093 int idx;
7094
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007095 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01007096 if (spec->multiout.dac_nids[dac_idx] == 0x25)
7097 idx = 4;
7098 else
7099 idx = spec->multiout.dac_nids[dac_idx] - 2;
Kailang Yangdf694da2005-12-05 19:42:22 +01007100 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
7101
7102}
7103
7104static void alc882_auto_init_multi_out(struct hda_codec *codec)
7105{
7106 struct alc_spec *spec = codec->spec;
7107 int i;
7108
7109 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007110 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007111 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01007112 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007113 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007114 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01007115 }
7116}
7117
7118static void alc882_auto_init_hp_out(struct hda_codec *codec)
7119{
7120 struct alc_spec *spec = codec->spec;
7121 hda_nid_t pin;
7122
Takashi Iwaieb06ed82006-09-20 17:10:27 +02007123 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007124 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007125 /* use dac 0 */
7126 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007127 pin = spec->autocfg.speaker_pins[0];
7128 if (pin)
7129 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01007130}
7131
7132#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
7133#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
7134
7135static void alc882_auto_init_analog_input(struct hda_codec *codec)
7136{
7137 struct alc_spec *spec = codec->spec;
7138 int i;
7139
7140 for (i = 0; i < AUTO_PIN_LAST; i++) {
7141 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai7194cae2008-03-06 16:58:17 +01007142 if (!nid)
7143 continue;
Takashi Iwai23f0c042009-02-26 13:03:58 +01007144 alc_set_input_pin(codec, nid, AUTO_PIN_FRONT_MIC /*i*/);
Takashi Iwai7194cae2008-03-06 16:58:17 +01007145 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
7146 snd_hda_codec_write(codec, nid, 0,
7147 AC_VERB_SET_AMP_GAIN_MUTE,
7148 AMP_OUT_MUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01007149 }
7150}
7151
Takashi Iwaif511b012008-08-15 16:46:42 +02007152static void alc882_auto_init_input_src(struct hda_codec *codec)
7153{
7154 struct alc_spec *spec = codec->spec;
Takashi Iwaif511b012008-08-15 16:46:42 +02007155 int c;
7156
7157 for (c = 0; c < spec->num_adc_nids; c++) {
7158 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
7159 hda_nid_t nid = spec->capsrc_nids[c];
Herton Ronaldo Krzesinskib98b7b32009-01-29 13:18:31 -02007160 unsigned int mux_idx;
7161 const struct hda_input_mux *imux;
Takashi Iwaif511b012008-08-15 16:46:42 +02007162 int conns, mute, idx, item;
7163
7164 conns = snd_hda_get_connections(codec, nid, conn_list,
7165 ARRAY_SIZE(conn_list));
7166 if (conns < 0)
7167 continue;
Herton Ronaldo Krzesinskib98b7b32009-01-29 13:18:31 -02007168 mux_idx = c >= spec->num_mux_defs ? 0 : c;
7169 imux = &spec->input_mux[mux_idx];
Takashi Iwaif511b012008-08-15 16:46:42 +02007170 for (idx = 0; idx < conns; idx++) {
7171 /* if the current connection is the selected one,
7172 * unmute it as default - otherwise mute it
7173 */
7174 mute = AMP_IN_MUTE(idx);
7175 for (item = 0; item < imux->num_items; item++) {
7176 if (imux->items[item].index == idx) {
7177 if (spec->cur_mux[c] == item)
7178 mute = AMP_IN_UNMUTE(idx);
7179 break;
7180 }
7181 }
Herton Ronaldo Krzesinskib98b7b32009-01-29 13:18:31 -02007182 /* check if we have a selector or mixer
7183 * we could check for the widget type instead, but
7184 * just check for Amp-In presence (in case of mixer
7185 * without amp-in there is something wrong, this
7186 * function shouldn't be used or capsrc nid is wrong)
7187 */
7188 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
7189 snd_hda_codec_write(codec, nid, 0,
7190 AC_VERB_SET_AMP_GAIN_MUTE,
7191 mute);
7192 else if (mute != AMP_IN_MUTE(idx))
7193 snd_hda_codec_write(codec, nid, 0,
7194 AC_VERB_SET_CONNECT_SEL,
7195 idx);
Takashi Iwaif511b012008-08-15 16:46:42 +02007196 }
7197 }
7198}
7199
Takashi Iwai776e1842007-08-29 15:07:11 +02007200/* add mic boosts if needed */
7201static int alc_auto_add_mic_boost(struct hda_codec *codec)
7202{
7203 struct alc_spec *spec = codec->spec;
7204 int err;
7205 hda_nid_t nid;
7206
7207 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01007208 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02007209 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7210 "Mic Boost",
7211 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
7212 if (err < 0)
7213 return err;
7214 }
7215 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01007216 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02007217 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7218 "Front Mic Boost",
7219 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
7220 if (err < 0)
7221 return err;
7222 }
7223 return 0;
7224}
7225
Kailang Yangdf694da2005-12-05 19:42:22 +01007226/* almost identical with ALC880 parser... */
7227static int alc882_parse_auto_config(struct hda_codec *codec)
7228{
7229 struct alc_spec *spec = codec->spec;
7230 int err = alc880_parse_auto_config(codec);
7231
7232 if (err < 0)
7233 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02007234 else if (!err)
7235 return 0; /* no config found */
7236
7237 err = alc_auto_add_mic_boost(codec);
7238 if (err < 0)
7239 return err;
7240
7241 /* hack - override the init verbs */
7242 spec->init_verbs[0] = alc882_auto_init_verbs;
7243
7244 return 1; /* config found */
Kailang Yangdf694da2005-12-05 19:42:22 +01007245}
7246
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007247/* additional initialization for auto-configuration model */
7248static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01007249{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007250 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007251 alc882_auto_init_multi_out(codec);
7252 alc882_auto_init_hp_out(codec);
7253 alc882_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02007254 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007255 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02007256 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01007257}
7258
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007259static int patch_alc883(struct hda_codec *codec); /* called in patch_alc882() */
7260
Linus Torvalds1da177e2005-04-16 15:20:36 -07007261static int patch_alc882(struct hda_codec *codec)
7262{
7263 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007264 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007265
Takashi Iwaie560d8d2005-09-09 14:21:46 +02007266 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007267 if (spec == NULL)
7268 return -ENOMEM;
7269
Linus Torvalds1da177e2005-04-16 15:20:36 -07007270 codec->spec = spec;
7271
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007272 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
7273 alc882_models,
7274 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007275
Kailang Yangdf694da2005-12-05 19:42:22 +01007276 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01007277 /* Pick up systems that don't supply PCI SSID */
7278 switch (codec->subsystem_id) {
7279 case 0x106b0c00: /* Mac Pro */
7280 board_config = ALC885_MACPRO;
7281 break;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007282 case 0x106b1000: /* iMac 24 */
Peter Korsgaardf3911c52008-09-27 09:13:45 +02007283 case 0x106b2800: /* AppleTV */
Mark Eggleston3077e442009-01-31 17:57:54 +01007284 case 0x106b3e00: /* iMac 24 Aluminium */
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007285 board_config = ALC885_IMAC24;
7286 break;
Luke Yelavich2d466382009-02-23 13:00:33 +11007287 case 0x106b00a0: /* MacBookPro3,1 - Another revision */
Takashi Iwaic7e07572008-06-26 14:42:51 +02007288 case 0x106b00a1: /* Macbook (might be wrong - PCI SSID?) */
David Woodhouse9c95c432008-09-18 13:37:13 -07007289 case 0x106b00a4: /* MacbookPro4,1 */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007290 case 0x106b2c00: /* Macbook Pro rev3 */
Takashi Iwaic7e07572008-06-26 14:42:51 +02007291 case 0x106b3600: /* Macbook 3.1 */
Luke Yelavich2a884642009-01-28 15:58:38 +11007292 case 0x106b3800: /* MacbookPro4,1 - latter revision */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007293 board_config = ALC885_MBP3;
7294 break;
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007295 case 0x106b3f00: /* Macbook 5,1 */
7296 board_config = ALC885_MB5;
7297 break;
Tobin Davis081d17c2007-02-15 17:46:18 +01007298 default:
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007299 /* ALC889A is handled better as ALC888-compatible */
Clive Messer669faba2008-09-30 15:49:13 +02007300 if (codec->revision_id == 0x100101 ||
7301 codec->revision_id == 0x100103) {
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007302 alc_free(codec);
7303 return patch_alc883(codec);
7304 }
Tobin Davis081d17c2007-02-15 17:46:18 +01007305 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
7306 "trying auto-probe from BIOS...\n");
7307 board_config = ALC882_AUTO;
7308 }
Kailang Yangdf694da2005-12-05 19:42:22 +01007309 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007310
Takashi Iwaif95474e2007-07-10 00:47:43 +02007311 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
7312
Kailang Yangdf694da2005-12-05 19:42:22 +01007313 if (board_config == ALC882_AUTO) {
7314 /* automatic parse from the BIOS config */
7315 err = alc882_parse_auto_config(codec);
7316 if (err < 0) {
7317 alc_free(codec);
7318 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007319 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007320 printk(KERN_INFO
7321 "hda_codec: Cannot set up configuration "
7322 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007323 board_config = ALC882_3ST_DIG;
7324 }
7325 }
7326
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09007327 err = snd_hda_attach_beep_device(codec, 0x1);
7328 if (err < 0) {
7329 alc_free(codec);
7330 return err;
7331 }
7332
Kailang Yangdf694da2005-12-05 19:42:22 +01007333 if (board_config != ALC882_AUTO)
7334 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007335
Kailang Yang2f893282008-05-27 12:14:47 +02007336 if (codec->vendor_id == 0x10ec0885) {
7337 spec->stream_name_analog = "ALC885 Analog";
7338 spec->stream_name_digital = "ALC885 Digital";
7339 } else {
7340 spec->stream_name_analog = "ALC882 Analog";
7341 spec->stream_name_digital = "ALC882 Digital";
7342 }
7343
Kailang Yangdf694da2005-12-05 19:42:22 +01007344 spec->stream_analog_playback = &alc882_pcm_analog_playback;
7345 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01007346 /* FIXME: setup DAC5 */
7347 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
7348 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007349
Kailang Yangdf694da2005-12-05 19:42:22 +01007350 spec->stream_digital_playback = &alc882_pcm_digital_playback;
7351 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007352
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007353 spec->capture_style = CAPT_MIX; /* matrix-style capture */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007354 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01007355 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01007356 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007357 /* get type */
7358 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01007359 if (wcap != AC_WID_AUD_IN) {
7360 spec->adc_nids = alc882_adc_nids_alt;
7361 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
Takashi Iwaie1406342008-02-11 18:32:32 +01007362 spec->capsrc_nids = alc882_capsrc_nids_alt;
Kailang Yangdf694da2005-12-05 19:42:22 +01007363 } else {
7364 spec->adc_nids = alc882_adc_nids;
7365 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +01007366 spec->capsrc_nids = alc882_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +01007367 }
7368 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007369 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007370 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007371
Takashi Iwai2134ea42008-01-10 16:53:55 +01007372 spec->vmaster_nid = 0x0c;
7373
Linus Torvalds1da177e2005-04-16 15:20:36 -07007374 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01007375 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007376 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02007377#ifdef CONFIG_SND_HDA_POWER_SAVE
7378 if (!spec->loopback.amplist)
7379 spec->loopback.amplist = alc882_loopbacks;
7380#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01007381 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007382
7383 return 0;
7384}
7385
7386/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007387 * ALC883 support
7388 *
7389 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
7390 * configuration. Each pin widget can choose any input DACs and a mixer.
7391 * Each ADC is connected from a mixer of all inputs. This makes possible
7392 * 6-channel independent captures.
7393 *
7394 * In addition, an independent DAC for the multi-playback (not used in this
7395 * driver yet).
7396 */
7397#define ALC883_DIGOUT_NID 0x06
7398#define ALC883_DIGIN_NID 0x0a
7399
Wu Fengguang3ab90932008-11-17 09:51:09 +01007400#define ALC1200_DIGOUT_NID 0x10
7401
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007402static hda_nid_t alc883_dac_nids[4] = {
7403 /* front, rear, clfe, rear_surr */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01007404 0x02, 0x03, 0x04, 0x05
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007405};
7406
7407static hda_nid_t alc883_adc_nids[2] = {
7408 /* ADC1-2 */
7409 0x08, 0x09,
7410};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007411
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007412static hda_nid_t alc883_adc_nids_alt[1] = {
7413 /* ADC1 */
7414 0x08,
7415};
7416
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08007417static hda_nid_t alc883_adc_nids_rev[2] = {
7418 /* ADC2-1 */
7419 0x09, 0x08
7420};
7421
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007422#define alc889_adc_nids alc880_adc_nids
7423
Takashi Iwaie1406342008-02-11 18:32:32 +01007424static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 };
7425
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08007426static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
7427
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007428#define alc889_capsrc_nids alc882_capsrc_nids
7429
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007430/* input MUX */
7431/* FIXME: should be a matrix-type input source selection */
7432
7433static struct hda_input_mux alc883_capture_source = {
7434 .num_items = 4,
7435 .items = {
7436 { "Mic", 0x0 },
7437 { "Front Mic", 0x1 },
7438 { "Line", 0x2 },
7439 { "CD", 0x4 },
7440 },
7441};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007442
Jiang zhe17bba1b2008-06-04 12:11:07 +02007443static struct hda_input_mux alc883_3stack_6ch_intel = {
7444 .num_items = 4,
7445 .items = {
7446 { "Mic", 0x1 },
7447 { "Front Mic", 0x0 },
7448 { "Line", 0x2 },
7449 { "CD", 0x4 },
7450 },
7451};
7452
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007453static struct hda_input_mux alc883_lenovo_101e_capture_source = {
7454 .num_items = 2,
7455 .items = {
7456 { "Mic", 0x1 },
7457 { "Line", 0x2 },
7458 },
7459};
7460
Kailang Yang272a5272007-05-14 11:00:38 +02007461static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
7462 .num_items = 4,
7463 .items = {
7464 { "Mic", 0x0 },
7465 { "iMic", 0x1 },
7466 { "Line", 0x2 },
7467 { "CD", 0x4 },
7468 },
7469};
7470
Jiang zhefb97dc62008-03-06 11:07:11 +01007471static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
7472 .num_items = 2,
7473 .items = {
7474 { "Mic", 0x0 },
7475 { "Int Mic", 0x1 },
7476 },
7477};
7478
Kailang Yange2757d52008-08-26 13:17:46 +02007479static struct hda_input_mux alc883_lenovo_sky_capture_source = {
7480 .num_items = 3,
7481 .items = {
7482 { "Mic", 0x0 },
7483 { "Front Mic", 0x1 },
7484 { "Line", 0x4 },
7485 },
7486};
7487
7488static struct hda_input_mux alc883_asus_eee1601_capture_source = {
7489 .num_items = 2,
7490 .items = {
7491 { "Mic", 0x0 },
7492 { "Line", 0x2 },
7493 },
7494};
7495
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007496/*
7497 * 2ch mode
7498 */
7499static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
7500 { 2, NULL }
7501};
7502
7503/*
7504 * 2ch mode
7505 */
7506static struct hda_verb alc883_3ST_ch2_init[] = {
7507 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7508 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7509 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7510 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7511 { } /* end */
7512};
7513
7514/*
Tobin Davisb2011312007-09-17 12:45:11 +02007515 * 4ch mode
7516 */
7517static struct hda_verb alc883_3ST_ch4_init[] = {
7518 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7519 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7520 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7521 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7522 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7523 { } /* end */
7524};
7525
7526/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007527 * 6ch mode
7528 */
7529static struct hda_verb alc883_3ST_ch6_init[] = {
7530 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7531 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7532 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7533 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7534 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7535 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7536 { } /* end */
7537};
7538
Tobin Davisb2011312007-09-17 12:45:11 +02007539static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007540 { 2, alc883_3ST_ch2_init },
Tobin Davisb2011312007-09-17 12:45:11 +02007541 { 4, alc883_3ST_ch4_init },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007542 { 6, alc883_3ST_ch6_init },
7543};
7544
7545/*
Jiang zhe17bba1b2008-06-04 12:11:07 +02007546 * 2ch mode
7547 */
7548static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7549 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7550 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7551 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7552 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7553 { } /* end */
7554};
7555
7556/*
7557 * 4ch mode
7558 */
7559static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7560 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7561 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7562 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7563 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7564 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7565 { } /* end */
7566};
7567
7568/*
7569 * 6ch mode
7570 */
7571static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7572 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7573 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7574 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7575 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7576 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7577 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7578 { } /* end */
7579};
7580
7581static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7582 { 2, alc883_3ST_ch2_intel_init },
7583 { 4, alc883_3ST_ch4_intel_init },
7584 { 6, alc883_3ST_ch6_intel_init },
7585};
7586
7587/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007588 * 6ch mode
7589 */
7590static struct hda_verb alc883_sixstack_ch6_init[] = {
7591 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7592 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7593 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7594 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7595 { } /* end */
7596};
7597
7598/*
7599 * 8ch mode
7600 */
7601static struct hda_verb alc883_sixstack_ch8_init[] = {
7602 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7603 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7604 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7605 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7606 { } /* end */
7607};
7608
7609static struct hda_channel_mode alc883_sixstack_modes[2] = {
7610 { 6, alc883_sixstack_ch6_init },
7611 { 8, alc883_sixstack_ch8_init },
7612};
7613
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007614static struct hda_verb alc883_medion_eapd_verbs[] = {
7615 /* eanable EAPD on medion laptop */
7616 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7617 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7618 { }
7619};
7620
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007621/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7622 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7623 */
7624
7625static struct snd_kcontrol_new alc883_base_mixer[] = {
7626 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7627 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7628 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7629 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7630 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7631 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7632 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7633 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7634 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7635 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7636 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7637 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7638 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7639 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7640 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7641 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007642 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007643 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7644 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007645 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007646 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007647 { } /* end */
7648};
7649
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007650static struct snd_kcontrol_new alc883_mitac_mixer[] = {
7651 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7652 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7653 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7654 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7655 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7656 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7657 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7658 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7659 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7660 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7661 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7662 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7663 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007664 { } /* end */
7665};
7666
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007667static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007668 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7669 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7670 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7671 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7672 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7673 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7674 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7675 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7676 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7677 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01007678 { } /* end */
7679};
7680
Jiang zhefb97dc62008-03-06 11:07:11 +01007681static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
7682 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7683 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7684 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7685 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7686 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7687 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7688 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7689 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7690 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7691 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01007692 { } /* end */
7693};
7694
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007695static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
7696 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7697 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7698 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7699 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7700 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7701 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7702 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7703 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007704 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007705 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7706 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007707 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007708 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007709 { } /* end */
7710};
7711
7712static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
7713 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7714 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7715 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7716 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7717 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7718 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7719 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7720 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7721 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7722 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7723 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7724 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7725 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7726 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007727 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007728 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7729 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007730 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007731 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007732 { } /* end */
7733};
7734
Jiang zhe17bba1b2008-06-04 12:11:07 +02007735static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
7736 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7737 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7738 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7739 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7740 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7741 HDA_OUTPUT),
7742 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7743 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7744 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7745 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
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, 0x1, HDA_INPUT),
7751 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
7752 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7753 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7754 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7755 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02007756 { } /* end */
7757};
7758
Takashi Iwaid1d985f2006-11-23 19:27:12 +01007759static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02007760 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007761 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007762 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007763 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007764 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7765 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007766 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7767 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007768 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7769 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7770 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7771 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7772 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7773 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007774 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007775 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7776 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007777 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007778 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007779 { } /* end */
7780};
7781
Kailang Yangccc656c2006-10-17 12:32:26 +02007782static struct snd_kcontrol_new alc883_tagra_mixer[] = {
7783 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7784 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7785 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7786 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7787 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7788 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7789 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7790 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7791 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7792 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7793 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7794 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7795 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7796 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007797 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007798 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007799 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007800};
Kailang Yangccc656c2006-10-17 12:32:26 +02007801
7802static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
7803 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7804 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7805 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7806 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7807 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7808 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007809 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007810 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02007811 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7812 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7813 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007814 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007815};
Kailang Yangccc656c2006-10-17 12:32:26 +02007816
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007817static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
7818 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7819 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01007820 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7821 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007822 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7823 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7824 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7825 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007826 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007827};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007828
Kailang Yang272a5272007-05-14 11:00:38 +02007829static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
7830 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7831 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
7832 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7833 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7834 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7835 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7836 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7837 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7838 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007839 { } /* end */
7840};
7841
7842static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
7843 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7844 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7845 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7846 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7847 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7848 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7849 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7850 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7851 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007852 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02007853};
Kailang Yang272a5272007-05-14 11:00:38 +02007854
Tobin Davis2880a862007-08-07 11:50:26 +02007855static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02007856 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7857 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007858 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007859 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7860 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02007861 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7862 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7863 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007864 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02007865};
Tobin Davis2880a862007-08-07 11:50:26 +02007866
Kailang Yange2757d52008-08-26 13:17:46 +02007867static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
7868 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7869 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7870 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
7871 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
7872 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
7873 0x0d, 1, 0x0, HDA_OUTPUT),
7874 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
7875 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
7876 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
7877 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7878 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02007879 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7880 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7881 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7882 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7883 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7884 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7885 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7886 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7887 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7888 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02007889 { } /* end */
7890};
7891
7892static struct hda_bind_ctls alc883_bind_cap_vol = {
7893 .ops = &snd_hda_bind_vol,
7894 .values = {
7895 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
7896 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7897 0
7898 },
7899};
7900
7901static struct hda_bind_ctls alc883_bind_cap_switch = {
7902 .ops = &snd_hda_bind_sw,
7903 .values = {
7904 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
7905 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7906 0
7907 },
7908};
7909
7910static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
7911 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7912 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7913 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7914 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7915 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7916 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7917 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7918 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007919 { } /* end */
7920};
7921
7922static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02007923 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
7924 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
7925 {
7926 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7927 /* .name = "Capture Source", */
7928 .name = "Input Source",
7929 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01007930 .info = alc_mux_enum_info,
7931 .get = alc_mux_enum_get,
7932 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02007933 },
7934 { } /* end */
7935};
7936
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007937static struct snd_kcontrol_new alc883_chmode_mixer[] = {
7938 {
7939 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7940 .name = "Channel Mode",
7941 .info = alc_ch_mode_info,
7942 .get = alc_ch_mode_get,
7943 .put = alc_ch_mode_put,
7944 },
7945 { } /* end */
7946};
7947
7948static struct hda_verb alc883_init_verbs[] = {
7949 /* ADC1: mute amp left and right */
Kailang Yange2757d52008-08-26 13:17:46 +02007950 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007951 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7952 /* ADC2: mute amp left and right */
7953 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7954 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7955 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7956 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7957 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7958 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7959 /* Rear mixer */
7960 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7961 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7962 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7963 /* CLFE mixer */
7964 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7965 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7966 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7967 /* Side mixer */
7968 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7969 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7970 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7971
Takashi Iwaicb53c622007-08-10 17:21:45 +02007972 /* mute analog input loopbacks */
7973 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7974 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7975 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7976 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7977 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007978
7979 /* Front Pin: output 0 (0x0c) */
7980 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7981 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7982 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7983 /* Rear Pin: output 1 (0x0d) */
7984 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7985 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7986 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7987 /* CLFE Pin: output 2 (0x0e) */
7988 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7989 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7990 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7991 /* Side Pin: output 3 (0x0f) */
7992 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7993 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7994 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7995 /* Mic (rear) pin: input vref at 80% */
7996 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7997 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7998 /* Front Mic pin: input vref at 80% */
7999 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8000 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8001 /* Line In pin: input */
8002 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8003 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8004 /* Line-2 In: Headphone output (output 0 - 0x0c) */
8005 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8006 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8007 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8008 /* CD pin widget for input */
8009 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8010
8011 /* FIXME: use matrix-type input source selection */
8012 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8013 /* Input mixer2 */
8014 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yange2757d52008-08-26 13:17:46 +02008015 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8016 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8017 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008018 /* Input mixer3 */
8019 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yange2757d52008-08-26 13:17:46 +02008020 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8021 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8022 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008023 { }
8024};
8025
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008026/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008027static void alc883_mitac_init_hook(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008028{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008029 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008030
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008031 spec->autocfg.hp_pins[0] = 0x15;
8032 spec->autocfg.speaker_pins[0] = 0x14;
8033 spec->autocfg.speaker_pins[1] = 0x17;
8034 alc_automute_amp(codec);
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008035}
8036
8037/* auto-toggle front mic */
8038/*
8039static void alc883_mitac_mic_automute(struct hda_codec *codec)
8040{
8041 unsigned int present;
8042 unsigned char bits;
8043
8044 present = snd_hda_codec_read(codec, 0x18, 0,
8045 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8046 bits = present ? HDA_AMP_MUTE : 0;
8047 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
8048}
8049*/
8050
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008051static struct hda_verb alc883_mitac_verbs[] = {
8052 /* HP */
8053 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8054 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8055 /* Subwoofer */
8056 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8057 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8058
8059 /* enable unsolicited event */
8060 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8061 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
8062
8063 { } /* end */
8064};
8065
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008066static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008067 /* HP */
8068 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8069 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8070 /* Int speaker */
8071 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
8072 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8073
8074 /* enable unsolicited event */
8075 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008076 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01008077
8078 { } /* end */
8079};
8080
Jiang zhefb97dc62008-03-06 11:07:11 +01008081static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
8082 /* HP */
8083 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8084 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8085 /* Subwoofer */
8086 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8087 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8088
8089 /* enable unsolicited event */
8090 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8091
8092 { } /* end */
8093};
8094
Kailang Yangccc656c2006-10-17 12:32:26 +02008095static struct hda_verb alc883_tagra_verbs[] = {
8096 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8097 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8098
8099 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8100 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008101
Kailang Yangccc656c2006-10-17 12:32:26 +02008102 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8103 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8104 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8105
8106 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008107 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
8108 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
8109 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
Kailang Yangccc656c2006-10-17 12:32:26 +02008110
8111 { } /* end */
8112};
8113
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008114static struct hda_verb alc883_lenovo_101e_verbs[] = {
8115 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8116 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
8117 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
8118 { } /* end */
8119};
8120
Kailang Yang272a5272007-05-14 11:00:38 +02008121static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
8122 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8123 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8124 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8125 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8126 { } /* end */
8127};
8128
8129static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
8130 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8131 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8132 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8133 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
8134 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8135 { } /* end */
8136};
8137
Kailang Yang189609a2007-08-20 11:31:23 +02008138static struct hda_verb alc883_haier_w66_verbs[] = {
8139 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8140 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8141
8142 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8143
8144 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8145 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8146 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8147 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8148 { } /* end */
8149};
8150
Kailang Yange2757d52008-08-26 13:17:46 +02008151static struct hda_verb alc888_lenovo_sky_verbs[] = {
8152 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8153 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8154 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8155 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8156 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8157 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8158 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8159 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8160 { } /* end */
8161};
8162
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008163static struct hda_verb alc888_6st_dell_verbs[] = {
8164 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8165 { }
8166};
8167
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008168static void alc888_3st_hp_init_hook(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008169{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008170 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008171
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008172 spec->autocfg.hp_pins[0] = 0x1b;
8173 spec->autocfg.speaker_pins[0] = 0x14;
8174 spec->autocfg.speaker_pins[1] = 0x16;
8175 spec->autocfg.speaker_pins[2] = 0x18;
8176 alc_automute_amp(codec);
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008177}
8178
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008179static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008180 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01008181 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
8182 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008183 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008184 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008185};
8186
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008187/*
8188 * 2ch mode
8189 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008190static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008191 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8192 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8193 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
8194 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008195 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008196};
8197
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008198/*
8199 * 4ch mode
8200 */
8201static struct hda_verb alc888_3st_hp_4ch_init[] = {
8202 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8203 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8204 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8205 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8206 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8207 { } /* end */
8208};
8209
8210/*
8211 * 6ch mode
8212 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008213static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008214 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8215 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008216 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008217 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8218 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008219 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8220 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008221};
8222
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008223static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008224 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008225 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008226 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008227};
8228
Kailang Yang272a5272007-05-14 11:00:38 +02008229/* toggle front-jack and RCA according to the hp-jack state */
8230static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
8231{
8232 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008233
Kailang Yang272a5272007-05-14 11:00:38 +02008234 present = snd_hda_codec_read(codec, 0x1b, 0,
8235 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008236 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8237 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8238 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8239 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008240}
8241
8242/* toggle RCA according to the front-jack state */
8243static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
8244{
8245 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008246
Kailang Yang272a5272007-05-14 11:00:38 +02008247 present = snd_hda_codec_read(codec, 0x14, 0,
8248 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008249 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8250 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008251}
Takashi Iwai47fd8302007-08-10 17:11:07 +02008252
Kailang Yang272a5272007-05-14 11:00:38 +02008253static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
8254 unsigned int res)
8255{
8256 if ((res >> 26) == ALC880_HP_EVENT)
8257 alc888_lenovo_ms7195_front_automute(codec);
8258 if ((res >> 26) == ALC880_FRONT_EVENT)
8259 alc888_lenovo_ms7195_rca_automute(codec);
8260}
8261
8262static struct hda_verb alc883_medion_md2_verbs[] = {
8263 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8264 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8265
8266 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8267
8268 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8269 { } /* end */
8270};
8271
8272/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008273static void alc883_medion_md2_init_hook(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02008274{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008275 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008276
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008277 spec->autocfg.hp_pins[0] = 0x14;
8278 spec->autocfg.speaker_pins[0] = 0x15;
8279 alc_automute_amp(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02008280}
8281
Kailang Yangccc656c2006-10-17 12:32:26 +02008282/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008283#define alc883_tagra_init_hook alc882_targa_init_hook
8284#define alc883_tagra_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01008285
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008286static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
8287{
8288 unsigned int present;
8289
8290 present = snd_hda_codec_read(codec, 0x18, 0,
8291 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8292 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
8293 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8294}
8295
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008296static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008297{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008298 struct alc_spec *spec = codec->spec;
8299
8300 spec->autocfg.hp_pins[0] = 0x15;
8301 spec->autocfg.speaker_pins[0] = 0x14;
8302 alc_automute_amp(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008303 alc883_clevo_m720_mic_automute(codec);
8304}
8305
8306static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01008307 unsigned int res)
8308{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008309 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008310 case ALC880_MIC_EVENT:
8311 alc883_clevo_m720_mic_automute(codec);
8312 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008313 default:
8314 alc_automute_amp_unsol_event(codec, res);
8315 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008316 }
Jiang zhe368c7a92008-03-04 11:20:33 +01008317}
8318
Jiang zhefb97dc62008-03-06 11:07:11 +01008319/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008320static void alc883_2ch_fujitsu_pi2515_init_hook(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008321{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008322 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008323
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008324 spec->autocfg.hp_pins[0] = 0x14;
8325 spec->autocfg.speaker_pins[0] = 0x15;
8326 alc_automute_amp(codec);
Jiang zhefb97dc62008-03-06 11:07:11 +01008327}
8328
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008329static void alc883_haier_w66_init_hook(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008330{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008331 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008332
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008333 spec->autocfg.hp_pins[0] = 0x1b;
8334 spec->autocfg.speaker_pins[0] = 0x14;
8335 alc_automute_amp(codec);
Kailang Yang189609a2007-08-20 11:31:23 +02008336}
8337
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008338static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
8339{
8340 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008341 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008342
8343 present = snd_hda_codec_read(codec, 0x14, 0,
8344 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008345 bits = present ? HDA_AMP_MUTE : 0;
8346 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8347 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008348}
8349
8350static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
8351{
8352 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008353 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008354
8355 present = snd_hda_codec_read(codec, 0x1b, 0,
8356 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008357 bits = present ? HDA_AMP_MUTE : 0;
8358 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8359 HDA_AMP_MUTE, bits);
8360 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8361 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008362}
8363
8364static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
8365 unsigned int res)
8366{
8367 if ((res >> 26) == ALC880_HP_EVENT)
8368 alc883_lenovo_101e_all_automute(codec);
8369 if ((res >> 26) == ALC880_FRONT_EVENT)
8370 alc883_lenovo_101e_ispeaker_automute(codec);
8371}
8372
Takashi Iwai676a9b52007-08-16 15:23:35 +02008373/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008374static void alc883_acer_aspire_init_hook(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02008375{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008376 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008377
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008378 spec->autocfg.hp_pins[0] = 0x14;
8379 spec->autocfg.speaker_pins[0] = 0x15;
8380 spec->autocfg.speaker_pins[1] = 0x16;
8381 alc_automute_amp(codec);
Takashi Iwai676a9b52007-08-16 15:23:35 +02008382}
8383
Kailang Yangd1a991a2007-08-15 16:21:59 +02008384static struct hda_verb alc883_acer_eapd_verbs[] = {
8385 /* HP Pin: output 0 (0x0c) */
8386 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8387 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8388 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8389 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02008390 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8391 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008392 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008393 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
8394 /* eanable EAPD on medion laptop */
8395 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8396 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02008397 /* enable unsolicited event */
8398 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008399 { }
8400};
8401
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008402static void alc888_6st_dell_init_hook(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008403{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008404 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008405
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008406 spec->autocfg.hp_pins[0] = 0x1b;
8407 spec->autocfg.speaker_pins[0] = 0x14;
8408 spec->autocfg.speaker_pins[1] = 0x15;
8409 spec->autocfg.speaker_pins[2] = 0x16;
8410 spec->autocfg.speaker_pins[3] = 0x17;
8411 alc_automute_amp(codec);
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008412}
8413
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008414static void alc888_lenovo_sky_init_hook(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008415{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008416 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008417
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008418 spec->autocfg.hp_pins[0] = 0x1b;
8419 spec->autocfg.speaker_pins[0] = 0x14;
8420 spec->autocfg.speaker_pins[1] = 0x15;
8421 spec->autocfg.speaker_pins[2] = 0x16;
8422 spec->autocfg.speaker_pins[3] = 0x17;
8423 spec->autocfg.speaker_pins[4] = 0x1a;
8424 alc_automute_amp(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008425}
8426
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008427/*
8428 * generic initialization of ADC, input mixers and output mixers
8429 */
8430static struct hda_verb alc883_auto_init_verbs[] = {
8431 /*
8432 * Unmute ADC0-2 and set the default input to mic-in
8433 */
8434 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8435 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8436 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8437 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8438
Takashi Iwaicb53c622007-08-10 17:21:45 +02008439 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008440 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008441 * Note: PASD motherboards uses the Line In 2 as the input for
8442 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008443 */
8444 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008445 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8446 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8447 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8448 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8449 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008450
8451 /*
8452 * Set up output mixers (0x0c - 0x0f)
8453 */
8454 /* set vol=0 to output mixers */
8455 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8456 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8457 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8458 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8459 /* set up input amps for analog loopback */
8460 /* Amp Indices: DAC = 0, mixer = 1 */
8461 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8462 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8463 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8464 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8465 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8466 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8467 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8468 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8469 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8470 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8471
8472 /* FIXME: use matrix-type input source selection */
8473 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8474 /* Input mixer1 */
8475 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8476 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8477 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008478 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008479 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
8480 /* Input mixer2 */
8481 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8482 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8483 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008484 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Andy Shevchenkoe3cde642007-12-03 16:50:58 +01008485 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008486
8487 { }
8488};
8489
Kailang Yange2757d52008-08-26 13:17:46 +02008490static struct hda_verb alc888_asus_m90v_verbs[] = {
8491 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8492 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8493 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8494 /* enable unsolicited event */
8495 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8496 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8497 { } /* end */
8498};
8499
8500static void alc883_nb_mic_automute(struct hda_codec *codec)
8501{
8502 unsigned int present;
8503
8504 present = snd_hda_codec_read(codec, 0x18, 0,
8505 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8506 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8507 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
8508 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8509 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
8510}
8511
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008512static void alc883_M90V_init_hook(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02008513{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008514 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02008515
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008516 spec->autocfg.hp_pins[0] = 0x1b;
8517 spec->autocfg.speaker_pins[0] = 0x14;
8518 spec->autocfg.speaker_pins[1] = 0x15;
8519 spec->autocfg.speaker_pins[2] = 0x16;
8520 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008521}
8522
8523static void alc883_mode2_unsol_event(struct hda_codec *codec,
8524 unsigned int res)
8525{
8526 switch (res >> 26) {
Kailang Yange2757d52008-08-26 13:17:46 +02008527 case ALC880_MIC_EVENT:
8528 alc883_nb_mic_automute(codec);
8529 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008530 default:
8531 alc_sku_unsol_event(codec, res);
8532 break;
Kailang Yange2757d52008-08-26 13:17:46 +02008533 }
8534}
8535
8536static void alc883_mode2_inithook(struct hda_codec *codec)
8537{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008538 alc883_M90V_init_hook(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008539 alc883_nb_mic_automute(codec);
8540}
8541
8542static struct hda_verb alc888_asus_eee1601_verbs[] = {
8543 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8544 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8545 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8546 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8547 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8548 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
8549 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
8550 /* enable unsolicited event */
8551 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8552 { } /* end */
8553};
8554
Kailang Yange2757d52008-08-26 13:17:46 +02008555static void alc883_eee1601_inithook(struct hda_codec *codec)
8556{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008557 struct alc_spec *spec = codec->spec;
8558
8559 spec->autocfg.hp_pins[0] = 0x14;
8560 spec->autocfg.speaker_pins[0] = 0x1b;
8561 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008562}
8563
Takashi Iwaicb53c622007-08-10 17:21:45 +02008564#ifdef CONFIG_SND_HDA_POWER_SAVE
8565#define alc883_loopbacks alc880_loopbacks
8566#endif
8567
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008568/* pcm configuration: identiacal with ALC880 */
8569#define alc883_pcm_analog_playback alc880_pcm_analog_playback
8570#define alc883_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +01008571#define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008572#define alc883_pcm_digital_playback alc880_pcm_digital_playback
8573#define alc883_pcm_digital_capture alc880_pcm_digital_capture
8574
8575/*
8576 * configuration and preset
8577 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008578static const char *alc883_models[ALC883_MODEL_LAST] = {
8579 [ALC883_3ST_2ch_DIG] = "3stack-dig",
8580 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
8581 [ALC883_3ST_6ch] = "3stack-6ch",
8582 [ALC883_6ST_DIG] = "6stack-dig",
8583 [ALC883_TARGA_DIG] = "targa-dig",
8584 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008585 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02008586 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008587 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008588 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02008589 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008590 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008591 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02008592 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
8593 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02008594 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02008595 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008596 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008597 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008598 [ALC883_MITAC] = "mitac",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008599 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01008600 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008601 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02008602 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Wu Fengguang3ab90932008-11-17 09:51:09 +01008603 [ALC1200_ASUS_P5Q] = "asus-p5q",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008604 [ALC883_AUTO] = "auto",
8605};
8606
8607static struct snd_pci_quirk alc883_cfg_tbl[] = {
8608 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008609 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01008610 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01008611 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008612 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
8613 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02008614 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008615 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
8616 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008617 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
8618 ALC888_ACER_ASPIRE_4930G),
Takashi Iwaib3bdb302009-02-18 13:16:26 +01008619 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC883_AUTO),
Takashi Iwai94683502009-02-13 09:31:20 +01008620 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC883_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008621 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
8622 ALC888_ACER_ASPIRE_4930G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01008623 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
8624 ALC888_ACER_ASPIRE_4930G),
Takashi Iwaidea0a502009-02-09 17:14:52 +01008625 /* default Acer */
8626 SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER),
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008627 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Tobin Davisfebe3372007-06-12 11:27:46 +02008628 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008629 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
8630 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01008631 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01008632 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03008633 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Kailang Yanga01c30c2008-10-15 11:14:58 +02008634 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008635 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01008636 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01008637 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02008638 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Travis Place97ec7102008-05-23 18:31:46 +02008639 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008640 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008641 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008642 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
8643 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02008644 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008645 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Tobin Davis57b14f22007-04-18 23:05:36 +02008646 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008647 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
8648 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
8649 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Jiang zhe4383fae2008-04-14 12:58:57 +02008650 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008651 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01008652 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008653 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
8654 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
8655 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
8656 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
8657 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
8658 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
8659 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
8660 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
8661 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008662 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
8663 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02008664 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01008665 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01008666 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01008667 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02008668 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008669 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008670 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008671 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
8672 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
Takashi Iwaidea0a502009-02-09 17:14:52 +01008673 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04008674 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008675 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02008676 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01008677 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02008678 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008679 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02008680 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02008681 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008682 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
8683 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02008684 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02008685 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01008686 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01008687 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02008688 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008689 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
8690 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008691 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Wu Fengguang4b558992009-01-12 09:18:58 +08008692 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC883_3ST_6ch_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008693 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008694 {}
8695};
8696
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08008697static hda_nid_t alc883_slave_dig_outs[] = {
8698 ALC1200_DIGOUT_NID, 0,
8699};
8700
Wu Fengguangb25c9da2009-02-06 15:02:27 +08008701static hda_nid_t alc1200_slave_dig_outs[] = {
8702 ALC883_DIGOUT_NID, 0,
8703};
8704
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008705static struct alc_config_preset alc883_presets[] = {
8706 [ALC883_3ST_2ch_DIG] = {
8707 .mixers = { alc883_3ST_2ch_mixer },
8708 .init_verbs = { alc883_init_verbs },
8709 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8710 .dac_nids = alc883_dac_nids,
8711 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008712 .dig_in_nid = ALC883_DIGIN_NID,
8713 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8714 .channel_mode = alc883_3ST_2ch_modes,
8715 .input_mux = &alc883_capture_source,
8716 },
8717 [ALC883_3ST_6ch_DIG] = {
8718 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8719 .init_verbs = { alc883_init_verbs },
8720 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8721 .dac_nids = alc883_dac_nids,
8722 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008723 .dig_in_nid = ALC883_DIGIN_NID,
8724 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8725 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008726 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008727 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008728 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008729 [ALC883_3ST_6ch] = {
8730 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8731 .init_verbs = { alc883_init_verbs },
8732 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8733 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008734 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8735 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008736 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008737 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008738 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02008739 [ALC883_3ST_6ch_INTEL] = {
8740 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
8741 .init_verbs = { alc883_init_verbs },
8742 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8743 .dac_nids = alc883_dac_nids,
8744 .dig_out_nid = ALC883_DIGOUT_NID,
8745 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08008746 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +02008747 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
8748 .channel_mode = alc883_3ST_6ch_intel_modes,
8749 .need_dac_fix = 1,
8750 .input_mux = &alc883_3stack_6ch_intel,
8751 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008752 [ALC883_6ST_DIG] = {
8753 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
8754 .init_verbs = { alc883_init_verbs },
8755 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8756 .dac_nids = alc883_dac_nids,
8757 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008758 .dig_in_nid = ALC883_DIGIN_NID,
8759 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8760 .channel_mode = alc883_sixstack_modes,
8761 .input_mux = &alc883_capture_source,
8762 },
Kailang Yangccc656c2006-10-17 12:32:26 +02008763 [ALC883_TARGA_DIG] = {
8764 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
8765 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8766 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8767 .dac_nids = alc883_dac_nids,
8768 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008769 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8770 .channel_mode = alc883_3ST_6ch_modes,
8771 .need_dac_fix = 1,
8772 .input_mux = &alc883_capture_source,
8773 .unsol_event = alc883_tagra_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008774 .init_hook = alc883_tagra_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02008775 },
8776 [ALC883_TARGA_2ch_DIG] = {
8777 .mixers = { alc883_tagra_2ch_mixer},
8778 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8779 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8780 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008781 .adc_nids = alc883_adc_nids_alt,
8782 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangccc656c2006-10-17 12:32:26 +02008783 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008784 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8785 .channel_mode = alc883_3ST_2ch_modes,
8786 .input_mux = &alc883_capture_source,
8787 .unsol_event = alc883_tagra_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008788 .init_hook = alc883_tagra_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02008789 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008790 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008791 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008792 /* On TravelMate laptops, GPIO 0 enables the internal speaker
8793 * and the headphone jack. Turn this on and rely on the
8794 * standard mute methods whenever the user wants to turn
8795 * these outputs off.
8796 */
8797 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
8798 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8799 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008800 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8801 .channel_mode = alc883_3ST_2ch_modes,
8802 .input_mux = &alc883_capture_source,
8803 },
Tobin Davis2880a862007-08-07 11:50:26 +02008804 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008805 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02008806 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02008807 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8808 .dac_nids = alc883_dac_nids,
8809 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02008810 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8811 .channel_mode = alc883_3ST_2ch_modes,
8812 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008813 .unsol_event = alc_automute_amp_unsol_event,
8814 .init_hook = alc883_acer_aspire_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +02008815 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008816 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008817 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008818 alc883_chmode_mixer },
8819 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
8820 alc888_acer_aspire_4930g_verbs },
8821 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8822 .dac_nids = alc883_dac_nids,
8823 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
8824 .adc_nids = alc883_adc_nids_rev,
8825 .capsrc_nids = alc883_capsrc_nids_rev,
8826 .dig_out_nid = ALC883_DIGOUT_NID,
8827 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8828 .channel_mode = alc883_3ST_6ch_modes,
8829 .need_dac_fix = 1,
8830 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008831 ARRAY_SIZE(alc888_2_capture_sources),
8832 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008833 .unsol_event = alc_automute_amp_unsol_event,
8834 .init_hook = alc888_acer_aspire_4930g_init_hook,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008835 },
Tobin Davisc07584c2006-10-13 12:32:16 +02008836 [ALC883_MEDION] = {
8837 .mixers = { alc883_fivestack_mixer,
8838 alc883_chmode_mixer },
8839 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008840 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02008841 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8842 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008843 .adc_nids = alc883_adc_nids_alt,
8844 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Tobin Davisc07584c2006-10-13 12:32:16 +02008845 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8846 .channel_mode = alc883_sixstack_modes,
8847 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008848 },
Kailang Yang272a5272007-05-14 11:00:38 +02008849 [ALC883_MEDION_MD2] = {
8850 .mixers = { alc883_medion_md2_mixer},
8851 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
8852 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8853 .dac_nids = alc883_dac_nids,
8854 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008855 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8856 .channel_mode = alc883_3ST_2ch_modes,
8857 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008858 .unsol_event = alc_automute_amp_unsol_event,
8859 .init_hook = alc883_medion_md2_init_hook,
Kailang Yangea1fb292008-08-26 12:58:38 +02008860 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008861 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008862 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008863 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
8864 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8865 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008866 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8867 .channel_mode = alc883_3ST_2ch_modes,
8868 .input_mux = &alc883_capture_source,
8869 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008870 [ALC883_CLEVO_M720] = {
8871 .mixers = { alc883_clevo_m720_mixer },
8872 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01008873 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8874 .dac_nids = alc883_dac_nids,
8875 .dig_out_nid = ALC883_DIGOUT_NID,
8876 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8877 .channel_mode = alc883_3ST_2ch_modes,
8878 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008879 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008880 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +01008881 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008882 [ALC883_LENOVO_101E_2ch] = {
8883 .mixers = { alc883_lenovo_101e_2ch_mixer},
8884 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
8885 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8886 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008887 .adc_nids = alc883_adc_nids_alt,
8888 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008889 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8890 .channel_mode = alc883_3ST_2ch_modes,
8891 .input_mux = &alc883_lenovo_101e_capture_source,
8892 .unsol_event = alc883_lenovo_101e_unsol_event,
8893 .init_hook = alc883_lenovo_101e_all_automute,
8894 },
Kailang Yang272a5272007-05-14 11:00:38 +02008895 [ALC883_LENOVO_NB0763] = {
8896 .mixers = { alc883_lenovo_nb0763_mixer },
8897 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
8898 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8899 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02008900 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8901 .channel_mode = alc883_3ST_2ch_modes,
8902 .need_dac_fix = 1,
8903 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008904 .unsol_event = alc_automute_amp_unsol_event,
8905 .init_hook = alc883_medion_md2_init_hook,
Kailang Yang272a5272007-05-14 11:00:38 +02008906 },
8907 [ALC888_LENOVO_MS7195_DIG] = {
8908 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8909 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
8910 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8911 .dac_nids = alc883_dac_nids,
8912 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008913 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8914 .channel_mode = alc883_3ST_6ch_modes,
8915 .need_dac_fix = 1,
8916 .input_mux = &alc883_capture_source,
8917 .unsol_event = alc883_lenovo_ms7195_unsol_event,
8918 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02008919 },
8920 [ALC883_HAIER_W66] = {
8921 .mixers = { alc883_tagra_2ch_mixer},
8922 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
8923 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8924 .dac_nids = alc883_dac_nids,
8925 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02008926 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8927 .channel_mode = alc883_3ST_2ch_modes,
8928 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008929 .unsol_event = alc_automute_amp_unsol_event,
8930 .init_hook = alc883_haier_w66_init_hook,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01008931 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008932 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01008933 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008934 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008935 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8936 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008937 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
8938 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008939 .need_dac_fix = 1,
8940 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008941 .unsol_event = alc_automute_amp_unsol_event,
8942 .init_hook = alc888_3st_hp_init_hook,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008943 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008944 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01008945 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008946 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
8947 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8948 .dac_nids = alc883_dac_nids,
8949 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008950 .dig_in_nid = ALC883_DIGIN_NID,
8951 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8952 .channel_mode = alc883_sixstack_modes,
8953 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008954 .unsol_event = alc_automute_amp_unsol_event,
8955 .init_hook = alc888_6st_dell_init_hook,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008956 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008957 [ALC883_MITAC] = {
8958 .mixers = { alc883_mitac_mixer },
8959 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
8960 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8961 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008962 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8963 .channel_mode = alc883_3ST_2ch_modes,
8964 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008965 .unsol_event = alc_automute_amp_unsol_event,
8966 .init_hook = alc883_mitac_init_hook,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008967 },
Jiang zhefb97dc62008-03-06 11:07:11 +01008968 [ALC883_FUJITSU_PI2515] = {
8969 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
8970 .init_verbs = { alc883_init_verbs,
8971 alc883_2ch_fujitsu_pi2515_verbs},
8972 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8973 .dac_nids = alc883_dac_nids,
8974 .dig_out_nid = ALC883_DIGOUT_NID,
8975 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8976 .channel_mode = alc883_3ST_2ch_modes,
8977 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008978 .unsol_event = alc_automute_amp_unsol_event,
8979 .init_hook = alc883_2ch_fujitsu_pi2515_init_hook,
Jiang zhefb97dc62008-03-06 11:07:11 +01008980 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008981 [ALC888_FUJITSU_XA3530] = {
8982 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
8983 .init_verbs = { alc883_init_verbs,
8984 alc888_fujitsu_xa3530_verbs },
8985 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8986 .dac_nids = alc883_dac_nids,
8987 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
8988 .adc_nids = alc883_adc_nids_rev,
8989 .capsrc_nids = alc883_capsrc_nids_rev,
8990 .dig_out_nid = ALC883_DIGOUT_NID,
8991 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
8992 .channel_mode = alc888_4ST_8ch_intel_modes,
8993 .num_mux_defs =
8994 ARRAY_SIZE(alc888_2_capture_sources),
8995 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008996 .unsol_event = alc_automute_amp_unsol_event,
8997 .init_hook = alc888_fujitsu_xa3530_init_hook,
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008998 },
Kailang Yange2757d52008-08-26 13:17:46 +02008999 [ALC888_LENOVO_SKY] = {
9000 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
9001 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
9002 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9003 .dac_nids = alc883_dac_nids,
9004 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +02009005 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9006 .channel_mode = alc883_sixstack_modes,
9007 .need_dac_fix = 1,
9008 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009009 .unsol_event = alc_automute_amp_unsol_event,
9010 .init_hook = alc888_lenovo_sky_init_hook,
Kailang Yange2757d52008-08-26 13:17:46 +02009011 },
9012 [ALC888_ASUS_M90V] = {
9013 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9014 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
9015 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9016 .dac_nids = alc883_dac_nids,
9017 .dig_out_nid = ALC883_DIGOUT_NID,
9018 .dig_in_nid = ALC883_DIGIN_NID,
9019 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9020 .channel_mode = alc883_3ST_6ch_modes,
9021 .need_dac_fix = 1,
9022 .input_mux = &alc883_fujitsu_pi2515_capture_source,
9023 .unsol_event = alc883_mode2_unsol_event,
9024 .init_hook = alc883_mode2_inithook,
9025 },
9026 [ALC888_ASUS_EEE1601] = {
9027 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009028 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +02009029 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
9030 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9031 .dac_nids = alc883_dac_nids,
9032 .dig_out_nid = ALC883_DIGOUT_NID,
9033 .dig_in_nid = ALC883_DIGIN_NID,
9034 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9035 .channel_mode = alc883_3ST_2ch_modes,
9036 .need_dac_fix = 1,
9037 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009038 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +02009039 .init_hook = alc883_eee1601_inithook,
9040 },
Wu Fengguang3ab90932008-11-17 09:51:09 +01009041 [ALC1200_ASUS_P5Q] = {
9042 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9043 .init_verbs = { alc883_init_verbs },
9044 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9045 .dac_nids = alc883_dac_nids,
9046 .dig_out_nid = ALC1200_DIGOUT_NID,
9047 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +08009048 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +01009049 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9050 .channel_mode = alc883_sixstack_modes,
9051 .input_mux = &alc883_capture_source,
9052 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009053};
9054
9055
9056/*
9057 * BIOS auto configuration
9058 */
9059static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
9060 hda_nid_t nid, int pin_type,
9061 int dac_idx)
9062{
9063 /* set as output */
9064 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009065 int idx;
9066
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009067 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009068 if (spec->multiout.dac_nids[dac_idx] == 0x25)
9069 idx = 4;
9070 else
9071 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009072 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
9073
9074}
9075
9076static void alc883_auto_init_multi_out(struct hda_codec *codec)
9077{
9078 struct alc_spec *spec = codec->spec;
9079 int i;
9080
9081 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009082 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009083 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009084 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009085 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009086 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009087 }
9088}
9089
9090static void alc883_auto_init_hp_out(struct hda_codec *codec)
9091{
9092 struct alc_spec *spec = codec->spec;
9093 hda_nid_t pin;
9094
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009095 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009096 if (pin) /* connect to front */
9097 /* use dac 0 */
9098 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009099 pin = spec->autocfg.speaker_pins[0];
9100 if (pin)
9101 alc883_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009102}
9103
9104#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
9105#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
9106
9107static void alc883_auto_init_analog_input(struct hda_codec *codec)
9108{
9109 struct alc_spec *spec = codec->spec;
9110 int i;
9111
9112 for (i = 0; i < AUTO_PIN_LAST; i++) {
9113 hda_nid_t nid = spec->autocfg.input_pins[i];
9114 if (alc883_is_input_pin(nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01009115 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01009116 if (nid != ALC883_PIN_CD_NID &&
9117 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009118 snd_hda_codec_write(codec, nid, 0,
9119 AC_VERB_SET_AMP_GAIN_MUTE,
9120 AMP_OUT_MUTE);
9121 }
9122 }
9123}
9124
Takashi Iwaif511b012008-08-15 16:46:42 +02009125#define alc883_auto_init_input_src alc882_auto_init_input_src
9126
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009127/* almost identical with ALC880 parser... */
9128static int alc883_parse_auto_config(struct hda_codec *codec)
9129{
9130 struct alc_spec *spec = codec->spec;
9131 int err = alc880_parse_auto_config(codec);
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009132 struct auto_pin_cfg *cfg = &spec->autocfg;
9133 int i;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009134
9135 if (err < 0)
9136 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02009137 else if (!err)
9138 return 0; /* no config found */
9139
9140 err = alc_auto_add_mic_boost(codec);
9141 if (err < 0)
9142 return err;
9143
9144 /* hack - override the init verbs */
9145 spec->init_verbs[0] = alc883_auto_init_verbs;
Takashi Iwai776e1842007-08-29 15:07:11 +02009146
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009147 /* setup input_mux for ALC889 */
9148 if (codec->vendor_id == 0x10ec0889) {
9149 /* digital-mic input pin is excluded in alc880_auto_create..()
9150 * because it's under 0x18
9151 */
9152 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
9153 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
9154 struct hda_input_mux *imux = &spec->private_imux[0];
9155 for (i = 1; i < 3; i++)
9156 memcpy(&spec->private_imux[i],
9157 &spec->private_imux[0],
9158 sizeof(spec->private_imux[0]));
9159 imux->items[imux->num_items].label = "Int DMic";
9160 imux->items[imux->num_items].index = 0x0b;
9161 imux->num_items++;
9162 spec->num_mux_defs = 3;
9163 spec->input_mux = spec->private_imux;
9164 }
9165 }
9166
Takashi Iwai776e1842007-08-29 15:07:11 +02009167 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009168}
9169
9170/* additional initialization for auto-configuration model */
9171static void alc883_auto_init(struct hda_codec *codec)
9172{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009173 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009174 alc883_auto_init_multi_out(codec);
9175 alc883_auto_init_hp_out(codec);
9176 alc883_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02009177 alc883_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009178 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02009179 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009180}
9181
9182static int patch_alc883(struct hda_codec *codec)
9183{
9184 struct alc_spec *spec;
9185 int err, board_config;
9186
9187 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
9188 if (spec == NULL)
9189 return -ENOMEM;
9190
9191 codec->spec = spec;
9192
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02009193 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
9194
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009195 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
9196 alc883_models,
9197 alc883_cfg_tbl);
9198 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009199 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
9200 "trying auto-probe from BIOS...\n");
9201 board_config = ALC883_AUTO;
9202 }
9203
9204 if (board_config == ALC883_AUTO) {
9205 /* automatic parse from the BIOS config */
9206 err = alc883_parse_auto_config(codec);
9207 if (err < 0) {
9208 alc_free(codec);
9209 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009210 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009211 printk(KERN_INFO
9212 "hda_codec: Cannot set up configuration "
9213 "from BIOS. Using base mode...\n");
9214 board_config = ALC883_3ST_2ch_DIG;
9215 }
9216 }
9217
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09009218 err = snd_hda_attach_beep_device(codec, 0x1);
9219 if (err < 0) {
9220 alc_free(codec);
9221 return err;
9222 }
9223
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009224 if (board_config != ALC883_AUTO)
9225 setup_preset(spec, &alc883_presets[board_config]);
9226
Kailang Yang2f893282008-05-27 12:14:47 +02009227 switch (codec->vendor_id) {
9228 case 0x10ec0888:
Kailang Yang44426082008-10-15 11:18:05 +02009229 if (codec->revision_id == 0x100101) {
9230 spec->stream_name_analog = "ALC1200 Analog";
9231 spec->stream_name_digital = "ALC1200 Digital";
9232 } else {
9233 spec->stream_name_analog = "ALC888 Analog";
9234 spec->stream_name_digital = "ALC888 Digital";
9235 }
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009236 if (!spec->num_adc_nids) {
9237 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
9238 spec->adc_nids = alc883_adc_nids;
9239 }
9240 if (!spec->capsrc_nids)
9241 spec->capsrc_nids = alc883_capsrc_nids;
9242 spec->capture_style = CAPT_MIX; /* matrix-style capture */
Takashi Iwai4a79ba32009-04-22 16:31:35 +02009243 spec->init_amp = ALC_INIT_DEFAULT; /* always initialize */
Kailang Yang2f893282008-05-27 12:14:47 +02009244 break;
9245 case 0x10ec0889:
9246 spec->stream_name_analog = "ALC889 Analog";
9247 spec->stream_name_digital = "ALC889 Digital";
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009248 if (!spec->num_adc_nids) {
9249 spec->num_adc_nids = ARRAY_SIZE(alc889_adc_nids);
9250 spec->adc_nids = alc889_adc_nids;
9251 }
9252 if (!spec->capsrc_nids)
9253 spec->capsrc_nids = alc889_capsrc_nids;
9254 spec->capture_style = CAPT_1MUX_MIX; /* 1mux/Nmix-style
9255 capture */
Kailang Yang2f893282008-05-27 12:14:47 +02009256 break;
9257 default:
9258 spec->stream_name_analog = "ALC883 Analog";
9259 spec->stream_name_digital = "ALC883 Digital";
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009260 if (!spec->num_adc_nids) {
9261 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
9262 spec->adc_nids = alc883_adc_nids;
9263 }
9264 if (!spec->capsrc_nids)
9265 spec->capsrc_nids = alc883_capsrc_nids;
9266 spec->capture_style = CAPT_MIX; /* matrix-style capture */
Kailang Yang2f893282008-05-27 12:14:47 +02009267 break;
9268 }
9269
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009270 spec->stream_analog_playback = &alc883_pcm_analog_playback;
9271 spec->stream_analog_capture = &alc883_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01009272 spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009273
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009274 spec->stream_digital_playback = &alc883_pcm_digital_playback;
9275 spec->stream_digital_capture = &alc883_pcm_digital_capture;
9276
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009277 if (!spec->cap_mixer)
9278 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01009279 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009280
Takashi Iwai2134ea42008-01-10 16:53:55 +01009281 spec->vmaster_nid = 0x0c;
9282
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009283 codec->patch_ops = alc_patch_ops;
9284 if (board_config == ALC883_AUTO)
9285 spec->init_hook = alc883_auto_init;
Kailang Yangf9423e72008-05-27 12:32:25 +02009286
Takashi Iwaicb53c622007-08-10 17:21:45 +02009287#ifdef CONFIG_SND_HDA_POWER_SAVE
9288 if (!spec->loopback.amplist)
9289 spec->loopback.amplist = alc883_loopbacks;
9290#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01009291 codec->proc_widget_hook = print_realtek_coef;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009292
9293 return 0;
9294}
9295
9296/*
Kailang Yangdf694da2005-12-05 19:42:22 +01009297 * ALC262 support
9298 */
9299
9300#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
9301#define ALC262_DIGIN_NID ALC880_DIGIN_NID
9302
9303#define alc262_dac_nids alc260_dac_nids
9304#define alc262_adc_nids alc882_adc_nids
9305#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +01009306#define alc262_capsrc_nids alc882_capsrc_nids
9307#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +01009308
9309#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01009310#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01009311
Kailang Yang4e555fe2008-08-26 13:05:55 +02009312static hda_nid_t alc262_dmic_adc_nids[1] = {
9313 /* ADC0 */
9314 0x09
9315};
9316
9317static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
9318
Kailang Yangdf694da2005-12-05 19:42:22 +01009319static struct snd_kcontrol_new alc262_base_mixer[] = {
9320 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9321 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9322 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9323 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9324 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9325 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9326 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9327 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009328 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009329 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9330 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009331 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009332 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
9333 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9334 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
9335 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009336 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01009337};
9338
Takashi Iwaice875f02008-01-28 18:17:43 +01009339/* update HP, line and mono-out pins according to the master switch */
9340static void alc262_hp_master_update(struct hda_codec *codec)
9341{
9342 struct alc_spec *spec = codec->spec;
9343 int val = spec->master_sw;
9344
9345 /* HP & line-out */
9346 snd_hda_codec_write_cache(codec, 0x1b, 0,
9347 AC_VERB_SET_PIN_WIDGET_CONTROL,
9348 val ? PIN_HP : 0);
9349 snd_hda_codec_write_cache(codec, 0x15, 0,
9350 AC_VERB_SET_PIN_WIDGET_CONTROL,
9351 val ? PIN_HP : 0);
9352 /* mono (speaker) depending on the HP jack sense */
9353 val = val && !spec->jack_present;
9354 snd_hda_codec_write_cache(codec, 0x16, 0,
9355 AC_VERB_SET_PIN_WIDGET_CONTROL,
9356 val ? PIN_OUT : 0);
9357}
9358
9359static void alc262_hp_bpc_automute(struct hda_codec *codec)
9360{
9361 struct alc_spec *spec = codec->spec;
9362 unsigned int presence;
9363 presence = snd_hda_codec_read(codec, 0x1b, 0,
9364 AC_VERB_GET_PIN_SENSE, 0);
9365 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9366 alc262_hp_master_update(codec);
9367}
9368
9369static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
9370{
9371 if ((res >> 26) != ALC880_HP_EVENT)
9372 return;
9373 alc262_hp_bpc_automute(codec);
9374}
9375
9376static void alc262_hp_wildwest_automute(struct hda_codec *codec)
9377{
9378 struct alc_spec *spec = codec->spec;
9379 unsigned int presence;
9380 presence = snd_hda_codec_read(codec, 0x15, 0,
9381 AC_VERB_GET_PIN_SENSE, 0);
9382 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9383 alc262_hp_master_update(codec);
9384}
9385
9386static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
9387 unsigned int res)
9388{
9389 if ((res >> 26) != ALC880_HP_EVENT)
9390 return;
9391 alc262_hp_wildwest_automute(codec);
9392}
9393
Takashi Iwaib72519b2009-05-08 14:31:55 +02009394#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +01009395
9396static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
9397 struct snd_ctl_elem_value *ucontrol)
9398{
9399 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9400 struct alc_spec *spec = codec->spec;
9401 int val = !!*ucontrol->value.integer.value;
9402
9403 if (val == spec->master_sw)
9404 return 0;
9405 spec->master_sw = val;
9406 alc262_hp_master_update(codec);
9407 return 1;
9408}
9409
Takashi Iwaib72519b2009-05-08 14:31:55 +02009410#define ALC262_HP_MASTER_SWITCH \
9411 { \
9412 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
9413 .name = "Master Playback Switch", \
9414 .info = snd_ctl_boolean_mono_info, \
9415 .get = alc262_hp_master_sw_get, \
9416 .put = alc262_hp_master_sw_put, \
9417 }
9418
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009419static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +02009420 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009421 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9422 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9423 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009424 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9425 HDA_OUTPUT),
9426 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9427 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009428 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9429 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009430 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009431 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9432 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009433 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009434 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9435 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9436 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9437 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009438 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
9439 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
9440 { } /* end */
9441};
9442
Kailang Yangcd7509a2007-01-26 18:33:17 +01009443static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +02009444 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +01009445 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9446 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9447 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9448 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009449 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9450 HDA_OUTPUT),
9451 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9452 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009453 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
9454 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009455 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009456 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9457 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9458 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9459 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009460 { } /* end */
9461};
9462
9463static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
9464 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9465 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009466 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009467 { } /* end */
9468};
9469
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009470/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009471static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009472{
9473 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009474
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009475 spec->autocfg.hp_pins[0] = 0x15;
9476 spec->autocfg.speaker_pins[0] = 0x0c; /* HACK: not actually a pin */
9477 alc_automute_amp(codec);
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009478}
9479
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009480static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +01009481 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9482 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009483 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9484 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9485 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9486 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9487 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9488 { } /* end */
9489};
9490
9491static struct hda_verb alc262_hp_t5735_verbs[] = {
9492 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9493 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9494
9495 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9496 { }
9497};
9498
Kailang Yang8c427222008-01-10 13:03:59 +01009499static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +01009500 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9501 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01009502 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
9503 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +01009504 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9505 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9506 { } /* end */
9507};
9508
9509static struct hda_verb alc262_hp_rp5700_verbs[] = {
9510 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9511 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9512 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9513 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9514 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9515 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9516 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9517 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9518 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9519 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9520 {}
9521};
9522
9523static struct hda_input_mux alc262_hp_rp5700_capture_source = {
9524 .num_items = 1,
9525 .items = {
9526 { "Line", 0x1 },
9527 },
9528};
9529
Takashi Iwai42171c12009-05-08 14:11:43 +02009530/* bind hp and internal speaker mute (with plug check) as master switch */
9531static void alc262_hippo_master_update(struct hda_codec *codec)
9532{
9533 struct alc_spec *spec = codec->spec;
9534 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
9535 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
9536 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
9537 unsigned int mute;
9538
9539 /* HP */
9540 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
9541 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
9542 HDA_AMP_MUTE, mute);
9543 /* mute internal speaker per jack sense */
9544 if (spec->jack_present)
9545 mute = HDA_AMP_MUTE;
9546 if (line_nid)
9547 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
9548 HDA_AMP_MUTE, mute);
9549 if (speaker_nid && speaker_nid != line_nid)
9550 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
9551 HDA_AMP_MUTE, mute);
9552}
9553
9554#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
9555
9556static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
9557 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +02009558{
9559 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +02009560 struct alc_spec *spec = codec->spec;
9561 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +02009562
Takashi Iwai42171c12009-05-08 14:11:43 +02009563 if (val == spec->master_sw)
9564 return 0;
9565 spec->master_sw = val;
9566 alc262_hippo_master_update(codec);
9567 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +02009568}
Takashi Iwai5b319542007-07-26 11:49:22 +02009569
Takashi Iwai42171c12009-05-08 14:11:43 +02009570#define ALC262_HIPPO_MASTER_SWITCH \
9571 { \
9572 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
9573 .name = "Master Playback Switch", \
9574 .info = snd_ctl_boolean_mono_info, \
9575 .get = alc262_hippo_master_sw_get, \
9576 .put = alc262_hippo_master_sw_put, \
9577 }
9578
9579static struct snd_kcontrol_new alc262_hippo_mixer[] = {
9580 ALC262_HIPPO_MASTER_SWITCH,
9581 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9582 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9583 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9584 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9585 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9586 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9587 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9588 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9589 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9590 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9591 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9592 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9593 { } /* end */
9594};
9595
9596static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
9597 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9598 ALC262_HIPPO_MASTER_SWITCH,
9599 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9600 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9601 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9602 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9603 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9604 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9605 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9606 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9607 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9608 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9609 { } /* end */
9610};
9611
9612/* mute/unmute internal speaker according to the hp jack and mute state */
9613static void alc262_hippo_automute(struct hda_codec *codec)
9614{
9615 struct alc_spec *spec = codec->spec;
9616 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
9617 unsigned int present;
9618
9619 /* need to execute and sync at first */
9620 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
9621 present = snd_hda_codec_read(codec, hp_nid, 0,
9622 AC_VERB_GET_PIN_SENSE, 0);
9623 spec->jack_present = (present & 0x80000000) != 0;
9624 alc262_hippo_master_update(codec);
9625}
9626
9627static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
9628{
9629 if ((res >> 26) != ALC880_HP_EVENT)
9630 return;
9631 alc262_hippo_automute(codec);
9632}
9633
9634static void alc262_hippo_init_hook(struct hda_codec *codec)
9635{
9636 struct alc_spec *spec = codec->spec;
9637
9638 spec->autocfg.hp_pins[0] = 0x15;
9639 spec->autocfg.speaker_pins[0] = 0x14;
9640 alc262_hippo_automute(codec);
9641}
9642
9643static void alc262_hippo1_init_hook(struct hda_codec *codec)
9644{
9645 struct alc_spec *spec = codec->spec;
9646
9647 spec->autocfg.hp_pins[0] = 0x1b;
9648 spec->autocfg.speaker_pins[0] = 0x14;
9649 alc262_hippo_automute(codec);
9650}
9651
9652
Kailang Yang272a5272007-05-14 11:00:38 +02009653static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +02009654 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +02009655 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +02009656 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9657 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9658 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9659 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9660 { } /* end */
9661};
9662
Kailang Yang83c34212007-07-05 11:43:05 +02009663static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +02009664 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9665 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +02009666 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9667 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9668 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9669 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9670 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9671 { } /* end */
9672};
Kailang Yang272a5272007-05-14 11:00:38 +02009673
Tony Vroonba340e82009-02-02 19:01:30 +00009674static struct snd_kcontrol_new alc262_tyan_mixer[] = {
9675 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9676 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
9677 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
9678 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
9679 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9680 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9681 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9682 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9683 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9684 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9685 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9686 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9687 { } /* end */
9688};
9689
9690static struct hda_verb alc262_tyan_verbs[] = {
9691 /* Headphone automute */
9692 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9693 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9694 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9695
9696 /* P11 AUX_IN, white 4-pin connector */
9697 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9698 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
9699 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
9700 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
9701
9702 {}
9703};
9704
9705/* unsolicited event for HP jack sensing */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009706static void alc262_tyan_init_hook(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +00009707{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009708 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +00009709
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009710 spec->autocfg.hp_pins[0] = 0x1b;
9711 spec->autocfg.speaker_pins[0] = 0x15;
9712 alc_automute_amp(codec);
Tony Vroonba340e82009-02-02 19:01:30 +00009713}
9714
Tony Vroonba340e82009-02-02 19:01:30 +00009715
Kailang Yangdf694da2005-12-05 19:42:22 +01009716#define alc262_capture_mixer alc882_capture_mixer
9717#define alc262_capture_alt_mixer alc882_capture_alt_mixer
9718
9719/*
9720 * generic initialization of ADC, input mixers and output mixers
9721 */
9722static struct hda_verb alc262_init_verbs[] = {
9723 /*
9724 * Unmute ADC0-2 and set the default input to mic-in
9725 */
9726 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9727 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9728 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9729 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9730 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9731 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9732
Takashi Iwaicb53c622007-08-10 17:21:45 +02009733 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01009734 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009735 * Note: PASD motherboards uses the Line In 2 as the input for
9736 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01009737 */
9738 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009739 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9740 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9741 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9742 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9743 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009744
9745 /*
9746 * Set up output mixers (0x0c - 0x0e)
9747 */
9748 /* set vol=0 to output mixers */
9749 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9750 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9751 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9752 /* set up input amps for analog loopback */
9753 /* Amp Indices: DAC = 0, mixer = 1 */
9754 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9755 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9756 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9757 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9758 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9759 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9760
9761 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9762 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9763 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9764 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9765 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9766 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9767
9768 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9769 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9770 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9771 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9772 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +02009773
Kailang Yangdf694da2005-12-05 19:42:22 +01009774 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9775 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +02009776
Kailang Yangdf694da2005-12-05 19:42:22 +01009777 /* FIXME: use matrix-type input source selection */
9778 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9779 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9780 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9781 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9782 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9783 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9784 /* Input mixer2 */
9785 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9786 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9787 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9788 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9789 /* Input mixer3 */
9790 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9791 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9792 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009793 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +01009794
9795 { }
9796};
9797
Kailang Yang4e555fe2008-08-26 13:05:55 +02009798static struct hda_verb alc262_eapd_verbs[] = {
9799 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
9800 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
9801 { }
9802};
9803
Kailang Yangccc656c2006-10-17 12:32:26 +02009804static struct hda_verb alc262_hippo_unsol_verbs[] = {
9805 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9806 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9807 {}
9808};
9809
9810static struct hda_verb alc262_hippo1_unsol_verbs[] = {
9811 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9812 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9813 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9814
9815 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9816 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9817 {}
9818};
9819
Kailang Yang272a5272007-05-14 11:00:38 +02009820static struct hda_verb alc262_sony_unsol_verbs[] = {
9821 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9822 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9823 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
9824
9825 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9826 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +09009827 {}
Kailang Yang272a5272007-05-14 11:00:38 +02009828};
9829
Kailang Yang4e555fe2008-08-26 13:05:55 +02009830static struct hda_input_mux alc262_dmic_capture_source = {
9831 .num_items = 2,
9832 .items = {
9833 { "Int DMic", 0x9 },
9834 { "Mic", 0x0 },
9835 },
9836};
9837
9838static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
9839 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9840 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9841 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9842 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9843 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +02009844 { } /* end */
9845};
9846
9847static struct hda_verb alc262_toshiba_s06_verbs[] = {
9848 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9849 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9850 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9851 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9852 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
9853 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9854 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
9855 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9856 {}
9857};
9858
9859static void alc262_dmic_automute(struct hda_codec *codec)
9860{
9861 unsigned int present;
9862
9863 present = snd_hda_codec_read(codec, 0x18, 0,
9864 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9865 snd_hda_codec_write(codec, 0x22, 0,
9866 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x09);
9867}
9868
Kailang Yang4e555fe2008-08-26 13:05:55 +02009869
9870/* unsolicited event for HP jack sensing */
9871static void alc262_toshiba_s06_unsol_event(struct hda_codec *codec,
9872 unsigned int res)
9873{
Kailang Yang4e555fe2008-08-26 13:05:55 +02009874 if ((res >> 26) == ALC880_MIC_EVENT)
9875 alc262_dmic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009876 else
9877 alc_sku_unsol_event(codec, res);
Kailang Yang4e555fe2008-08-26 13:05:55 +02009878}
9879
9880static void alc262_toshiba_s06_init_hook(struct hda_codec *codec)
9881{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009882 struct alc_spec *spec = codec->spec;
9883
9884 spec->autocfg.hp_pins[0] = 0x15;
9885 spec->autocfg.speaker_pins[0] = 0x14;
9886 alc_automute_pin(codec);
Kailang Yang4e555fe2008-08-26 13:05:55 +02009887 alc262_dmic_automute(codec);
9888}
9889
Takashi Iwai834be882006-03-01 14:16:17 +01009890/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +02009891 * nec model
9892 * 0x15 = headphone
9893 * 0x16 = internal speaker
9894 * 0x18 = external mic
9895 */
9896
9897static struct snd_kcontrol_new alc262_nec_mixer[] = {
9898 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
9899 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
9900
9901 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9902 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9903 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9904
9905 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9906 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9907 { } /* end */
9908};
9909
9910static struct hda_verb alc262_nec_verbs[] = {
9911 /* Unmute Speaker */
9912 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9913
9914 /* Headphone */
9915 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9916 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9917
9918 /* External mic to headphone */
9919 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9920 /* External mic to speaker */
9921 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9922 {}
9923};
9924
9925/*
Takashi Iwai834be882006-03-01 14:16:17 +01009926 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +01009927 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
9928 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +01009929 */
9930
9931#define ALC_HP_EVENT 0x37
9932
9933static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
9934 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9935 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +01009936 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9937 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +01009938 {}
9939};
9940
Jiang zhe0e31daf2008-03-20 12:12:39 +01009941static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
9942 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9943 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9944 {}
9945};
9946
Takashi Iwai834be882006-03-01 14:16:17 +01009947static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009948 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +01009949 .items = {
9950 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009951 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +01009952 { "CD", 0x4 },
9953 },
9954};
9955
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009956static struct hda_input_mux alc262_HP_capture_source = {
9957 .num_items = 5,
9958 .items = {
9959 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +02009960 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009961 { "Line", 0x2 },
9962 { "CD", 0x4 },
9963 { "AUX IN", 0x6 },
9964 },
9965};
9966
zhejiangaccbe492007-08-31 12:36:05 +02009967static struct hda_input_mux alc262_HP_D7000_capture_source = {
9968 .num_items = 4,
9969 .items = {
9970 { "Mic", 0x0 },
9971 { "Front Mic", 0x2 },
9972 { "Line", 0x1 },
9973 { "CD", 0x4 },
9974 },
9975};
9976
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009977/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +01009978static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
9979{
9980 struct alc_spec *spec = codec->spec;
9981 unsigned int mute;
9982
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009983 if (force || !spec->sense_updated) {
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009984 unsigned int present;
Takashi Iwai834be882006-03-01 14:16:17 +01009985 /* need to execute and sync at first */
9986 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009987 /* check laptop HP jack */
9988 present = snd_hda_codec_read(codec, 0x14, 0,
9989 AC_VERB_GET_PIN_SENSE, 0);
9990 /* need to execute and sync at first */
9991 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9992 /* check docking HP jack */
9993 present |= snd_hda_codec_read(codec, 0x1b, 0,
9994 AC_VERB_GET_PIN_SENSE, 0);
9995 if (present & AC_PINSENSE_PRESENCE)
9996 spec->jack_present = 1;
9997 else
9998 spec->jack_present = 0;
Takashi Iwai834be882006-03-01 14:16:17 +01009999 spec->sense_updated = 1;
10000 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010001 /* unmute internal speaker only if both HPs are unplugged and
10002 * master switch is on
10003 */
10004 if (spec->jack_present)
10005 mute = HDA_AMP_MUTE;
10006 else
Takashi Iwai834be882006-03-01 14:16:17 +010010007 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010008 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10009 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010010010}
10011
10012/* unsolicited event for HP jack sensing */
10013static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
10014 unsigned int res)
10015{
10016 if ((res >> 26) != ALC_HP_EVENT)
10017 return;
10018 alc262_fujitsu_automute(codec, 1);
10019}
10020
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010021static void alc262_fujitsu_init_hook(struct hda_codec *codec)
10022{
10023 alc262_fujitsu_automute(codec, 1);
10024}
10025
Takashi Iwai834be882006-03-01 14:16:17 +010010026/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020010027static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
10028 .ops = &snd_hda_bind_vol,
10029 .values = {
10030 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
10031 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
10032 0
10033 },
10034};
Takashi Iwai834be882006-03-01 14:16:17 +010010035
Jiang zhe0e31daf2008-03-20 12:12:39 +010010036/* mute/unmute internal speaker according to the hp jack and mute state */
10037static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
10038{
10039 struct alc_spec *spec = codec->spec;
10040 unsigned int mute;
10041
10042 if (force || !spec->sense_updated) {
10043 unsigned int present_int_hp;
10044 /* need to execute and sync at first */
10045 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10046 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
10047 AC_VERB_GET_PIN_SENSE, 0);
10048 spec->jack_present = (present_int_hp & 0x80000000) != 0;
10049 spec->sense_updated = 1;
10050 }
10051 if (spec->jack_present) {
10052 /* mute internal speaker */
10053 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10054 HDA_AMP_MUTE, HDA_AMP_MUTE);
10055 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10056 HDA_AMP_MUTE, HDA_AMP_MUTE);
10057 } else {
10058 /* unmute internal speaker if necessary */
10059 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
10060 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10061 HDA_AMP_MUTE, mute);
10062 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10063 HDA_AMP_MUTE, mute);
10064 }
10065}
10066
10067/* unsolicited event for HP jack sensing */
10068static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
10069 unsigned int res)
10070{
10071 if ((res >> 26) != ALC_HP_EVENT)
10072 return;
10073 alc262_lenovo_3000_automute(codec, 1);
10074}
10075
Takashi Iwai834be882006-03-01 14:16:17 +010010076/* bind hp and internal speaker mute (with plug check) */
10077static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
10078 struct snd_ctl_elem_value *ucontrol)
10079{
10080 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10081 long *valp = ucontrol->value.integer.value;
10082 int change;
10083
Tony Vroon5d9fab22008-03-14 17:09:18 +010010084 change = snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10085 HDA_AMP_MUTE,
10086 valp ? 0 : HDA_AMP_MUTE);
10087 change |= snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
10088 HDA_AMP_MUTE,
10089 valp ? 0 : HDA_AMP_MUTE);
10090
Takashi Iwai82beb8f2007-08-10 17:09:26 +020010091 if (change)
10092 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010010093 return change;
10094}
10095
10096static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020010097 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010010098 {
10099 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10100 .name = "Master Playback Switch",
10101 .info = snd_hda_mixer_amp_switch_info,
10102 .get = snd_hda_mixer_amp_switch_get,
10103 .put = alc262_fujitsu_master_sw_put,
10104 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10105 },
10106 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10107 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10108 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10109 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10110 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010111 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10112 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10113 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010010114 { } /* end */
10115};
10116
Jiang zhe0e31daf2008-03-20 12:12:39 +010010117/* bind hp and internal speaker mute (with plug check) */
10118static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
10119 struct snd_ctl_elem_value *ucontrol)
10120{
10121 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10122 long *valp = ucontrol->value.integer.value;
10123 int change;
10124
10125 change = snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
10126 HDA_AMP_MUTE,
10127 valp ? 0 : HDA_AMP_MUTE);
10128
10129 if (change)
10130 alc262_lenovo_3000_automute(codec, 0);
10131 return change;
10132}
10133
10134static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
10135 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10136 {
10137 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10138 .name = "Master Playback Switch",
10139 .info = snd_hda_mixer_amp_switch_info,
10140 .get = snd_hda_mixer_amp_switch_get,
10141 .put = alc262_lenovo_3000_master_sw_put,
10142 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
10143 },
10144 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10145 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10146 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10147 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10148 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10149 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10150 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10151 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10152 { } /* end */
10153};
10154
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010155static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
10156 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020010157 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010158 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10159 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10160 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10161 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10162 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10163 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10164 { } /* end */
10165};
10166
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010167/* additional init verbs for Benq laptops */
10168static struct hda_verb alc262_EAPD_verbs[] = {
10169 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10170 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
10171 {}
10172};
10173
Kailang Yang83c34212007-07-05 11:43:05 +020010174static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
10175 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10176 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10177
10178 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10179 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
10180 {}
10181};
10182
Tobin Davisf651b502007-10-26 12:40:47 +020010183/* Samsung Q1 Ultra Vista model setup */
10184static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010185 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10186 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010187 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10188 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10189 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010190 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010191 { } /* end */
10192};
10193
10194static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010195 /* output mixer */
10196 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10197 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10198 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10199 /* speaker */
10200 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10201 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10202 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10203 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10204 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020010205 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010206 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10207 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10208 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10209 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10210 /* internal mic */
10211 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10212 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10213 /* ADC, choose mic */
10214 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10215 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10216 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10217 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10218 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10219 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10220 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10221 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10222 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
10223 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020010224 {}
10225};
10226
Tobin Davisf651b502007-10-26 12:40:47 +020010227/* mute/unmute internal speaker according to the hp jack and mute state */
10228static void alc262_ultra_automute(struct hda_codec *codec)
10229{
10230 struct alc_spec *spec = codec->spec;
10231 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020010232
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010233 mute = 0;
10234 /* auto-mute only when HP is used as HP */
10235 if (!spec->cur_mux[0]) {
10236 unsigned int present;
10237 /* need to execute and sync at first */
10238 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
10239 present = snd_hda_codec_read(codec, 0x15, 0,
10240 AC_VERB_GET_PIN_SENSE, 0);
10241 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
10242 if (spec->jack_present)
10243 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020010244 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010245 /* mute/unmute internal speaker */
10246 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10247 HDA_AMP_MUTE, mute);
10248 /* mute/unmute HP */
10249 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10250 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020010251}
10252
10253/* unsolicited event for HP jack sensing */
10254static void alc262_ultra_unsol_event(struct hda_codec *codec,
10255 unsigned int res)
10256{
10257 if ((res >> 26) != ALC880_HP_EVENT)
10258 return;
10259 alc262_ultra_automute(codec);
10260}
10261
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010262static struct hda_input_mux alc262_ultra_capture_source = {
10263 .num_items = 2,
10264 .items = {
10265 { "Mic", 0x1 },
10266 { "Headphone", 0x7 },
10267 },
10268};
10269
10270static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
10271 struct snd_ctl_elem_value *ucontrol)
10272{
10273 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10274 struct alc_spec *spec = codec->spec;
10275 int ret;
10276
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010277 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010278 if (!ret)
10279 return 0;
10280 /* reprogram the HP pin as mic or HP according to the input source */
10281 snd_hda_codec_write_cache(codec, 0x15, 0,
10282 AC_VERB_SET_PIN_WIDGET_CONTROL,
10283 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
10284 alc262_ultra_automute(codec); /* mute/unmute HP */
10285 return ret;
10286}
10287
10288static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
10289 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10290 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10291 {
10292 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10293 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010294 .info = alc_mux_enum_info,
10295 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010296 .put = alc262_ultra_mux_enum_put,
10297 },
10298 { } /* end */
10299};
10300
Kailang Yangdf694da2005-12-05 19:42:22 +010010301/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010302static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
10303 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010010304{
10305 hda_nid_t nid;
10306 int err;
10307
10308 spec->multiout.num_dacs = 1; /* only use one dac */
10309 spec->multiout.dac_nids = spec->private_dac_nids;
10310 spec->multiout.dac_nids[0] = 2;
10311
10312 nid = cfg->line_out_pins[0];
10313 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010314 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10315 "Front Playback Volume",
10316 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
10317 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010318 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010319 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10320 "Front Playback Switch",
10321 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
10322 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010323 return err;
10324 }
10325
Takashi Iwai82bc9552006-03-21 11:24:42 +010010326 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010327 if (nid) {
10328 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010329 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10330 "Speaker Playback Volume",
10331 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10332 HDA_OUTPUT));
10333 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010334 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010335 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10336 "Speaker Playback Switch",
10337 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10338 HDA_OUTPUT));
10339 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010340 return err;
10341 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010342 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10343 "Speaker Playback Switch",
10344 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10345 HDA_OUTPUT));
10346 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010347 return err;
10348 }
10349 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +020010350 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010351 if (nid) {
10352 /* spec->multiout.hp_nid = 2; */
10353 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010354 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10355 "Headphone Playback Volume",
10356 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10357 HDA_OUTPUT));
10358 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010359 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010360 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10361 "Headphone Playback Switch",
10362 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10363 HDA_OUTPUT));
10364 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010365 return err;
10366 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010367 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10368 "Headphone Playback Switch",
10369 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10370 HDA_OUTPUT));
10371 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010372 return err;
10373 }
10374 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010375 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010010376}
10377
10378/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010379#define alc262_auto_create_analog_input_ctls \
10380 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010010381
10382/*
10383 * generic initialization of ADC, input mixers and output mixers
10384 */
10385static struct hda_verb alc262_volume_init_verbs[] = {
10386 /*
10387 * Unmute ADC0-2 and set the default input to mic-in
10388 */
10389 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10390 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10391 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10392 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10393 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10394 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10395
Takashi Iwaicb53c622007-08-10 17:21:45 +020010396 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010397 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010398 * Note: PASD motherboards uses the Line In 2 as the input for
10399 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010400 */
10401 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010402 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10403 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10404 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10405 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10406 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010407
10408 /*
10409 * Set up output mixers (0x0c - 0x0f)
10410 */
10411 /* set vol=0 to output mixers */
10412 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10413 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10414 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020010415
Kailang Yangdf694da2005-12-05 19:42:22 +010010416 /* set up input amps for analog loopback */
10417 /* Amp Indices: DAC = 0, mixer = 1 */
10418 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10419 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10420 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10421 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10422 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10423 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10424
10425 /* FIXME: use matrix-type input source selection */
10426 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10427 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10428 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10429 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10430 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10431 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10432 /* Input mixer2 */
10433 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10434 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10435 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10436 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10437 /* Input mixer3 */
10438 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10439 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10440 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10441 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10442
10443 { }
10444};
10445
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010446static struct hda_verb alc262_HP_BPC_init_verbs[] = {
10447 /*
10448 * Unmute ADC0-2 and set the default input to mic-in
10449 */
10450 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10451 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10452 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10453 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10454 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10455 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10456
Takashi Iwaicb53c622007-08-10 17:21:45 +020010457 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010458 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010459 * Note: PASD motherboards uses the Line In 2 as the input for
10460 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010461 */
10462 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010463 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10464 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10465 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10466 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10467 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10468 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10469 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020010470
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010471 /*
10472 * Set up output mixers (0x0c - 0x0e)
10473 */
10474 /* set vol=0 to output mixers */
10475 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10476 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10477 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10478
10479 /* set up input amps for analog loopback */
10480 /* Amp Indices: DAC = 0, mixer = 1 */
10481 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10482 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10483 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10484 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10485 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10486 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10487
Takashi Iwaice875f02008-01-28 18:17:43 +010010488 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010489 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10490 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10491
10492 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10493 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10494
10495 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10496 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10497
10498 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10499 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10500 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10501 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10502 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10503
10504 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10505 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10506 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10507 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10508 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10509 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10510
10511
10512 /* FIXME: use matrix-type input source selection */
10513 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10514 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10515 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10516 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10517 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10518 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10519 /* Input mixer2 */
10520 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10521 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10522 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10523 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10524 /* Input mixer3 */
10525 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10526 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10527 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10528 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10529
Takashi Iwaice875f02008-01-28 18:17:43 +010010530 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10531
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010532 { }
10533};
10534
Kailang Yangcd7509a2007-01-26 18:33:17 +010010535static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
10536 /*
10537 * Unmute ADC0-2 and set the default input to mic-in
10538 */
10539 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10540 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10541 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10542 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10543 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10544 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10545
Takashi Iwaicb53c622007-08-10 17:21:45 +020010546 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010010547 * mixer widget
10548 * Note: PASD motherboards uses the Line In 2 as the input for front
10549 * panel mic (mic 2)
10550 */
10551 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010552 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10553 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10554 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10555 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10556 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10557 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10558 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10559 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010010560 /*
10561 * Set up output mixers (0x0c - 0x0e)
10562 */
10563 /* set vol=0 to output mixers */
10564 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10565 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10566 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10567
10568 /* set up input amps for analog loopback */
10569 /* Amp Indices: DAC = 0, mixer = 1 */
10570 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10571 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10572 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10573 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10574 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10575 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10576
10577
10578 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
10579 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
10580 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
10581 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
10582 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10583 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
10584 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
10585
10586 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10587 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10588
10589 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10590 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
10591
10592 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
10593 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10594 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10595 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10596 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10597 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10598
10599 /* FIXME: use matrix-type input source selection */
10600 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10601 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10602 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
10603 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
10604 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
10605 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
10606 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
10607 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10608 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
10609 /* Input mixer2 */
10610 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10611 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10612 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10613 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10614 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10615 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10616 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10617 /* Input mixer3 */
10618 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10619 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10620 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10621 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10622 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10623 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10624 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10625
Takashi Iwaice875f02008-01-28 18:17:43 +010010626 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10627
Kailang Yangcd7509a2007-01-26 18:33:17 +010010628 { }
10629};
10630
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010631static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
10632
10633 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
10634 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10635 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
10636
10637 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
10638 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10639 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10640 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10641
10642 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
10643 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10644 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10645 {}
10646};
10647
10648
Takashi Iwaicb53c622007-08-10 17:21:45 +020010649#ifdef CONFIG_SND_HDA_POWER_SAVE
10650#define alc262_loopbacks alc880_loopbacks
10651#endif
10652
Kailang Yangdf694da2005-12-05 19:42:22 +010010653/* pcm configuration: identiacal with ALC880 */
10654#define alc262_pcm_analog_playback alc880_pcm_analog_playback
10655#define alc262_pcm_analog_capture alc880_pcm_analog_capture
10656#define alc262_pcm_digital_playback alc880_pcm_digital_playback
10657#define alc262_pcm_digital_capture alc880_pcm_digital_capture
10658
10659/*
10660 * BIOS auto configuration
10661 */
10662static int alc262_parse_auto_config(struct hda_codec *codec)
10663{
10664 struct alc_spec *spec = codec->spec;
10665 int err;
10666 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
10667
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010668 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10669 alc262_ignore);
10670 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010671 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010672 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010010673 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010674 spec->multiout.max_channels = 2;
10675 spec->no_analog = 1;
10676 goto dig_only;
10677 }
Kailang Yangdf694da2005-12-05 19:42:22 +010010678 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010679 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010680 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
10681 if (err < 0)
10682 return err;
10683 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
10684 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010685 return err;
10686
10687 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10688
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010689 dig_only:
Takashi Iwai0852d7a2009-02-11 11:35:15 +010010690 if (spec->autocfg.dig_outs) {
Kailang Yangdf694da2005-12-05 19:42:22 +010010691 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
Takashi Iwai0852d7a2009-02-11 11:35:15 +010010692 spec->dig_out_type = spec->autocfg.dig_out_type[0];
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010693 }
Kailang Yangdf694da2005-12-05 19:42:22 +010010694 if (spec->autocfg.dig_in_pin)
10695 spec->dig_in_nid = ALC262_DIGIN_NID;
10696
Takashi Iwai603c4012008-07-30 15:01:44 +020010697 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010010698 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010010699
Takashi Iwaid88897e2008-10-31 15:01:37 +010010700 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020010701 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020010702 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010703
Takashi Iwai776e1842007-08-29 15:07:11 +020010704 err = alc_auto_add_mic_boost(codec);
10705 if (err < 0)
10706 return err;
10707
Takashi Iwai4a79ba32009-04-22 16:31:35 +020010708 alc_ssid_check(codec, 0x15, 0x14, 0x1b);
10709
Kailang Yangdf694da2005-12-05 19:42:22 +010010710 return 1;
10711}
10712
10713#define alc262_auto_init_multi_out alc882_auto_init_multi_out
10714#define alc262_auto_init_hp_out alc882_auto_init_hp_out
10715#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020010716#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010010717
10718
10719/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010720static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010010721{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010722 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010010723 alc262_auto_init_multi_out(codec);
10724 alc262_auto_init_hp_out(codec);
10725 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020010726 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010727 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020010728 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010010729}
10730
10731/*
10732 * configuration and preset
10733 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010734static const char *alc262_models[ALC262_MODEL_LAST] = {
10735 [ALC262_BASIC] = "basic",
10736 [ALC262_HIPPO] = "hippo",
10737 [ALC262_HIPPO_1] = "hippo_1",
10738 [ALC262_FUJITSU] = "fujitsu",
10739 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010010740 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010010741 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010010742 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010743 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020010744 [ALC262_BENQ_T31] = "benq-t31",
10745 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020010746 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010747 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020010748 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010010749 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010750 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000010751 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010752 [ALC262_AUTO] = "auto",
10753};
10754
10755static struct snd_pci_quirk alc262_cfg_tbl[] = {
10756 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010757 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010010758 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
10759 ALC262_HP_BPC),
10760 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
10761 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010010762 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
10763 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010764 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010765 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010766 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010767 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010768 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010769 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010770 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010771 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010772 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
10773 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
10774 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010775 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
10776 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010010777 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010778 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010779 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010780 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010010781 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwaif872a912009-02-26 00:57:01 +010010782 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
10783 ALC262_SONY_ASSAMD),
Akio Idehara36ca6e12008-06-09 22:57:40 +090010784 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010785 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020010786 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010787 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010010788 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000010789 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010010790 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
10791 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110010792 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010010793 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010794 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020010795 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010796 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010010797 {}
10798};
10799
10800static struct alc_config_preset alc262_presets[] = {
10801 [ALC262_BASIC] = {
10802 .mixers = { alc262_base_mixer },
10803 .init_verbs = { alc262_init_verbs },
10804 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10805 .dac_nids = alc262_dac_nids,
10806 .hp_nid = 0x03,
10807 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10808 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010010809 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010010810 },
Kailang Yangccc656c2006-10-17 12:32:26 +020010811 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020010812 .mixers = { alc262_hippo_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +020010813 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
10814 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10815 .dac_nids = alc262_dac_nids,
10816 .hp_nid = 0x03,
10817 .dig_out_nid = ALC262_DIGOUT_NID,
10818 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10819 .channel_mode = alc262_modes,
10820 .input_mux = &alc262_capture_source,
10821 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020010822 .init_hook = alc262_hippo_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +020010823 },
10824 [ALC262_HIPPO_1] = {
10825 .mixers = { alc262_hippo1_mixer },
10826 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
10827 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10828 .dac_nids = alc262_dac_nids,
10829 .hp_nid = 0x02,
10830 .dig_out_nid = ALC262_DIGOUT_NID,
10831 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10832 .channel_mode = alc262_modes,
10833 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020010834 .unsol_event = alc262_hippo_unsol_event,
10835 .init_hook = alc262_hippo1_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +020010836 },
Takashi Iwai834be882006-03-01 14:16:17 +010010837 [ALC262_FUJITSU] = {
10838 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010839 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
10840 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010010841 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10842 .dac_nids = alc262_dac_nids,
10843 .hp_nid = 0x03,
10844 .dig_out_nid = ALC262_DIGOUT_NID,
10845 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10846 .channel_mode = alc262_modes,
10847 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010848 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010849 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010010850 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010851 [ALC262_HP_BPC] = {
10852 .mixers = { alc262_HP_BPC_mixer },
10853 .init_verbs = { alc262_HP_BPC_init_verbs },
10854 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10855 .dac_nids = alc262_dac_nids,
10856 .hp_nid = 0x03,
10857 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10858 .channel_mode = alc262_modes,
10859 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010860 .unsol_event = alc262_hp_bpc_unsol_event,
10861 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010862 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010010863 [ALC262_HP_BPC_D7000_WF] = {
10864 .mixers = { alc262_HP_BPC_WildWest_mixer },
10865 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
10866 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10867 .dac_nids = alc262_dac_nids,
10868 .hp_nid = 0x03,
10869 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10870 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020010871 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010872 .unsol_event = alc262_hp_wildwest_unsol_event,
10873 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010874 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010010875 [ALC262_HP_BPC_D7000_WL] = {
10876 .mixers = { alc262_HP_BPC_WildWest_mixer,
10877 alc262_HP_BPC_WildWest_option_mixer },
10878 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
10879 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10880 .dac_nids = alc262_dac_nids,
10881 .hp_nid = 0x03,
10882 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10883 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020010884 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010885 .unsol_event = alc262_hp_wildwest_unsol_event,
10886 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010887 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010888 [ALC262_HP_TC_T5735] = {
10889 .mixers = { alc262_hp_t5735_mixer },
10890 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
10891 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10892 .dac_nids = alc262_dac_nids,
10893 .hp_nid = 0x03,
10894 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10895 .channel_mode = alc262_modes,
10896 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010897 .unsol_event = alc_automute_amp_unsol_event,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010898 .init_hook = alc262_hp_t5735_init_hook,
Kailang Yang8c427222008-01-10 13:03:59 +010010899 },
10900 [ALC262_HP_RP5700] = {
10901 .mixers = { alc262_hp_rp5700_mixer },
10902 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
10903 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10904 .dac_nids = alc262_dac_nids,
10905 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10906 .channel_mode = alc262_modes,
10907 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010908 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010909 [ALC262_BENQ_ED8] = {
10910 .mixers = { alc262_base_mixer },
10911 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
10912 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10913 .dac_nids = alc262_dac_nids,
10914 .hp_nid = 0x03,
10915 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10916 .channel_mode = alc262_modes,
10917 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010918 },
Kailang Yang272a5272007-05-14 11:00:38 +020010919 [ALC262_SONY_ASSAMD] = {
10920 .mixers = { alc262_sony_mixer },
10921 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
10922 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10923 .dac_nids = alc262_dac_nids,
10924 .hp_nid = 0x02,
10925 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10926 .channel_mode = alc262_modes,
10927 .input_mux = &alc262_capture_source,
10928 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020010929 .init_hook = alc262_hippo_init_hook,
Kailang Yang83c34212007-07-05 11:43:05 +020010930 },
10931 [ALC262_BENQ_T31] = {
10932 .mixers = { alc262_benq_t31_mixer },
10933 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
10934 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10935 .dac_nids = alc262_dac_nids,
10936 .hp_nid = 0x03,
10937 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10938 .channel_mode = alc262_modes,
10939 .input_mux = &alc262_capture_source,
10940 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020010941 .init_hook = alc262_hippo_init_hook,
Kailang Yangea1fb292008-08-26 12:58:38 +020010942 },
Tobin Davisf651b502007-10-26 12:40:47 +020010943 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010944 .mixers = { alc262_ultra_mixer },
10945 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010946 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020010947 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10948 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020010949 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10950 .channel_mode = alc262_modes,
10951 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010952 .adc_nids = alc262_adc_nids, /* ADC0 */
10953 .capsrc_nids = alc262_capsrc_nids,
10954 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020010955 .unsol_event = alc262_ultra_unsol_event,
10956 .init_hook = alc262_ultra_automute,
10957 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010010958 [ALC262_LENOVO_3000] = {
10959 .mixers = { alc262_lenovo_3000_mixer },
10960 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
10961 alc262_lenovo_3000_unsol_verbs },
10962 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10963 .dac_nids = alc262_dac_nids,
10964 .hp_nid = 0x03,
10965 .dig_out_nid = ALC262_DIGOUT_NID,
10966 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10967 .channel_mode = alc262_modes,
10968 .input_mux = &alc262_fujitsu_capture_source,
10969 .unsol_event = alc262_lenovo_3000_unsol_event,
10970 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010971 [ALC262_NEC] = {
10972 .mixers = { alc262_nec_mixer },
10973 .init_verbs = { alc262_nec_verbs },
10974 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10975 .dac_nids = alc262_dac_nids,
10976 .hp_nid = 0x03,
10977 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10978 .channel_mode = alc262_modes,
10979 .input_mux = &alc262_capture_source,
10980 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020010981 [ALC262_TOSHIBA_S06] = {
10982 .mixers = { alc262_toshiba_s06_mixer },
10983 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
10984 alc262_eapd_verbs },
10985 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10986 .capsrc_nids = alc262_dmic_capsrc_nids,
10987 .dac_nids = alc262_dac_nids,
10988 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
10989 .dig_out_nid = ALC262_DIGOUT_NID,
10990 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10991 .channel_mode = alc262_modes,
10992 .input_mux = &alc262_dmic_capture_source,
10993 .unsol_event = alc262_toshiba_s06_unsol_event,
10994 .init_hook = alc262_toshiba_s06_init_hook,
10995 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010996 [ALC262_TOSHIBA_RX1] = {
10997 .mixers = { alc262_toshiba_rx1_mixer },
10998 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
10999 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11000 .dac_nids = alc262_dac_nids,
11001 .hp_nid = 0x03,
11002 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11003 .channel_mode = alc262_modes,
11004 .input_mux = &alc262_capture_source,
11005 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011006 .init_hook = alc262_hippo_init_hook,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011007 },
Tony Vroonba340e82009-02-02 19:01:30 +000011008 [ALC262_TYAN] = {
11009 .mixers = { alc262_tyan_mixer },
11010 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
11011 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11012 .dac_nids = alc262_dac_nids,
11013 .hp_nid = 0x02,
11014 .dig_out_nid = ALC262_DIGOUT_NID,
11015 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11016 .channel_mode = alc262_modes,
11017 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011018 .unsol_event = alc_automute_amp_unsol_event,
11019 .init_hook = alc262_tyan_init_hook,
Tony Vroonba340e82009-02-02 19:01:30 +000011020 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011021};
11022
11023static int patch_alc262(struct hda_codec *codec)
11024{
11025 struct alc_spec *spec;
11026 int board_config;
11027 int err;
11028
Robert P. J. Daydc041e02006-12-19 14:44:15 +010011029 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010011030 if (spec == NULL)
11031 return -ENOMEM;
11032
11033 codec->spec = spec;
11034#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011035 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
11036 * under-run
11037 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011038 {
11039 int tmp;
11040 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11041 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
11042 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11043 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
11044 }
11045#endif
11046
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020011047 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
11048
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011049 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
11050 alc262_models,
11051 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010011052
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011053 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011054 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
11055 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011056 board_config = ALC262_AUTO;
11057 }
11058
11059 if (board_config == ALC262_AUTO) {
11060 /* automatic parse from the BIOS config */
11061 err = alc262_parse_auto_config(codec);
11062 if (err < 0) {
11063 alc_free(codec);
11064 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011065 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011066 printk(KERN_INFO
11067 "hda_codec: Cannot set up configuration "
11068 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011069 board_config = ALC262_BASIC;
11070 }
11071 }
11072
Takashi Iwai07eba612009-02-19 08:06:35 +010011073 if (!spec->no_analog) {
11074 err = snd_hda_attach_beep_device(codec, 0x1);
11075 if (err < 0) {
11076 alc_free(codec);
11077 return err;
11078 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090011079 }
11080
Kailang Yangdf694da2005-12-05 19:42:22 +010011081 if (board_config != ALC262_AUTO)
11082 setup_preset(spec, &alc262_presets[board_config]);
11083
11084 spec->stream_name_analog = "ALC262 Analog";
11085 spec->stream_analog_playback = &alc262_pcm_analog_playback;
11086 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020011087
Kailang Yangdf694da2005-12-05 19:42:22 +010011088 spec->stream_name_digital = "ALC262 Digital";
11089 spec->stream_digital_playback = &alc262_pcm_digital_playback;
11090 spec->stream_digital_capture = &alc262_pcm_digital_capture;
11091
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011092 spec->capture_style = CAPT_MIX;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011093 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011094 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +010011095 unsigned int wcap = get_wcaps(codec, 0x07);
11096
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011097 /* get type */
11098 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +010011099 if (wcap != AC_WID_AUD_IN) {
11100 spec->adc_nids = alc262_adc_nids_alt;
11101 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwai88c71a92008-02-14 17:27:17 +010011102 spec->capsrc_nids = alc262_capsrc_nids_alt;
Kailang Yangdf694da2005-12-05 19:42:22 +010011103 } else {
11104 spec->adc_nids = alc262_adc_nids;
11105 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
Takashi Iwai88c71a92008-02-14 17:27:17 +010011106 spec->capsrc_nids = alc262_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010011107 }
11108 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011109 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011110 set_capture_mixer(spec);
Takashi Iwai07eba612009-02-19 08:06:35 +010011111 if (!spec->no_analog)
11112 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010011113
Takashi Iwai2134ea42008-01-10 16:53:55 +010011114 spec->vmaster_nid = 0x0c;
11115
Kailang Yangdf694da2005-12-05 19:42:22 +010011116 codec->patch_ops = alc_patch_ops;
11117 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011118 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011119#ifdef CONFIG_SND_HDA_POWER_SAVE
11120 if (!spec->loopback.amplist)
11121 spec->loopback.amplist = alc262_loopbacks;
11122#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010011123 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020011124
Kailang Yangdf694da2005-12-05 19:42:22 +010011125 return 0;
11126}
11127
Kailang Yangdf694da2005-12-05 19:42:22 +010011128/*
Kailang Yanga361d842007-06-05 12:30:55 +020011129 * ALC268 channel source setting (2 channel)
11130 */
11131#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
11132#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020011133
Kailang Yanga361d842007-06-05 12:30:55 +020011134static hda_nid_t alc268_dac_nids[2] = {
11135 /* front, hp */
11136 0x02, 0x03
11137};
11138
11139static hda_nid_t alc268_adc_nids[2] = {
11140 /* ADC0-1 */
11141 0x08, 0x07
11142};
11143
11144static hda_nid_t alc268_adc_nids_alt[1] = {
11145 /* ADC0 */
11146 0x08
11147};
11148
Takashi Iwaie1406342008-02-11 18:32:32 +010011149static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
11150
Kailang Yanga361d842007-06-05 12:30:55 +020011151static struct snd_kcontrol_new alc268_base_mixer[] = {
11152 /* output mixer control */
11153 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11154 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11155 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11156 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011157 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11158 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11159 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020011160 { }
11161};
11162
Takashi Iwai42171c12009-05-08 14:11:43 +020011163static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
11164 /* output mixer control */
11165 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11166 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11167 ALC262_HIPPO_MASTER_SWITCH,
11168 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11169 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11170 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11171 { }
11172};
11173
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011174/* bind Beep switches of both NID 0x0f and 0x10 */
11175static struct hda_bind_ctls alc268_bind_beep_sw = {
11176 .ops = &snd_hda_bind_sw,
11177 .values = {
11178 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
11179 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
11180 0
11181 },
11182};
11183
11184static struct snd_kcontrol_new alc268_beep_mixer[] = {
11185 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
11186 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
11187 { }
11188};
11189
Kailang Yangd1a991a2007-08-15 16:21:59 +020011190static struct hda_verb alc268_eapd_verbs[] = {
11191 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11192 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11193 { }
11194};
11195
Takashi Iwaid2738092007-08-16 14:59:45 +020011196/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020011197static struct hda_verb alc268_toshiba_verbs[] = {
11198 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11199 { } /* end */
11200};
11201
Kailang Yang8ef355d2008-08-26 13:10:22 +020011202static struct hda_input_mux alc268_acer_lc_capture_source = {
11203 .num_items = 2,
11204 .items = {
11205 { "i-Mic", 0x6 },
11206 { "E-Mic", 0x0 },
11207 },
11208};
11209
Takashi Iwaid2738092007-08-16 14:59:45 +020011210/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020011211/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020011212static struct hda_bind_ctls alc268_acer_bind_master_vol = {
11213 .ops = &snd_hda_bind_vol,
11214 .values = {
11215 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
11216 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
11217 0
11218 },
11219};
11220
Takashi Iwai889c4392007-08-23 18:56:52 +020011221/* mute/unmute internal speaker according to the hp jack and mute state */
11222static void alc268_acer_automute(struct hda_codec *codec, int force)
11223{
11224 struct alc_spec *spec = codec->spec;
11225 unsigned int mute;
11226
11227 if (force || !spec->sense_updated) {
11228 unsigned int present;
11229 present = snd_hda_codec_read(codec, 0x14, 0,
11230 AC_VERB_GET_PIN_SENSE, 0);
11231 spec->jack_present = (present & 0x80000000) != 0;
11232 spec->sense_updated = 1;
11233 }
11234 if (spec->jack_present)
11235 mute = HDA_AMP_MUTE; /* mute internal speaker */
11236 else /* unmute internal speaker if necessary */
11237 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
11238 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11239 HDA_AMP_MUTE, mute);
11240}
11241
11242
11243/* bind hp and internal speaker mute (with plug check) */
11244static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
11245 struct snd_ctl_elem_value *ucontrol)
11246{
11247 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11248 long *valp = ucontrol->value.integer.value;
11249 int change;
11250
11251 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
11252 HDA_AMP_MUTE,
11253 valp[0] ? 0 : HDA_AMP_MUTE);
11254 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
11255 HDA_AMP_MUTE,
11256 valp[1] ? 0 : HDA_AMP_MUTE);
11257 if (change)
11258 alc268_acer_automute(codec, 0);
11259 return change;
11260}
Takashi Iwaid2738092007-08-16 14:59:45 +020011261
Kailang Yang8ef355d2008-08-26 13:10:22 +020011262static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
11263 /* output mixer control */
11264 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11265 {
11266 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11267 .name = "Master Playback Switch",
11268 .info = snd_hda_mixer_amp_switch_info,
11269 .get = snd_hda_mixer_amp_switch_get,
11270 .put = alc268_acer_master_sw_put,
11271 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11272 },
11273 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
11274 { }
11275};
11276
Takashi Iwaid2738092007-08-16 14:59:45 +020011277static struct snd_kcontrol_new alc268_acer_mixer[] = {
11278 /* output mixer control */
11279 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11280 {
11281 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11282 .name = "Master Playback Switch",
11283 .info = snd_hda_mixer_amp_switch_info,
11284 .get = snd_hda_mixer_amp_switch_get,
11285 .put = alc268_acer_master_sw_put,
11286 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11287 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011288 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11289 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11290 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020011291 { }
11292};
11293
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011294static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
11295 /* output mixer control */
11296 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11297 {
11298 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11299 .name = "Master Playback Switch",
11300 .info = snd_hda_mixer_amp_switch_info,
11301 .get = snd_hda_mixer_amp_switch_get,
11302 .put = alc268_acer_master_sw_put,
11303 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11304 },
11305 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11306 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11307 { }
11308};
11309
Kailang Yang8ef355d2008-08-26 13:10:22 +020011310static struct hda_verb alc268_acer_aspire_one_verbs[] = {
11311 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11312 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11313 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11314 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11315 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
11316 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
11317 { }
11318};
11319
Takashi Iwaid2738092007-08-16 14:59:45 +020011320static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011321 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
11322 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020011323 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11324 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011325 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11326 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020011327 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11328 { }
11329};
11330
11331/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020011332#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
11333#define alc268_toshiba_init_hook alc262_hippo_init_hook
Takashi Iwaid2738092007-08-16 14:59:45 +020011334
11335static void alc268_acer_unsol_event(struct hda_codec *codec,
11336 unsigned int res)
11337{
Takashi Iwai889c4392007-08-23 18:56:52 +020011338 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020011339 return;
11340 alc268_acer_automute(codec, 1);
11341}
11342
Takashi Iwai889c4392007-08-23 18:56:52 +020011343static void alc268_acer_init_hook(struct hda_codec *codec)
11344{
11345 alc268_acer_automute(codec, 1);
11346}
11347
Kailang Yang8ef355d2008-08-26 13:10:22 +020011348/* toggle speaker-output according to the hp-jack state */
11349static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
11350{
11351 unsigned int present;
11352 unsigned char bits;
11353
11354 present = snd_hda_codec_read(codec, 0x15, 0,
11355 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11356 bits = present ? AMP_IN_MUTE(0) : 0;
11357 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
11358 AMP_IN_MUTE(0), bits);
11359 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
11360 AMP_IN_MUTE(0), bits);
11361}
11362
11363
11364static void alc268_acer_mic_automute(struct hda_codec *codec)
11365{
11366 unsigned int present;
11367
11368 present = snd_hda_codec_read(codec, 0x18, 0,
11369 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11370 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_CONNECT_SEL,
11371 present ? 0x0 : 0x6);
11372}
11373
11374static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
11375 unsigned int res)
11376{
11377 if ((res >> 26) == ALC880_HP_EVENT)
11378 alc268_aspire_one_speaker_automute(codec);
11379 if ((res >> 26) == ALC880_MIC_EVENT)
11380 alc268_acer_mic_automute(codec);
11381}
11382
11383static void alc268_acer_lc_init_hook(struct hda_codec *codec)
11384{
11385 alc268_aspire_one_speaker_automute(codec);
11386 alc268_acer_mic_automute(codec);
11387}
11388
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011389static struct snd_kcontrol_new alc268_dell_mixer[] = {
11390 /* output mixer control */
11391 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11392 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11393 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11394 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11395 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11396 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11397 { }
11398};
11399
11400static struct hda_verb alc268_dell_verbs[] = {
11401 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11402 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11403 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11404 { }
11405};
11406
11407/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011408static void alc268_dell_init_hook(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011409{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011410 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011411
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011412 spec->autocfg.hp_pins[0] = 0x15;
11413 spec->autocfg.speaker_pins[0] = 0x14;
11414 alc_automute_pin(codec);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011415}
11416
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011417static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
11418 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11419 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11420 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11421 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11422 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11423 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
11424 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
11425 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11426 { }
11427};
11428
11429static struct hda_verb alc267_quanta_il1_verbs[] = {
11430 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11431 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
11432 { }
11433};
11434
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011435static void alc267_quanta_il1_mic_automute(struct hda_codec *codec)
11436{
11437 unsigned int present;
11438
11439 present = snd_hda_codec_read(codec, 0x18, 0,
11440 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11441 snd_hda_codec_write(codec, 0x23, 0,
11442 AC_VERB_SET_CONNECT_SEL,
11443 present ? 0x00 : 0x01);
11444}
11445
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011446static void alc267_quanta_il1_init_hook(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011447{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011448 struct alc_spec *spec = codec->spec;
11449
11450 spec->autocfg.hp_pins[0] = 0x15;
11451 spec->autocfg.speaker_pins[0] = 0x14;
11452 alc_automute_pin(codec);
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011453 alc267_quanta_il1_mic_automute(codec);
11454}
11455
11456static void alc267_quanta_il1_unsol_event(struct hda_codec *codec,
11457 unsigned int res)
11458{
11459 switch (res >> 26) {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011460 case ALC880_MIC_EVENT:
11461 alc267_quanta_il1_mic_automute(codec);
11462 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011463 default:
11464 alc_sku_unsol_event(codec, res);
11465 break;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011466 }
11467}
11468
Kailang Yanga361d842007-06-05 12:30:55 +020011469/*
11470 * generic initialization of ADC, input mixers and output mixers
11471 */
11472static struct hda_verb alc268_base_init_verbs[] = {
11473 /* Unmute DAC0-1 and set vol = 0 */
11474 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011475 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011476
11477 /*
11478 * Set up output mixers (0x0c - 0x0e)
11479 */
11480 /* set vol=0 to output mixers */
11481 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020011482 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
11483
11484 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11485 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11486
11487 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11488 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11489 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11490 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11491 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11492 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11493 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11494 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11495
11496 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11497 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11498 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11499 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011500 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011501
11502 /* set PCBEEP vol = 0, mute connections */
11503 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11504 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11505 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020011506
Jiang Zhea9b3aa82007-12-20 13:13:13 +010011507 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020011508
Jiang Zhea9b3aa82007-12-20 13:13:13 +010011509 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
11510 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11511 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
11512 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011513
Kailang Yanga361d842007-06-05 12:30:55 +020011514 { }
11515};
11516
11517/*
11518 * generic initialization of ADC, input mixers and output mixers
11519 */
11520static struct hda_verb alc268_volume_init_verbs[] = {
11521 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010011522 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11523 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011524
11525 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11526 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11527 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11528 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11529 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11530
Kailang Yanga361d842007-06-05 12:30:55 +020011531 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020011532 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11533 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11534
11535 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011536 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011537
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011538 /* set PCBEEP vol = 0, mute connections */
11539 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11540 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11541 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020011542
11543 { }
11544};
11545
Kailang Yanga361d842007-06-05 12:30:55 +020011546static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
11547 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11548 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11549 {
11550 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11551 /* The multiple "Capture Source" controls confuse alsamixer
11552 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020011553 */
11554 /* .name = "Capture Source", */
11555 .name = "Input Source",
11556 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011557 .info = alc_mux_enum_info,
11558 .get = alc_mux_enum_get,
11559 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020011560 },
11561 { } /* end */
11562};
11563
11564static struct snd_kcontrol_new alc268_capture_mixer[] = {
11565 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11566 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11567 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
11568 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
11569 {
11570 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11571 /* The multiple "Capture Source" controls confuse alsamixer
11572 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020011573 */
11574 /* .name = "Capture Source", */
11575 .name = "Input Source",
11576 .count = 2,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011577 .info = alc_mux_enum_info,
11578 .get = alc_mux_enum_get,
11579 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020011580 },
11581 { } /* end */
11582};
11583
11584static struct hda_input_mux alc268_capture_source = {
11585 .num_items = 4,
11586 .items = {
11587 { "Mic", 0x0 },
11588 { "Front Mic", 0x1 },
11589 { "Line", 0x2 },
11590 { "CD", 0x3 },
11591 },
11592};
11593
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011594static struct hda_input_mux alc268_acer_capture_source = {
11595 .num_items = 3,
11596 .items = {
11597 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011598 { "Internal Mic", 0x1 },
11599 { "Line", 0x2 },
11600 },
11601};
11602
11603static struct hda_input_mux alc268_acer_dmic_capture_source = {
11604 .num_items = 3,
11605 .items = {
11606 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011607 { "Internal Mic", 0x6 },
11608 { "Line", 0x2 },
11609 },
11610};
11611
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011612#ifdef CONFIG_SND_DEBUG
11613static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011614 /* Volume widgets */
11615 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11616 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11617 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
11618 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
11619 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
11620 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
11621 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
11622 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
11623 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
11624 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
11625 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
11626 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
11627 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010011628 /* The below appears problematic on some hardwares */
11629 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011630 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11631 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
11632 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
11633 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
11634
11635 /* Modes for retasking pin widgets */
11636 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
11637 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
11638 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
11639 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
11640
11641 /* Controls for GPIO pins, assuming they are configured as outputs */
11642 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
11643 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
11644 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
11645 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
11646
11647 /* Switches to allow the digital SPDIF output pin to be enabled.
11648 * The ALC268 does not have an SPDIF input.
11649 */
11650 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
11651
11652 /* A switch allowing EAPD to be enabled. Some laptops seem to use
11653 * this output to turn on an external amplifier.
11654 */
11655 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
11656 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
11657
11658 { } /* end */
11659};
11660#endif
11661
Kailang Yanga361d842007-06-05 12:30:55 +020011662/* create input playback/capture controls for the given pin */
11663static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
11664 const char *ctlname, int idx)
11665{
11666 char name[32];
11667 int err;
11668
11669 sprintf(name, "%s Playback Volume", ctlname);
11670 if (nid == 0x14) {
11671 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11672 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
11673 HDA_OUTPUT));
11674 if (err < 0)
11675 return err;
11676 } else if (nid == 0x15) {
11677 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11678 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
11679 HDA_OUTPUT));
11680 if (err < 0)
11681 return err;
11682 } else
11683 return -1;
11684 sprintf(name, "%s Playback Switch", ctlname);
11685 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
11686 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
11687 if (err < 0)
11688 return err;
11689 return 0;
11690}
11691
11692/* add playback controls from the parsed DAC table */
11693static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
11694 const struct auto_pin_cfg *cfg)
11695{
11696 hda_nid_t nid;
11697 int err;
11698
11699 spec->multiout.num_dacs = 2; /* only use one dac */
11700 spec->multiout.dac_nids = spec->private_dac_nids;
11701 spec->multiout.dac_nids[0] = 2;
11702 spec->multiout.dac_nids[1] = 3;
11703
11704 nid = cfg->line_out_pins[0];
11705 if (nid)
Kailang Yangea1fb292008-08-26 12:58:38 +020011706 alc268_new_analog_output(spec, nid, "Front", 0);
Kailang Yanga361d842007-06-05 12:30:55 +020011707
11708 nid = cfg->speaker_pins[0];
11709 if (nid == 0x1d) {
11710 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11711 "Speaker Playback Volume",
11712 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
11713 if (err < 0)
11714 return err;
11715 }
11716 nid = cfg->hp_pins[0];
11717 if (nid)
11718 alc268_new_analog_output(spec, nid, "Headphone", 0);
11719
11720 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
11721 if (nid == 0x16) {
11722 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11723 "Mono Playback Switch",
11724 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
11725 if (err < 0)
11726 return err;
11727 }
Kailang Yangea1fb292008-08-26 12:58:38 +020011728 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020011729}
11730
11731/* create playback/capture controls for input pins */
11732static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
11733 const struct auto_pin_cfg *cfg)
11734{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011735 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020011736 int i, idx1;
11737
11738 for (i = 0; i < AUTO_PIN_LAST; i++) {
11739 switch(cfg->input_pins[i]) {
11740 case 0x18:
11741 idx1 = 0; /* Mic 1 */
11742 break;
11743 case 0x19:
11744 idx1 = 1; /* Mic 2 */
11745 break;
11746 case 0x1a:
11747 idx1 = 2; /* Line In */
11748 break;
Kailang Yangea1fb292008-08-26 12:58:38 +020011749 case 0x1c:
Kailang Yanga361d842007-06-05 12:30:55 +020011750 idx1 = 3; /* CD */
11751 break;
Takashi Iwai7194cae2008-03-06 16:58:17 +010011752 case 0x12:
11753 case 0x13:
11754 idx1 = 6; /* digital mics */
11755 break;
Kailang Yanga361d842007-06-05 12:30:55 +020011756 default:
11757 continue;
11758 }
11759 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
11760 imux->items[imux->num_items].index = idx1;
Kailang Yangea1fb292008-08-26 12:58:38 +020011761 imux->num_items++;
Kailang Yanga361d842007-06-05 12:30:55 +020011762 }
11763 return 0;
11764}
11765
11766static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
11767{
11768 struct alc_spec *spec = codec->spec;
11769 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
11770 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
11771 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
11772 unsigned int dac_vol1, dac_vol2;
11773
11774 if (speaker_nid) {
11775 snd_hda_codec_write(codec, speaker_nid, 0,
11776 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
11777 snd_hda_codec_write(codec, 0x0f, 0,
11778 AC_VERB_SET_AMP_GAIN_MUTE,
11779 AMP_IN_UNMUTE(1));
11780 snd_hda_codec_write(codec, 0x10, 0,
11781 AC_VERB_SET_AMP_GAIN_MUTE,
11782 AMP_IN_UNMUTE(1));
11783 } else {
11784 snd_hda_codec_write(codec, 0x0f, 0,
11785 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
11786 snd_hda_codec_write(codec, 0x10, 0,
11787 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
11788 }
11789
11790 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020011791 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020011792 dac_vol2 = AMP_OUT_ZERO;
11793 else if (line_nid == 0x15)
11794 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020011795 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020011796 dac_vol2 = AMP_OUT_ZERO;
11797 else if (hp_nid == 0x15)
11798 dac_vol1 = AMP_OUT_ZERO;
11799 if (line_nid != 0x16 || hp_nid != 0x16 ||
11800 spec->autocfg.line_out_pins[1] != 0x16 ||
11801 spec->autocfg.line_out_pins[2] != 0x16)
11802 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
11803
11804 snd_hda_codec_write(codec, 0x02, 0,
11805 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
11806 snd_hda_codec_write(codec, 0x03, 0,
11807 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
11808}
11809
11810/* pcm configuration: identiacal with ALC880 */
11811#define alc268_pcm_analog_playback alc880_pcm_analog_playback
11812#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010011813#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020011814#define alc268_pcm_digital_playback alc880_pcm_digital_playback
11815
11816/*
11817 * BIOS auto configuration
11818 */
11819static int alc268_parse_auto_config(struct hda_codec *codec)
11820{
11821 struct alc_spec *spec = codec->spec;
11822 int err;
11823 static hda_nid_t alc268_ignore[] = { 0 };
11824
11825 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11826 alc268_ignore);
11827 if (err < 0)
11828 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010011829 if (!spec->autocfg.line_outs) {
11830 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
11831 spec->multiout.max_channels = 2;
11832 spec->no_analog = 1;
11833 goto dig_only;
11834 }
Kailang Yanga361d842007-06-05 12:30:55 +020011835 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010011836 }
Kailang Yanga361d842007-06-05 12:30:55 +020011837 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
11838 if (err < 0)
11839 return err;
11840 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
11841 if (err < 0)
11842 return err;
11843
11844 spec->multiout.max_channels = 2;
11845
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010011846 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020011847 /* digital only support output */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010011848 if (spec->autocfg.dig_outs) {
Kailang Yanga361d842007-06-05 12:30:55 +020011849 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010011850 spec->dig_out_type = spec->autocfg.dig_out_type[0];
11851 }
Takashi Iwai603c4012008-07-30 15:01:44 +020011852 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011853 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020011854
Takashi Iwai892981f2009-03-02 08:04:35 +010011855 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011856 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011857
Takashi Iwaid88897e2008-10-31 15:01:37 +010011858 add_verb(spec, alc268_volume_init_verbs);
Kailang Yanga361d842007-06-05 12:30:55 +020011859 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011860 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020011861
Takashi Iwai776e1842007-08-29 15:07:11 +020011862 err = alc_auto_add_mic_boost(codec);
11863 if (err < 0)
11864 return err;
11865
Kailang Yanga361d842007-06-05 12:30:55 +020011866 return 1;
11867}
11868
11869#define alc268_auto_init_multi_out alc882_auto_init_multi_out
11870#define alc268_auto_init_hp_out alc882_auto_init_hp_out
11871#define alc268_auto_init_analog_input alc882_auto_init_analog_input
11872
11873/* init callback for auto-configuration model -- overriding the default init */
11874static void alc268_auto_init(struct hda_codec *codec)
11875{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011876 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020011877 alc268_auto_init_multi_out(codec);
11878 alc268_auto_init_hp_out(codec);
11879 alc268_auto_init_mono_speaker_out(codec);
11880 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011881 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020011882 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020011883}
11884
11885/*
11886 * configuration and preset
11887 */
11888static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011889 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020011890 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020011891 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020011892 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011893 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020011894 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011895 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011896 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011897#ifdef CONFIG_SND_DEBUG
11898 [ALC268_TEST] = "test",
11899#endif
Kailang Yanga361d842007-06-05 12:30:55 +020011900 [ALC268_AUTO] = "auto",
11901};
11902
11903static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020011904 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011905 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010011906 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011907 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010011908 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020011909 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
11910 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011911 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Takashi Iwai57d13922009-01-08 15:52:09 +010011912 SND_PCI_QUIRK(0x1028, 0x02b0, "Dell Inspiron Mini9", ALC268_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011913 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
Kailang Yanga361d842007-06-05 12:30:55 +020011914 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Kailang Yangd1a991a2007-08-15 16:21:59 +020011915 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
Takashi Iwai8e7f00f2007-09-07 10:58:58 +020011916 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
Travis Place2346d0c2008-09-01 08:24:00 +020011917 SND_PCI_QUIRK(0x1179, 0xff64, "TOSHIBA L305", ALC268_TOSHIBA),
Tony Vroon378bd6a2008-06-04 12:08:30 +020011918 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020011919 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011920 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011921 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Kailang Yanga361d842007-06-05 12:30:55 +020011922 {}
11923};
11924
11925static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011926 [ALC267_QUANTA_IL1] = {
Takashi Iwai22971e32009-02-10 11:56:44 +010011927 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011928 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11929 alc267_quanta_il1_verbs },
11930 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11931 .dac_nids = alc268_dac_nids,
11932 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11933 .adc_nids = alc268_adc_nids_alt,
11934 .hp_nid = 0x03,
11935 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11936 .channel_mode = alc268_modes,
11937 .input_mux = &alc268_capture_source,
11938 .unsol_event = alc267_quanta_il1_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011939 .init_hook = alc267_quanta_il1_init_hook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011940 },
Kailang Yanga361d842007-06-05 12:30:55 +020011941 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011942 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
11943 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020011944 .init_verbs = { alc268_base_init_verbs },
11945 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11946 .dac_nids = alc268_dac_nids,
11947 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11948 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011949 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020011950 .hp_nid = 0x03,
11951 .dig_out_nid = ALC268_DIGOUT_NID,
11952 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11953 .channel_mode = alc268_modes,
11954 .input_mux = &alc268_capture_source,
11955 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020011956 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011957 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011958 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020011959 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11960 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020011961 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11962 .dac_nids = alc268_dac_nids,
11963 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11964 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011965 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020011966 .hp_nid = 0x03,
11967 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11968 .channel_mode = alc268_modes,
11969 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020011970 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011971 .init_hook = alc268_toshiba_init_hook,
Takashi Iwaid2738092007-08-16 14:59:45 +020011972 },
11973 [ALC268_ACER] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011974 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
11975 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020011976 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11977 alc268_acer_verbs },
11978 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11979 .dac_nids = alc268_dac_nids,
11980 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11981 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011982 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020011983 .hp_nid = 0x02,
11984 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11985 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011986 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020011987 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020011988 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020011989 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011990 [ALC268_ACER_DMIC] = {
11991 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
11992 alc268_beep_mixer },
11993 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11994 alc268_acer_verbs },
11995 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11996 .dac_nids = alc268_dac_nids,
11997 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11998 .adc_nids = alc268_adc_nids_alt,
11999 .capsrc_nids = alc268_capsrc_nids,
12000 .hp_nid = 0x02,
12001 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12002 .channel_mode = alc268_modes,
12003 .input_mux = &alc268_acer_dmic_capture_source,
12004 .unsol_event = alc268_acer_unsol_event,
12005 .init_hook = alc268_acer_init_hook,
12006 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012007 [ALC268_ACER_ASPIRE_ONE] = {
12008 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010012009 alc268_beep_mixer,
12010 alc268_capture_alt_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012011 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12012 alc268_acer_aspire_one_verbs },
12013 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12014 .dac_nids = alc268_dac_nids,
12015 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12016 .adc_nids = alc268_adc_nids_alt,
12017 .capsrc_nids = alc268_capsrc_nids,
12018 .hp_nid = 0x03,
12019 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12020 .channel_mode = alc268_modes,
12021 .input_mux = &alc268_acer_lc_capture_source,
12022 .unsol_event = alc268_acer_lc_unsol_event,
12023 .init_hook = alc268_acer_lc_init_hook,
12024 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012025 [ALC268_DELL] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012026 .mixers = { alc268_dell_mixer, alc268_beep_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012027 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12028 alc268_dell_verbs },
12029 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12030 .dac_nids = alc268_dac_nids,
12031 .hp_nid = 0x02,
12032 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12033 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012034 .unsol_event = alc_sku_unsol_event,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012035 .init_hook = alc268_dell_init_hook,
12036 .input_mux = &alc268_capture_source,
12037 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012038 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012039 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12040 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012041 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12042 alc268_toshiba_verbs },
12043 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12044 .dac_nids = alc268_dac_nids,
12045 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12046 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012047 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012048 .hp_nid = 0x03,
12049 .dig_out_nid = ALC268_DIGOUT_NID,
12050 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12051 .channel_mode = alc268_modes,
12052 .input_mux = &alc268_capture_source,
12053 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020012054 .init_hook = alc268_toshiba_init_hook
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012055 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012056#ifdef CONFIG_SND_DEBUG
12057 [ALC268_TEST] = {
12058 .mixers = { alc268_test_mixer, alc268_capture_mixer },
12059 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12060 alc268_volume_init_verbs },
12061 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12062 .dac_nids = alc268_dac_nids,
12063 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12064 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012065 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012066 .hp_nid = 0x03,
12067 .dig_out_nid = ALC268_DIGOUT_NID,
12068 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12069 .channel_mode = alc268_modes,
12070 .input_mux = &alc268_capture_source,
12071 },
12072#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012073};
12074
12075static int patch_alc268(struct hda_codec *codec)
12076{
12077 struct alc_spec *spec;
12078 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010012079 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020012080
12081 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
12082 if (spec == NULL)
12083 return -ENOMEM;
12084
12085 codec->spec = spec;
12086
12087 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
12088 alc268_models,
12089 alc268_cfg_tbl);
12090
12091 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
12092 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
12093 "trying auto-probe from BIOS...\n");
12094 board_config = ALC268_AUTO;
12095 }
12096
12097 if (board_config == ALC268_AUTO) {
12098 /* automatic parse from the BIOS config */
12099 err = alc268_parse_auto_config(codec);
12100 if (err < 0) {
12101 alc_free(codec);
12102 return err;
12103 } else if (!err) {
12104 printk(KERN_INFO
12105 "hda_codec: Cannot set up configuration "
12106 "from BIOS. Using base mode...\n");
12107 board_config = ALC268_3ST;
12108 }
12109 }
12110
12111 if (board_config != ALC268_AUTO)
12112 setup_preset(spec, &alc268_presets[board_config]);
12113
Kailang Yang2f893282008-05-27 12:14:47 +020012114 if (codec->vendor_id == 0x10ec0267) {
12115 spec->stream_name_analog = "ALC267 Analog";
12116 spec->stream_name_digital = "ALC267 Digital";
12117 } else {
12118 spec->stream_name_analog = "ALC268 Analog";
12119 spec->stream_name_digital = "ALC268 Digital";
12120 }
12121
Kailang Yanga361d842007-06-05 12:30:55 +020012122 spec->stream_analog_playback = &alc268_pcm_analog_playback;
12123 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010012124 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020012125
Kailang Yanga361d842007-06-05 12:30:55 +020012126 spec->stream_digital_playback = &alc268_pcm_digital_playback;
12127
Takashi Iwai22971e32009-02-10 11:56:44 +010012128 has_beep = 0;
12129 for (i = 0; i < spec->num_mixers; i++) {
12130 if (spec->mixers[i] == alc268_beep_mixer) {
12131 has_beep = 1;
12132 break;
12133 }
12134 }
12135
12136 if (has_beep) {
12137 err = snd_hda_attach_beep_device(codec, 0x1);
12138 if (err < 0) {
12139 alc_free(codec);
12140 return err;
12141 }
12142 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
12143 /* override the amp caps for beep generator */
12144 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012145 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
12146 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
12147 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
12148 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010012149 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012150
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012151 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012152 /* check whether NID 0x07 is valid */
12153 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010012154 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020012155
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012156 /* get type */
12157 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwai67ebcb02008-02-19 15:03:57 +010012158 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012159 spec->adc_nids = alc268_adc_nids_alt;
12160 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012161 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012162 } else {
12163 spec->adc_nids = alc268_adc_nids;
12164 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012165 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020012166 }
Takashi Iwaie1406342008-02-11 18:32:32 +010012167 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai85860c02008-02-19 15:00:15 +010012168 /* set default input source */
12169 for (i = 0; i < spec->num_adc_nids; i++)
12170 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
12171 0, AC_VERB_SET_CONNECT_SEL,
12172 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020012173 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010012174
12175 spec->vmaster_nid = 0x02;
12176
Kailang Yanga361d842007-06-05 12:30:55 +020012177 codec->patch_ops = alc_patch_ops;
12178 if (board_config == ALC268_AUTO)
12179 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020012180
Takashi Iwaidaead532008-11-28 12:55:36 +010012181 codec->proc_widget_hook = print_realtek_coef;
12182
Kailang Yanga361d842007-06-05 12:30:55 +020012183 return 0;
12184}
12185
12186/*
Kailang Yangf6a92242007-12-13 16:52:54 +010012187 * ALC269 channel source setting (2 channel)
12188 */
12189#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
12190
12191#define alc269_dac_nids alc260_dac_nids
12192
12193static hda_nid_t alc269_adc_nids[1] = {
12194 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020012195 0x08,
12196};
12197
Takashi Iwaie01bf502008-08-21 16:25:07 +020012198static hda_nid_t alc269_capsrc_nids[1] = {
12199 0x23,
12200};
12201
12202/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
12203 * not a mux!
12204 */
12205
Kailang Yangf53281e2008-07-18 12:36:43 +020012206static struct hda_input_mux alc269_eeepc_dmic_capture_source = {
12207 .num_items = 2,
12208 .items = {
12209 { "i-Mic", 0x5 },
12210 { "e-Mic", 0x0 },
12211 },
12212};
12213
12214static struct hda_input_mux alc269_eeepc_amic_capture_source = {
12215 .num_items = 2,
12216 .items = {
12217 { "i-Mic", 0x1 },
12218 { "e-Mic", 0x0 },
12219 },
Kailang Yangf6a92242007-12-13 16:52:54 +010012220};
12221
12222#define alc269_modes alc260_modes
12223#define alc269_capture_source alc880_lg_lw_capture_source
12224
12225static struct snd_kcontrol_new alc269_base_mixer[] = {
12226 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12227 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12228 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12229 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12230 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12231 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12232 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12233 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12234 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12235 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12236 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12237 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
12238 { } /* end */
12239};
12240
Kailang Yang60db6b52008-08-26 13:13:00 +020012241static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
12242 /* output mixer control */
12243 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12244 {
12245 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12246 .name = "Master Playback Switch",
12247 .info = snd_hda_mixer_amp_switch_info,
12248 .get = snd_hda_mixer_amp_switch_get,
12249 .put = alc268_acer_master_sw_put,
12250 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12251 },
12252 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12253 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12254 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12255 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12256 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12257 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020012258 { }
12259};
12260
Tony Vroon64154832008-11-06 15:08:49 +000012261static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
12262 /* output mixer control */
12263 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12264 {
12265 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12266 .name = "Master Playback Switch",
12267 .info = snd_hda_mixer_amp_switch_info,
12268 .get = snd_hda_mixer_amp_switch_get,
12269 .put = alc268_acer_master_sw_put,
12270 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12271 },
12272 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12273 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12274 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12275 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12276 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12277 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12278 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
12279 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
12280 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000012281 { }
12282};
12283
Kailang Yangf53281e2008-07-18 12:36:43 +020012284/* bind volumes of both NID 0x0c and 0x0d */
12285static struct hda_bind_ctls alc269_epc_bind_vol = {
12286 .ops = &snd_hda_bind_vol,
12287 .values = {
12288 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
12289 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
12290 0
12291 },
12292};
12293
12294static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
12295 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12296 HDA_BIND_VOL("LineOut Playback Volume", &alc269_epc_bind_vol),
12297 HDA_CODEC_MUTE("LineOut Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12298 { } /* end */
12299};
12300
Kailang Yangf6a92242007-12-13 16:52:54 +010012301/* capture mixer elements */
Kailang Yangf53281e2008-07-18 12:36:43 +020012302static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
12303 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12304 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012305 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12306 { } /* end */
12307};
12308
12309/* FSC amilo */
12310static struct snd_kcontrol_new alc269_fujitsu_mixer[] = {
12311 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12312 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12313 HDA_BIND_VOL("PCM Playback Volume", &alc269_epc_bind_vol),
Kailang Yangf53281e2008-07-18 12:36:43 +020012314 { } /* end */
12315};
12316
Kailang Yang60db6b52008-08-26 13:13:00 +020012317static struct hda_verb alc269_quanta_fl1_verbs[] = {
12318 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12319 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12320 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12321 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12322 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12323 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12324 { }
12325};
12326
Tony Vroon64154832008-11-06 15:08:49 +000012327static struct hda_verb alc269_lifebook_verbs[] = {
12328 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12329 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
12330 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12331 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12332 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12333 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12334 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12335 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12336 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12337 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12338 { }
12339};
12340
Kailang Yang60db6b52008-08-26 13:13:00 +020012341/* toggle speaker-output according to the hp-jack state */
12342static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
12343{
12344 unsigned int present;
12345 unsigned char bits;
12346
12347 present = snd_hda_codec_read(codec, 0x15, 0,
12348 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12349 bits = present ? AMP_IN_MUTE(0) : 0;
12350 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12351 AMP_IN_MUTE(0), bits);
12352 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12353 AMP_IN_MUTE(0), bits);
12354
12355 snd_hda_codec_write(codec, 0x20, 0,
12356 AC_VERB_SET_COEF_INDEX, 0x0c);
12357 snd_hda_codec_write(codec, 0x20, 0,
12358 AC_VERB_SET_PROC_COEF, 0x680);
12359
12360 snd_hda_codec_write(codec, 0x20, 0,
12361 AC_VERB_SET_COEF_INDEX, 0x0c);
12362 snd_hda_codec_write(codec, 0x20, 0,
12363 AC_VERB_SET_PROC_COEF, 0x480);
12364}
12365
Tony Vroon64154832008-11-06 15:08:49 +000012366/* toggle speaker-output according to the hp-jacks state */
12367static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
12368{
12369 unsigned int present;
12370 unsigned char bits;
12371
12372 /* Check laptop headphone socket */
12373 present = snd_hda_codec_read(codec, 0x15, 0,
12374 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12375
12376 /* Check port replicator headphone socket */
12377 present |= snd_hda_codec_read(codec, 0x1a, 0,
12378 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12379
12380 bits = present ? AMP_IN_MUTE(0) : 0;
12381 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12382 AMP_IN_MUTE(0), bits);
12383 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12384 AMP_IN_MUTE(0), bits);
12385
12386 snd_hda_codec_write(codec, 0x20, 0,
12387 AC_VERB_SET_COEF_INDEX, 0x0c);
12388 snd_hda_codec_write(codec, 0x20, 0,
12389 AC_VERB_SET_PROC_COEF, 0x680);
12390
12391 snd_hda_codec_write(codec, 0x20, 0,
12392 AC_VERB_SET_COEF_INDEX, 0x0c);
12393 snd_hda_codec_write(codec, 0x20, 0,
12394 AC_VERB_SET_PROC_COEF, 0x480);
12395}
12396
Kailang Yang60db6b52008-08-26 13:13:00 +020012397static void alc269_quanta_fl1_mic_automute(struct hda_codec *codec)
12398{
12399 unsigned int present;
12400
12401 present = snd_hda_codec_read(codec, 0x18, 0,
12402 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12403 snd_hda_codec_write(codec, 0x23, 0,
12404 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x1);
12405}
12406
Tony Vroon64154832008-11-06 15:08:49 +000012407static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
12408{
12409 unsigned int present_laptop;
12410 unsigned int present_dock;
12411
12412 present_laptop = snd_hda_codec_read(codec, 0x18, 0,
12413 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12414
12415 present_dock = snd_hda_codec_read(codec, 0x1b, 0,
12416 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12417
12418 /* Laptop mic port overrides dock mic port, design decision */
12419 if (present_dock)
12420 snd_hda_codec_write(codec, 0x23, 0,
12421 AC_VERB_SET_CONNECT_SEL, 0x3);
12422 if (present_laptop)
12423 snd_hda_codec_write(codec, 0x23, 0,
12424 AC_VERB_SET_CONNECT_SEL, 0x0);
12425 if (!present_dock && !present_laptop)
12426 snd_hda_codec_write(codec, 0x23, 0,
12427 AC_VERB_SET_CONNECT_SEL, 0x1);
12428}
12429
Kailang Yang60db6b52008-08-26 13:13:00 +020012430static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
12431 unsigned int res)
12432{
12433 if ((res >> 26) == ALC880_HP_EVENT)
12434 alc269_quanta_fl1_speaker_automute(codec);
12435 if ((res >> 26) == ALC880_MIC_EVENT)
12436 alc269_quanta_fl1_mic_automute(codec);
12437}
12438
Tony Vroon64154832008-11-06 15:08:49 +000012439static void alc269_lifebook_unsol_event(struct hda_codec *codec,
12440 unsigned int res)
12441{
12442 if ((res >> 26) == ALC880_HP_EVENT)
12443 alc269_lifebook_speaker_automute(codec);
12444 if ((res >> 26) == ALC880_MIC_EVENT)
12445 alc269_lifebook_mic_autoswitch(codec);
12446}
12447
Kailang Yang60db6b52008-08-26 13:13:00 +020012448static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
12449{
12450 alc269_quanta_fl1_speaker_automute(codec);
12451 alc269_quanta_fl1_mic_automute(codec);
12452}
12453
Tony Vroon64154832008-11-06 15:08:49 +000012454static void alc269_lifebook_init_hook(struct hda_codec *codec)
12455{
12456 alc269_lifebook_speaker_automute(codec);
12457 alc269_lifebook_mic_autoswitch(codec);
12458}
12459
Kailang Yang60db6b52008-08-26 13:13:00 +020012460static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
12461 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12462 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
12463 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12464 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
12465 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12466 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12467 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12468 {}
12469};
12470
12471static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
12472 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12473 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
12474 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12475 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
12476 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12477 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12478 {}
12479};
12480
12481/* toggle speaker-output according to the hp-jack state */
12482static void alc269_speaker_automute(struct hda_codec *codec)
12483{
12484 unsigned int present;
12485 unsigned char bits;
12486
12487 present = snd_hda_codec_read(codec, 0x15, 0,
12488 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12489 bits = present ? AMP_IN_MUTE(0) : 0;
12490 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12491 AMP_IN_MUTE(0), bits);
12492 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12493 AMP_IN_MUTE(0), bits);
12494}
12495
12496static void alc269_eeepc_dmic_automute(struct hda_codec *codec)
12497{
12498 unsigned int present;
12499
12500 present = snd_hda_codec_read(codec, 0x18, 0,
12501 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12502 snd_hda_codec_write(codec, 0x23, 0,
12503 AC_VERB_SET_CONNECT_SEL, (present ? 0 : 5));
12504}
12505
12506static void alc269_eeepc_amic_automute(struct hda_codec *codec)
12507{
12508 unsigned int present;
12509
12510 present = snd_hda_codec_read(codec, 0x18, 0,
12511 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12512 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12513 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
12514 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12515 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
12516}
12517
12518/* unsolicited event for HP jack sensing */
12519static void alc269_eeepc_dmic_unsol_event(struct hda_codec *codec,
12520 unsigned int res)
12521{
12522 if ((res >> 26) == ALC880_HP_EVENT)
12523 alc269_speaker_automute(codec);
12524
12525 if ((res >> 26) == ALC880_MIC_EVENT)
12526 alc269_eeepc_dmic_automute(codec);
12527}
12528
12529static void alc269_eeepc_dmic_inithook(struct hda_codec *codec)
12530{
12531 alc269_speaker_automute(codec);
12532 alc269_eeepc_dmic_automute(codec);
12533}
12534
12535/* unsolicited event for HP jack sensing */
12536static void alc269_eeepc_amic_unsol_event(struct hda_codec *codec,
12537 unsigned int res)
12538{
12539 if ((res >> 26) == ALC880_HP_EVENT)
12540 alc269_speaker_automute(codec);
12541
12542 if ((res >> 26) == ALC880_MIC_EVENT)
12543 alc269_eeepc_amic_automute(codec);
12544}
12545
12546static void alc269_eeepc_amic_inithook(struct hda_codec *codec)
12547{
12548 alc269_speaker_automute(codec);
12549 alc269_eeepc_amic_automute(codec);
12550}
12551
Kailang Yangf6a92242007-12-13 16:52:54 +010012552/*
12553 * generic initialization of ADC, input mixers and output mixers
12554 */
12555static struct hda_verb alc269_init_verbs[] = {
12556 /*
12557 * Unmute ADC0 and set the default input to mic-in
12558 */
Kailang Yang60db6b52008-08-26 13:13:00 +020012559 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010012560
12561 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
12562 * analog-loopback mixer widget
12563 * Note: PASD motherboards uses the Line In 2 as the input for
12564 * front panel mic (mic 2)
12565 */
12566 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
12567 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12568 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12569 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12570 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12571 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12572
12573 /*
12574 * Set up output mixers (0x0c - 0x0e)
12575 */
12576 /* set vol=0 to output mixers */
12577 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12578 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12579
12580 /* set up input amps for analog loopback */
12581 /* Amp Indices: DAC = 0, mixer = 1 */
12582 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12583 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12584 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12585 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12586 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12587 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12588
12589 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12590 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12591 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12592 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12593 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12594 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12595 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12596
12597 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12598 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12599 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12600 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12601 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12602 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12603 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12604
12605 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
12606 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12607
12608 /* FIXME: use matrix-type input source selection */
12609 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
12610 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang60db6b52008-08-26 13:13:00 +020012611 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12612 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangf6a92242007-12-13 16:52:54 +010012613 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12614 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12615
12616 /* set EAPD */
12617 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12618 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12619 { }
12620};
12621
12622/* add playback controls from the parsed DAC table */
12623static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
12624 const struct auto_pin_cfg *cfg)
12625{
12626 hda_nid_t nid;
12627 int err;
12628
12629 spec->multiout.num_dacs = 1; /* only use one dac */
12630 spec->multiout.dac_nids = spec->private_dac_nids;
12631 spec->multiout.dac_nids[0] = 2;
12632
12633 nid = cfg->line_out_pins[0];
12634 if (nid) {
12635 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12636 "Front Playback Volume",
12637 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
12638 if (err < 0)
12639 return err;
12640 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12641 "Front Playback Switch",
12642 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
12643 if (err < 0)
12644 return err;
12645 }
12646
12647 nid = cfg->speaker_pins[0];
12648 if (nid) {
12649 if (!cfg->line_out_pins[0]) {
12650 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12651 "Speaker Playback Volume",
12652 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12653 HDA_OUTPUT));
12654 if (err < 0)
12655 return err;
12656 }
12657 if (nid == 0x16) {
12658 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12659 "Speaker Playback Switch",
12660 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12661 HDA_OUTPUT));
12662 if (err < 0)
12663 return err;
12664 } else {
12665 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12666 "Speaker Playback Switch",
12667 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12668 HDA_OUTPUT));
12669 if (err < 0)
12670 return err;
12671 }
12672 }
12673 nid = cfg->hp_pins[0];
12674 if (nid) {
12675 /* spec->multiout.hp_nid = 2; */
12676 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
12677 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12678 "Headphone Playback Volume",
12679 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12680 HDA_OUTPUT));
12681 if (err < 0)
12682 return err;
12683 }
12684 if (nid == 0x16) {
12685 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12686 "Headphone Playback Switch",
12687 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12688 HDA_OUTPUT));
12689 if (err < 0)
12690 return err;
12691 } else {
12692 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12693 "Headphone Playback Switch",
12694 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12695 HDA_OUTPUT));
12696 if (err < 0)
12697 return err;
12698 }
12699 }
12700 return 0;
12701}
12702
Takashi Iwaiee956e02008-10-31 17:16:31 +010012703static int alc269_auto_create_analog_input_ctls(struct alc_spec *spec,
12704 const struct auto_pin_cfg *cfg)
12705{
12706 int err;
12707
12708 err = alc880_auto_create_analog_input_ctls(spec, cfg);
12709 if (err < 0)
12710 return err;
12711 /* digital-mic input pin is excluded in alc880_auto_create..()
12712 * because it's under 0x18
12713 */
12714 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
12715 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012716 struct hda_input_mux *imux = &spec->private_imux[0];
Takashi Iwaiee956e02008-10-31 17:16:31 +010012717 imux->items[imux->num_items].label = "Int Mic";
12718 imux->items[imux->num_items].index = 0x05;
12719 imux->num_items++;
12720 }
12721 return 0;
12722}
Kailang Yangf6a92242007-12-13 16:52:54 +010012723
12724#ifdef CONFIG_SND_HDA_POWER_SAVE
12725#define alc269_loopbacks alc880_loopbacks
12726#endif
12727
12728/* pcm configuration: identiacal with ALC880 */
12729#define alc269_pcm_analog_playback alc880_pcm_analog_playback
12730#define alc269_pcm_analog_capture alc880_pcm_analog_capture
12731#define alc269_pcm_digital_playback alc880_pcm_digital_playback
12732#define alc269_pcm_digital_capture alc880_pcm_digital_capture
12733
Takashi Iwaif03d3112009-03-05 14:18:16 +010012734static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
12735 .substreams = 1,
12736 .channels_min = 2,
12737 .channels_max = 8,
12738 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
12739 /* NID is set in alc_build_pcms */
12740 .ops = {
12741 .open = alc880_playback_pcm_open,
12742 .prepare = alc880_playback_pcm_prepare,
12743 .cleanup = alc880_playback_pcm_cleanup
12744 },
12745};
12746
12747static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
12748 .substreams = 1,
12749 .channels_min = 2,
12750 .channels_max = 2,
12751 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
12752 /* NID is set in alc_build_pcms */
12753};
12754
Kailang Yangf6a92242007-12-13 16:52:54 +010012755/*
12756 * BIOS auto configuration
12757 */
12758static int alc269_parse_auto_config(struct hda_codec *codec)
12759{
12760 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010012761 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010012762 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
12763
12764 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12765 alc269_ignore);
12766 if (err < 0)
12767 return err;
12768
12769 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
12770 if (err < 0)
12771 return err;
12772 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
12773 if (err < 0)
12774 return err;
12775
12776 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12777
Takashi Iwai0852d7a2009-02-11 11:35:15 +010012778 if (spec->autocfg.dig_outs)
Kailang Yangf6a92242007-12-13 16:52:54 +010012779 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
12780
Takashi Iwai603c4012008-07-30 15:01:44 +020012781 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012782 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010012783
Takashi Iwaid88897e2008-10-31 15:01:37 +010012784 add_verb(spec, alc269_init_verbs);
Kailang Yangf6a92242007-12-13 16:52:54 +010012785 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012786 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie01bf502008-08-21 16:25:07 +020012787 /* set default input source */
12788 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
12789 0, AC_VERB_SET_CONNECT_SEL,
12790 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010012791
12792 err = alc_auto_add_mic_boost(codec);
12793 if (err < 0)
12794 return err;
12795
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012796 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012797 set_capture_mixer(spec);
Kailang Yangf53281e2008-07-18 12:36:43 +020012798
Kailang Yangf6a92242007-12-13 16:52:54 +010012799 return 1;
12800}
12801
12802#define alc269_auto_init_multi_out alc882_auto_init_multi_out
12803#define alc269_auto_init_hp_out alc882_auto_init_hp_out
12804#define alc269_auto_init_analog_input alc882_auto_init_analog_input
12805
12806
12807/* init callback for auto-configuration model -- overriding the default init */
12808static void alc269_auto_init(struct hda_codec *codec)
12809{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012810 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010012811 alc269_auto_init_multi_out(codec);
12812 alc269_auto_init_hp_out(codec);
12813 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012814 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012815 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010012816}
12817
12818/*
12819 * configuration and preset
12820 */
12821static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020012822 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020012823 [ALC269_QUANTA_FL1] = "quanta",
12824 [ALC269_ASUS_EEEPC_P703] = "eeepc-p703",
Takashi Iwai26f5df22008-11-03 17:39:46 +010012825 [ALC269_ASUS_EEEPC_P901] = "eeepc-p901",
Tony Vroon64154832008-11-06 15:08:49 +000012826 [ALC269_FUJITSU] = "fujitsu",
12827 [ALC269_LIFEBOOK] = "lifebook"
Kailang Yangf6a92242007-12-13 16:52:54 +010012828};
12829
12830static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020012831 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020012832 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
12833 ALC269_ASUS_EEEPC_P703),
Kailang Yang622e84c2009-04-21 07:39:04 +020012834 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_ASUS_EEEPC_P703),
12835 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_ASUS_EEEPC_P703),
12836 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_ASUS_EEEPC_P703),
12837 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_ASUS_EEEPC_P703),
12838 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_ASUS_EEEPC_P703),
12839 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_ASUS_EEEPC_P703),
Kailang Yangf53281e2008-07-18 12:36:43 +020012840 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
12841 ALC269_ASUS_EEEPC_P901),
Kailang Yang60db6b52008-08-26 13:13:00 +020012842 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
12843 ALC269_ASUS_EEEPC_P901),
Kailang Yang622e84c2009-04-21 07:39:04 +020012844 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_ASUS_EEEPC_P901),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012845 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
Tony Vroon64154832008-11-06 15:08:49 +000012846 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yangf6a92242007-12-13 16:52:54 +010012847 {}
12848};
12849
12850static struct alc_config_preset alc269_presets[] = {
12851 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012852 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010012853 .init_verbs = { alc269_init_verbs },
12854 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12855 .dac_nids = alc269_dac_nids,
12856 .hp_nid = 0x03,
12857 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12858 .channel_mode = alc269_modes,
12859 .input_mux = &alc269_capture_source,
12860 },
Kailang Yang60db6b52008-08-26 13:13:00 +020012861 [ALC269_QUANTA_FL1] = {
12862 .mixers = { alc269_quanta_fl1_mixer },
12863 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
12864 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12865 .dac_nids = alc269_dac_nids,
12866 .hp_nid = 0x03,
12867 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12868 .channel_mode = alc269_modes,
12869 .input_mux = &alc269_capture_source,
12870 .unsol_event = alc269_quanta_fl1_unsol_event,
12871 .init_hook = alc269_quanta_fl1_init_hook,
12872 },
Kailang Yangf53281e2008-07-18 12:36:43 +020012873 [ALC269_ASUS_EEEPC_P703] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012874 .mixers = { alc269_eeepc_mixer },
12875 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020012876 .init_verbs = { alc269_init_verbs,
12877 alc269_eeepc_amic_init_verbs },
12878 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12879 .dac_nids = alc269_dac_nids,
12880 .hp_nid = 0x03,
12881 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12882 .channel_mode = alc269_modes,
12883 .input_mux = &alc269_eeepc_amic_capture_source,
12884 .unsol_event = alc269_eeepc_amic_unsol_event,
12885 .init_hook = alc269_eeepc_amic_inithook,
12886 },
12887 [ALC269_ASUS_EEEPC_P901] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012888 .mixers = { alc269_eeepc_mixer },
12889 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020012890 .init_verbs = { alc269_init_verbs,
12891 alc269_eeepc_dmic_init_verbs },
12892 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12893 .dac_nids = alc269_dac_nids,
12894 .hp_nid = 0x03,
12895 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12896 .channel_mode = alc269_modes,
12897 .input_mux = &alc269_eeepc_dmic_capture_source,
12898 .unsol_event = alc269_eeepc_dmic_unsol_event,
12899 .init_hook = alc269_eeepc_dmic_inithook,
12900 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010012901 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010012902 .mixers = { alc269_fujitsu_mixer },
Takashi Iwai26f5df22008-11-03 17:39:46 +010012903 .cap_mixer = alc269_epc_capture_mixer,
12904 .init_verbs = { alc269_init_verbs,
12905 alc269_eeepc_dmic_init_verbs },
12906 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12907 .dac_nids = alc269_dac_nids,
12908 .hp_nid = 0x03,
12909 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12910 .channel_mode = alc269_modes,
12911 .input_mux = &alc269_eeepc_dmic_capture_source,
12912 .unsol_event = alc269_eeepc_dmic_unsol_event,
12913 .init_hook = alc269_eeepc_dmic_inithook,
12914 },
Tony Vroon64154832008-11-06 15:08:49 +000012915 [ALC269_LIFEBOOK] = {
12916 .mixers = { alc269_lifebook_mixer },
12917 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
12918 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12919 .dac_nids = alc269_dac_nids,
12920 .hp_nid = 0x03,
12921 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12922 .channel_mode = alc269_modes,
12923 .input_mux = &alc269_capture_source,
12924 .unsol_event = alc269_lifebook_unsol_event,
12925 .init_hook = alc269_lifebook_init_hook,
12926 },
Kailang Yangf6a92242007-12-13 16:52:54 +010012927};
12928
12929static int patch_alc269(struct hda_codec *codec)
12930{
12931 struct alc_spec *spec;
12932 int board_config;
12933 int err;
12934
12935 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
12936 if (spec == NULL)
12937 return -ENOMEM;
12938
12939 codec->spec = spec;
12940
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020012941 alc_fix_pll_init(codec, 0x20, 0x04, 15);
12942
Kailang Yangf6a92242007-12-13 16:52:54 +010012943 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
12944 alc269_models,
12945 alc269_cfg_tbl);
12946
12947 if (board_config < 0) {
12948 printk(KERN_INFO "hda_codec: Unknown model for ALC269, "
12949 "trying auto-probe from BIOS...\n");
12950 board_config = ALC269_AUTO;
12951 }
12952
12953 if (board_config == ALC269_AUTO) {
12954 /* automatic parse from the BIOS config */
12955 err = alc269_parse_auto_config(codec);
12956 if (err < 0) {
12957 alc_free(codec);
12958 return err;
12959 } else if (!err) {
12960 printk(KERN_INFO
12961 "hda_codec: Cannot set up configuration "
12962 "from BIOS. Using base mode...\n");
12963 board_config = ALC269_BASIC;
12964 }
12965 }
12966
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090012967 err = snd_hda_attach_beep_device(codec, 0x1);
12968 if (err < 0) {
12969 alc_free(codec);
12970 return err;
12971 }
12972
Kailang Yangf6a92242007-12-13 16:52:54 +010012973 if (board_config != ALC269_AUTO)
12974 setup_preset(spec, &alc269_presets[board_config]);
12975
12976 spec->stream_name_analog = "ALC269 Analog";
Takashi Iwaif03d3112009-03-05 14:18:16 +010012977 if (codec->subsystem_id == 0x17aa3bf8) {
12978 /* Due to a hardware problem on Lenovo Ideadpad, we need to
12979 * fix the sample rate of analog I/O to 44.1kHz
12980 */
12981 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
12982 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
12983 } else {
12984 spec->stream_analog_playback = &alc269_pcm_analog_playback;
12985 spec->stream_analog_capture = &alc269_pcm_analog_capture;
12986 }
Kailang Yangf6a92242007-12-13 16:52:54 +010012987 spec->stream_name_digital = "ALC269 Digital";
12988 spec->stream_digital_playback = &alc269_pcm_digital_playback;
12989 spec->stream_digital_capture = &alc269_pcm_digital_capture;
12990
12991 spec->adc_nids = alc269_adc_nids;
12992 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
Takashi Iwaie01bf502008-08-21 16:25:07 +020012993 spec->capsrc_nids = alc269_capsrc_nids;
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012994 if (!spec->cap_mixer)
12995 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010012996 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010012997
12998 codec->patch_ops = alc_patch_ops;
12999 if (board_config == ALC269_AUTO)
13000 spec->init_hook = alc269_auto_init;
13001#ifdef CONFIG_SND_HDA_POWER_SAVE
13002 if (!spec->loopback.amplist)
13003 spec->loopback.amplist = alc269_loopbacks;
13004#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010013005 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010013006
13007 return 0;
13008}
13009
13010/*
Kailang Yangdf694da2005-12-05 19:42:22 +010013011 * ALC861 channel source setting (2/6 channel selection for 3-stack)
13012 */
13013
13014/*
13015 * set the path ways for 2 channel output
13016 * need to set the codec line out and mic 1 pin widgets to inputs
13017 */
13018static struct hda_verb alc861_threestack_ch2_init[] = {
13019 /* set pin widget 1Ah (line in) for input */
13020 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013021 /* set pin widget 18h (mic1/2) for input, for mic also enable
13022 * the vref
13023 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013024 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13025
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013026 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13027#if 0
13028 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13029 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13030#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013031 { } /* end */
13032};
13033/*
13034 * 6ch mode
13035 * need to set the codec line out and mic 1 pin widgets to outputs
13036 */
13037static struct hda_verb alc861_threestack_ch6_init[] = {
13038 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13039 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13040 /* set pin widget 18h (mic1) for output (CLFE)*/
13041 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13042
13043 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013044 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013045
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013046 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13047#if 0
13048 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13049 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13050#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013051 { } /* end */
13052};
13053
13054static struct hda_channel_mode alc861_threestack_modes[2] = {
13055 { 2, alc861_threestack_ch2_init },
13056 { 6, alc861_threestack_ch6_init },
13057};
Takashi Iwai22309c32006-08-09 16:57:28 +020013058/* Set mic1 as input and unmute the mixer */
13059static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
13060 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13061 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13062 { } /* end */
13063};
13064/* Set mic1 as output and mute mixer */
13065static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
13066 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13067 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13068 { } /* end */
13069};
13070
13071static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
13072 { 2, alc861_uniwill_m31_ch2_init },
13073 { 4, alc861_uniwill_m31_ch4_init },
13074};
Kailang Yangdf694da2005-12-05 19:42:22 +010013075
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013076/* Set mic1 and line-in as input and unmute the mixer */
13077static struct hda_verb alc861_asus_ch2_init[] = {
13078 /* set pin widget 1Ah (line in) for input */
13079 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013080 /* set pin widget 18h (mic1/2) for input, for mic also enable
13081 * the vref
13082 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013083 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13084
13085 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13086#if 0
13087 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13088 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13089#endif
13090 { } /* end */
13091};
13092/* Set mic1 nad line-in as output and mute mixer */
13093static struct hda_verb alc861_asus_ch6_init[] = {
13094 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13095 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13096 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13097 /* set pin widget 18h (mic1) for output (CLFE)*/
13098 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13099 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13100 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
13101 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
13102
13103 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13104#if 0
13105 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13106 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13107#endif
13108 { } /* end */
13109};
13110
13111static struct hda_channel_mode alc861_asus_modes[2] = {
13112 { 2, alc861_asus_ch2_init },
13113 { 6, alc861_asus_ch6_init },
13114};
13115
Kailang Yangdf694da2005-12-05 19:42:22 +010013116/* patch-ALC861 */
13117
13118static struct snd_kcontrol_new alc861_base_mixer[] = {
13119 /* output mixer control */
13120 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13121 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13122 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13123 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13124 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13125
13126 /*Input mixer control */
13127 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13128 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13129 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13130 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13131 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13132 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13133 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13134 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13135 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13136 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013137
Kailang Yangdf694da2005-12-05 19:42:22 +010013138 { } /* end */
13139};
13140
13141static struct snd_kcontrol_new alc861_3ST_mixer[] = {
13142 /* output mixer control */
13143 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13144 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13145 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13146 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13147 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13148
13149 /* Input mixer control */
13150 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13151 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13152 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13153 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13154 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13155 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13156 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13157 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13158 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13159 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013160
Kailang Yangdf694da2005-12-05 19:42:22 +010013161 {
13162 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13163 .name = "Channel Mode",
13164 .info = alc_ch_mode_info,
13165 .get = alc_ch_mode_get,
13166 .put = alc_ch_mode_put,
13167 .private_value = ARRAY_SIZE(alc861_threestack_modes),
13168 },
13169 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013170};
13171
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013172static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013173 /* output mixer control */
13174 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13175 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13176 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020013177
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013178 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013179};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013180
Takashi Iwai22309c32006-08-09 16:57:28 +020013181static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
13182 /* output mixer control */
13183 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13184 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13185 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13186 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13187 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13188
13189 /* Input mixer control */
13190 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13191 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13192 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13193 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13194 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13195 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13196 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13197 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13198 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13199 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013200
Takashi Iwai22309c32006-08-09 16:57:28 +020013201 {
13202 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13203 .name = "Channel Mode",
13204 .info = alc_ch_mode_info,
13205 .get = alc_ch_mode_get,
13206 .put = alc_ch_mode_put,
13207 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
13208 },
13209 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013210};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013211
13212static struct snd_kcontrol_new alc861_asus_mixer[] = {
13213 /* output mixer control */
13214 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13215 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13216 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13217 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13218 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13219
13220 /* Input mixer control */
13221 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13222 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13223 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13224 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13225 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13226 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13227 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13228 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13229 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013230 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
13231
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013232 {
13233 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13234 .name = "Channel Mode",
13235 .info = alc_ch_mode_info,
13236 .get = alc_ch_mode_get,
13237 .put = alc_ch_mode_put,
13238 .private_value = ARRAY_SIZE(alc861_asus_modes),
13239 },
13240 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013241};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013242
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013243/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013244static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013245 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13246 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013247 { }
13248};
13249
Kailang Yangdf694da2005-12-05 19:42:22 +010013250/*
13251 * generic initialization of ADC, input mixers and output mixers
13252 */
13253static struct hda_verb alc861_base_init_verbs[] = {
13254 /*
13255 * Unmute ADC0 and set the default input to mic-in
13256 */
13257 /* port-A for surround (rear panel) */
13258 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13259 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
13260 /* port-B for mic-in (rear panel) with vref */
13261 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13262 /* port-C for line-in (rear panel) */
13263 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13264 /* port-D for Front */
13265 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13266 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13267 /* port-E for HP out (front panel) */
13268 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13269 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013270 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013271 /* port-F for mic-in (front panel) with vref */
13272 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13273 /* port-G for CLFE (rear panel) */
13274 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13275 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13276 /* port-H for side (rear panel) */
13277 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13278 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
13279 /* CD-in */
13280 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13281 /* route front mic to ADC1*/
13282 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13283 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013284
Kailang Yangdf694da2005-12-05 19:42:22 +010013285 /* Unmute DAC0~3 & spdif out*/
13286 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13287 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13288 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13289 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13290 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013291
Kailang Yangdf694da2005-12-05 19:42:22 +010013292 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13293 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13294 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13295 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13296 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013297
Kailang Yangdf694da2005-12-05 19:42:22 +010013298 /* Unmute Stereo Mixer 15 */
13299 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13300 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13301 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013302 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013303
13304 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13305 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13306 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13307 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13308 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13309 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13310 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13311 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013312 /* hp used DAC 3 (Front) */
13313 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013314 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13315
13316 { }
13317};
13318
13319static struct hda_verb alc861_threestack_init_verbs[] = {
13320 /*
13321 * Unmute ADC0 and set the default input to mic-in
13322 */
13323 /* port-A for surround (rear panel) */
13324 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13325 /* port-B for mic-in (rear panel) with vref */
13326 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13327 /* port-C for line-in (rear panel) */
13328 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13329 /* port-D for Front */
13330 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13331 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13332 /* port-E for HP out (front panel) */
13333 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13334 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013335 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013336 /* port-F for mic-in (front panel) with vref */
13337 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13338 /* port-G for CLFE (rear panel) */
13339 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13340 /* port-H for side (rear panel) */
13341 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13342 /* CD-in */
13343 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13344 /* route front mic to ADC1*/
13345 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13346 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13347 /* Unmute DAC0~3 & spdif out*/
13348 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13349 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13350 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13351 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13352 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013353
Kailang Yangdf694da2005-12-05 19:42:22 +010013354 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13355 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13356 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13357 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13358 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013359
Kailang Yangdf694da2005-12-05 19:42:22 +010013360 /* Unmute Stereo Mixer 15 */
13361 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13362 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13363 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013364 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013365
13366 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13367 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13368 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13369 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13370 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13371 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13372 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13373 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013374 /* hp used DAC 3 (Front) */
13375 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013376 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13377 { }
13378};
Takashi Iwai22309c32006-08-09 16:57:28 +020013379
13380static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
13381 /*
13382 * Unmute ADC0 and set the default input to mic-in
13383 */
13384 /* port-A for surround (rear panel) */
13385 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13386 /* port-B for mic-in (rear panel) with vref */
13387 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13388 /* port-C for line-in (rear panel) */
13389 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13390 /* port-D for Front */
13391 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13392 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13393 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013394 /* this has to be set to VREF80 */
13395 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013396 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013397 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013398 /* port-F for mic-in (front panel) with vref */
13399 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13400 /* port-G for CLFE (rear panel) */
13401 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13402 /* port-H for side (rear panel) */
13403 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13404 /* CD-in */
13405 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13406 /* route front mic to ADC1*/
13407 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13408 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13409 /* Unmute DAC0~3 & spdif out*/
13410 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13411 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13412 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13413 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13414 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013415
Takashi Iwai22309c32006-08-09 16:57:28 +020013416 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13417 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13418 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13419 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13420 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013421
Takashi Iwai22309c32006-08-09 16:57:28 +020013422 /* Unmute Stereo Mixer 15 */
13423 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13424 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13425 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013426 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020013427
13428 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13429 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13430 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13431 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13432 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13433 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13434 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13435 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013436 /* hp used DAC 3 (Front) */
13437 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020013438 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13439 { }
13440};
13441
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013442static struct hda_verb alc861_asus_init_verbs[] = {
13443 /*
13444 * Unmute ADC0 and set the default input to mic-in
13445 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013446 /* port-A for surround (rear panel)
13447 * according to codec#0 this is the HP jack
13448 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013449 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
13450 /* route front PCM to HP */
13451 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
13452 /* port-B for mic-in (rear panel) with vref */
13453 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13454 /* port-C for line-in (rear panel) */
13455 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13456 /* port-D for Front */
13457 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13458 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13459 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013460 /* this has to be set to VREF80 */
13461 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013462 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013463 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013464 /* port-F for mic-in (front panel) with vref */
13465 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13466 /* port-G for CLFE (rear panel) */
13467 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13468 /* port-H for side (rear panel) */
13469 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13470 /* CD-in */
13471 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13472 /* route front mic to ADC1*/
13473 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13474 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13475 /* Unmute DAC0~3 & spdif out*/
13476 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13477 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13478 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13479 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13480 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13481 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13482 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13483 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13484 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13485 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013486
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013487 /* Unmute Stereo Mixer 15 */
13488 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13489 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13490 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013491 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013492
13493 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13494 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13495 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13496 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13497 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13498 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13499 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13500 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013501 /* hp used DAC 3 (Front) */
13502 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013503 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13504 { }
13505};
13506
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013507/* additional init verbs for ASUS laptops */
13508static struct hda_verb alc861_asus_laptop_init_verbs[] = {
13509 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
13510 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
13511 { }
13512};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013513
Kailang Yangdf694da2005-12-05 19:42:22 +010013514/*
13515 * generic initialization of ADC, input mixers and output mixers
13516 */
13517static struct hda_verb alc861_auto_init_verbs[] = {
13518 /*
13519 * Unmute ADC0 and set the default input to mic-in
13520 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013521 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010013522 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013523
Kailang Yangdf694da2005-12-05 19:42:22 +010013524 /* Unmute DAC0~3 & spdif out*/
13525 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13526 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13527 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13528 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13529 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013530
Kailang Yangdf694da2005-12-05 19:42:22 +010013531 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13532 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13533 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13534 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13535 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013536
Kailang Yangdf694da2005-12-05 19:42:22 +010013537 /* Unmute Stereo Mixer 15 */
13538 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13539 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13540 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13541 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
13542
13543 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13544 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13545 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13546 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13547 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13548 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13549 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13550 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13551
13552 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13553 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013554 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13555 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013556 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13557 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013558 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13559 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013560
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013561 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013562
13563 { }
13564};
13565
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013566static struct hda_verb alc861_toshiba_init_verbs[] = {
13567 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013568
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013569 { }
13570};
13571
13572/* toggle speaker-output according to the hp-jack state */
13573static void alc861_toshiba_automute(struct hda_codec *codec)
13574{
13575 unsigned int present;
13576
13577 present = snd_hda_codec_read(codec, 0x0f, 0,
13578 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013579 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
13580 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
13581 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
13582 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013583}
13584
13585static void alc861_toshiba_unsol_event(struct hda_codec *codec,
13586 unsigned int res)
13587{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013588 if ((res >> 26) == ALC880_HP_EVENT)
13589 alc861_toshiba_automute(codec);
13590}
13591
Kailang Yangdf694da2005-12-05 19:42:22 +010013592/* pcm configuration: identiacal with ALC880 */
13593#define alc861_pcm_analog_playback alc880_pcm_analog_playback
13594#define alc861_pcm_analog_capture alc880_pcm_analog_capture
13595#define alc861_pcm_digital_playback alc880_pcm_digital_playback
13596#define alc861_pcm_digital_capture alc880_pcm_digital_capture
13597
13598
13599#define ALC861_DIGOUT_NID 0x07
13600
13601static struct hda_channel_mode alc861_8ch_modes[1] = {
13602 { 8, NULL }
13603};
13604
13605static hda_nid_t alc861_dac_nids[4] = {
13606 /* front, surround, clfe, side */
13607 0x03, 0x06, 0x05, 0x04
13608};
13609
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013610static hda_nid_t alc660_dac_nids[3] = {
13611 /* front, clfe, surround */
13612 0x03, 0x05, 0x06
13613};
13614
Kailang Yangdf694da2005-12-05 19:42:22 +010013615static hda_nid_t alc861_adc_nids[1] = {
13616 /* ADC0-2 */
13617 0x08,
13618};
13619
13620static struct hda_input_mux alc861_capture_source = {
13621 .num_items = 5,
13622 .items = {
13623 { "Mic", 0x0 },
13624 { "Front Mic", 0x3 },
13625 { "Line", 0x1 },
13626 { "CD", 0x4 },
13627 { "Mixer", 0x5 },
13628 },
13629};
13630
13631/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013632static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
13633 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010013634{
13635 int i;
13636 hda_nid_t nid;
13637
13638 spec->multiout.dac_nids = spec->private_dac_nids;
13639 for (i = 0; i < cfg->line_outs; i++) {
13640 nid = cfg->line_out_pins[i];
13641 if (nid) {
13642 if (i >= ARRAY_SIZE(alc861_dac_nids))
13643 continue;
13644 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
13645 }
13646 }
13647 spec->multiout.num_dacs = cfg->line_outs;
13648 return 0;
13649}
13650
13651/* add playback controls from the parsed DAC table */
13652static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
13653 const struct auto_pin_cfg *cfg)
13654{
13655 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013656 static const char *chname[4] = {
13657 "Front", "Surround", NULL /*CLFE*/, "Side"
13658 };
Kailang Yangdf694da2005-12-05 19:42:22 +010013659 hda_nid_t nid;
13660 int i, idx, err;
13661
13662 for (i = 0; i < cfg->line_outs; i++) {
13663 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013664 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010013665 continue;
13666 if (nid == 0x05) {
13667 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013668 err = add_control(spec, ALC_CTL_BIND_MUTE,
13669 "Center Playback Switch",
13670 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
13671 HDA_OUTPUT));
13672 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013673 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013674 err = add_control(spec, ALC_CTL_BIND_MUTE,
13675 "LFE Playback Switch",
13676 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13677 HDA_OUTPUT));
13678 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013679 return err;
13680 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013681 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
13682 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +010013683 if (nid == alc861_dac_nids[idx])
13684 break;
13685 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013686 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
13687 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13688 HDA_OUTPUT));
13689 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013690 return err;
13691 }
13692 }
13693 return 0;
13694}
13695
13696static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
13697{
13698 int err;
13699 hda_nid_t nid;
13700
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013701 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010013702 return 0;
13703
13704 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
13705 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013706 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13707 "Headphone Playback Switch",
13708 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
13709 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013710 return err;
13711 spec->multiout.hp_nid = nid;
13712 }
13713 return 0;
13714}
13715
13716/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013717static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
13718 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010013719{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013720 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010013721 int i, err, idx, idx1;
13722
13723 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013724 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010013725 case 0x0c:
13726 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013727 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013728 break;
13729 case 0x0f:
13730 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013731 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013732 break;
13733 case 0x0d:
13734 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013735 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013736 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013737 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010013738 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013739 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013740 break;
13741 case 0x11:
13742 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013743 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010013744 break;
13745 default:
13746 continue;
13747 }
13748
Takashi Iwai4a471b72005-12-07 13:56:29 +010013749 err = new_analog_input(spec, cfg->input_pins[i],
13750 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010013751 if (err < 0)
13752 return err;
13753
Takashi Iwai4a471b72005-12-07 13:56:29 +010013754 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010013755 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013756 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010013757 }
13758 return 0;
13759}
13760
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013761static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
13762 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +010013763 int pin_type, int dac_idx)
13764{
Jacek Luczak564c5be2008-05-03 18:41:23 +020013765 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
13766 pin_type);
13767 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13768 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +010013769}
13770
13771static void alc861_auto_init_multi_out(struct hda_codec *codec)
13772{
13773 struct alc_spec *spec = codec->spec;
13774 int i;
13775
13776 for (i = 0; i < spec->autocfg.line_outs; i++) {
13777 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013778 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010013779 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013780 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013781 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010013782 }
13783}
13784
13785static void alc861_auto_init_hp_out(struct hda_codec *codec)
13786{
13787 struct alc_spec *spec = codec->spec;
13788 hda_nid_t pin;
13789
Takashi Iwaieb06ed82006-09-20 17:10:27 +020013790 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010013791 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013792 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
13793 spec->multiout.dac_nids[0]);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013794 pin = spec->autocfg.speaker_pins[0];
13795 if (pin)
13796 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010013797}
13798
13799static void alc861_auto_init_analog_input(struct hda_codec *codec)
13800{
13801 struct alc_spec *spec = codec->spec;
13802 int i;
13803
13804 for (i = 0; i < AUTO_PIN_LAST; i++) {
13805 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai23f0c042009-02-26 13:03:58 +010013806 if (nid >= 0x0c && nid <= 0x11)
13807 alc_set_input_pin(codec, nid, i);
Kailang Yangdf694da2005-12-05 19:42:22 +010013808 }
13809}
13810
13811/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013812/* return 1 if successful, 0 if the proper config is not found,
13813 * or a negative error code
13814 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013815static int alc861_parse_auto_config(struct hda_codec *codec)
13816{
13817 struct alc_spec *spec = codec->spec;
13818 int err;
13819 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
13820
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013821 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13822 alc861_ignore);
13823 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013824 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013825 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010013826 return 0; /* can't find valid BIOS pin config */
13827
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013828 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
13829 if (err < 0)
13830 return err;
13831 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
13832 if (err < 0)
13833 return err;
13834 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
13835 if (err < 0)
13836 return err;
13837 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
13838 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013839 return err;
13840
13841 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13842
Takashi Iwai0852d7a2009-02-11 11:35:15 +010013843 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010013844 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
13845
Takashi Iwai603c4012008-07-30 15:01:44 +020013846 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013847 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010013848
Takashi Iwaid88897e2008-10-31 15:01:37 +010013849 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010013850
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020013851 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013852 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010013853
13854 spec->adc_nids = alc861_adc_nids;
13855 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013856 set_capture_mixer(spec);
Kailang Yangdf694da2005-12-05 19:42:22 +010013857
Takashi Iwai4a79ba32009-04-22 16:31:35 +020013858 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b);
13859
Kailang Yangdf694da2005-12-05 19:42:22 +010013860 return 1;
13861}
13862
Takashi Iwaiae6b8132006-03-03 16:47:17 +010013863/* additional initialization for auto-configuration model */
13864static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010013865{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013866 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010013867 alc861_auto_init_multi_out(codec);
13868 alc861_auto_init_hp_out(codec);
13869 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013870 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013871 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010013872}
13873
Takashi Iwaicb53c622007-08-10 17:21:45 +020013874#ifdef CONFIG_SND_HDA_POWER_SAVE
13875static struct hda_amp_list alc861_loopbacks[] = {
13876 { 0x15, HDA_INPUT, 0 },
13877 { 0x15, HDA_INPUT, 1 },
13878 { 0x15, HDA_INPUT, 2 },
13879 { 0x15, HDA_INPUT, 3 },
13880 { } /* end */
13881};
13882#endif
13883
Kailang Yangdf694da2005-12-05 19:42:22 +010013884
13885/*
13886 * configuration and preset
13887 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013888static const char *alc861_models[ALC861_MODEL_LAST] = {
13889 [ALC861_3ST] = "3stack",
13890 [ALC660_3ST] = "3stack-660",
13891 [ALC861_3ST_DIG] = "3stack-dig",
13892 [ALC861_6ST_DIG] = "6stack-dig",
13893 [ALC861_UNIWILL_M31] = "uniwill-m31",
13894 [ALC861_TOSHIBA] = "toshiba",
13895 [ALC861_ASUS] = "asus",
13896 [ALC861_ASUS_LAPTOP] = "asus-laptop",
13897 [ALC861_AUTO] = "auto",
13898};
13899
13900static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010013901 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013902 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
13903 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
13904 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013905 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020013906 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010013907 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020013908 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
13909 * Any other models that need this preset?
13910 */
13911 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020013912 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
13913 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013914 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
13915 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
13916 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
13917 /* FIXME: the below seems conflict */
13918 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
13919 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
13920 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010013921 {}
13922};
13923
13924static struct alc_config_preset alc861_presets[] = {
13925 [ALC861_3ST] = {
13926 .mixers = { alc861_3ST_mixer },
13927 .init_verbs = { alc861_threestack_init_verbs },
13928 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13929 .dac_nids = alc861_dac_nids,
13930 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13931 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020013932 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010013933 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13934 .adc_nids = alc861_adc_nids,
13935 .input_mux = &alc861_capture_source,
13936 },
13937 [ALC861_3ST_DIG] = {
13938 .mixers = { alc861_base_mixer },
13939 .init_verbs = { alc861_threestack_init_verbs },
13940 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13941 .dac_nids = alc861_dac_nids,
13942 .dig_out_nid = ALC861_DIGOUT_NID,
13943 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13944 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020013945 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010013946 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13947 .adc_nids = alc861_adc_nids,
13948 .input_mux = &alc861_capture_source,
13949 },
13950 [ALC861_6ST_DIG] = {
13951 .mixers = { alc861_base_mixer },
13952 .init_verbs = { alc861_base_init_verbs },
13953 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13954 .dac_nids = alc861_dac_nids,
13955 .dig_out_nid = ALC861_DIGOUT_NID,
13956 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
13957 .channel_mode = alc861_8ch_modes,
13958 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13959 .adc_nids = alc861_adc_nids,
13960 .input_mux = &alc861_capture_source,
13961 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013962 [ALC660_3ST] = {
13963 .mixers = { alc861_3ST_mixer },
13964 .init_verbs = { alc861_threestack_init_verbs },
13965 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
13966 .dac_nids = alc660_dac_nids,
13967 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13968 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020013969 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013970 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13971 .adc_nids = alc861_adc_nids,
13972 .input_mux = &alc861_capture_source,
13973 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013974 [ALC861_UNIWILL_M31] = {
13975 .mixers = { alc861_uniwill_m31_mixer },
13976 .init_verbs = { alc861_uniwill_m31_init_verbs },
13977 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13978 .dac_nids = alc861_dac_nids,
13979 .dig_out_nid = ALC861_DIGOUT_NID,
13980 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
13981 .channel_mode = alc861_uniwill_m31_modes,
13982 .need_dac_fix = 1,
13983 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13984 .adc_nids = alc861_adc_nids,
13985 .input_mux = &alc861_capture_source,
13986 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013987 [ALC861_TOSHIBA] = {
13988 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013989 .init_verbs = { alc861_base_init_verbs,
13990 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013991 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13992 .dac_nids = alc861_dac_nids,
13993 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
13994 .channel_mode = alc883_3ST_2ch_modes,
13995 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13996 .adc_nids = alc861_adc_nids,
13997 .input_mux = &alc861_capture_source,
13998 .unsol_event = alc861_toshiba_unsol_event,
13999 .init_hook = alc861_toshiba_automute,
14000 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014001 [ALC861_ASUS] = {
14002 .mixers = { alc861_asus_mixer },
14003 .init_verbs = { alc861_asus_init_verbs },
14004 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14005 .dac_nids = alc861_dac_nids,
14006 .dig_out_nid = ALC861_DIGOUT_NID,
14007 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
14008 .channel_mode = alc861_asus_modes,
14009 .need_dac_fix = 1,
14010 .hp_nid = 0x06,
14011 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14012 .adc_nids = alc861_adc_nids,
14013 .input_mux = &alc861_capture_source,
14014 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014015 [ALC861_ASUS_LAPTOP] = {
14016 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
14017 .init_verbs = { alc861_asus_init_verbs,
14018 alc861_asus_laptop_init_verbs },
14019 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14020 .dac_nids = alc861_dac_nids,
14021 .dig_out_nid = ALC861_DIGOUT_NID,
14022 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14023 .channel_mode = alc883_3ST_2ch_modes,
14024 .need_dac_fix = 1,
14025 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14026 .adc_nids = alc861_adc_nids,
14027 .input_mux = &alc861_capture_source,
14028 },
14029};
Kailang Yangdf694da2005-12-05 19:42:22 +010014030
14031
14032static int patch_alc861(struct hda_codec *codec)
14033{
14034 struct alc_spec *spec;
14035 int board_config;
14036 int err;
14037
Robert P. J. Daydc041e02006-12-19 14:44:15 +010014038 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010014039 if (spec == NULL)
14040 return -ENOMEM;
14041
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014042 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014043
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014044 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
14045 alc861_models,
14046 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014047
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014048 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014049 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
14050 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010014051 board_config = ALC861_AUTO;
14052 }
14053
14054 if (board_config == ALC861_AUTO) {
14055 /* automatic parse from the BIOS config */
14056 err = alc861_parse_auto_config(codec);
14057 if (err < 0) {
14058 alc_free(codec);
14059 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014060 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014061 printk(KERN_INFO
14062 "hda_codec: Cannot set up configuration "
14063 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010014064 board_config = ALC861_3ST_DIG;
14065 }
14066 }
14067
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014068 err = snd_hda_attach_beep_device(codec, 0x23);
14069 if (err < 0) {
14070 alc_free(codec);
14071 return err;
14072 }
14073
Kailang Yangdf694da2005-12-05 19:42:22 +010014074 if (board_config != ALC861_AUTO)
14075 setup_preset(spec, &alc861_presets[board_config]);
14076
14077 spec->stream_name_analog = "ALC861 Analog";
14078 spec->stream_analog_playback = &alc861_pcm_analog_playback;
14079 spec->stream_analog_capture = &alc861_pcm_analog_capture;
14080
14081 spec->stream_name_digital = "ALC861 Digital";
14082 spec->stream_digital_playback = &alc861_pcm_digital_playback;
14083 spec->stream_digital_capture = &alc861_pcm_digital_capture;
14084
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014085 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
14086
Takashi Iwai2134ea42008-01-10 16:53:55 +010014087 spec->vmaster_nid = 0x03;
14088
Kailang Yangdf694da2005-12-05 19:42:22 +010014089 codec->patch_ops = alc_patch_ops;
14090 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014091 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014092#ifdef CONFIG_SND_HDA_POWER_SAVE
14093 if (!spec->loopback.amplist)
14094 spec->loopback.amplist = alc861_loopbacks;
14095#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010014096 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020014097
Kailang Yangdf694da2005-12-05 19:42:22 +010014098 return 0;
14099}
14100
14101/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014102 * ALC861-VD support
14103 *
14104 * Based on ALC882
14105 *
14106 * In addition, an independent DAC
14107 */
14108#define ALC861VD_DIGOUT_NID 0x06
14109
14110static hda_nid_t alc861vd_dac_nids[4] = {
14111 /* front, surr, clfe, side surr */
14112 0x02, 0x03, 0x04, 0x05
14113};
14114
14115/* dac_nids for ALC660vd are in a different order - according to
14116 * Realtek's driver.
14117 * This should probably tesult in a different mixer for 6stack models
14118 * of ALC660vd codecs, but for now there is only 3stack mixer
14119 * - and it is the same as in 861vd.
14120 * adc_nids in ALC660vd are (is) the same as in 861vd
14121 */
14122static hda_nid_t alc660vd_dac_nids[3] = {
14123 /* front, rear, clfe, rear_surr */
14124 0x02, 0x04, 0x03
14125};
14126
14127static hda_nid_t alc861vd_adc_nids[1] = {
14128 /* ADC0 */
14129 0x09,
14130};
14131
Takashi Iwaie1406342008-02-11 18:32:32 +010014132static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
14133
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014134/* input MUX */
14135/* FIXME: should be a matrix-type input source selection */
14136static struct hda_input_mux alc861vd_capture_source = {
14137 .num_items = 4,
14138 .items = {
14139 { "Mic", 0x0 },
14140 { "Front Mic", 0x1 },
14141 { "Line", 0x2 },
14142 { "CD", 0x4 },
14143 },
14144};
14145
Kailang Yang272a5272007-05-14 11:00:38 +020014146static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010014147 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020014148 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010014149 { "Ext Mic", 0x0 },
14150 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020014151 },
14152};
14153
Kailang Yangd1a991a2007-08-15 16:21:59 +020014154static struct hda_input_mux alc861vd_hp_capture_source = {
14155 .num_items = 2,
14156 .items = {
14157 { "Front Mic", 0x0 },
14158 { "ATAPI Mic", 0x1 },
14159 },
14160};
14161
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014162/*
14163 * 2ch mode
14164 */
14165static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
14166 { 2, NULL }
14167};
14168
14169/*
14170 * 6ch mode
14171 */
14172static struct hda_verb alc861vd_6stack_ch6_init[] = {
14173 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14174 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14175 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14176 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14177 { } /* end */
14178};
14179
14180/*
14181 * 8ch mode
14182 */
14183static struct hda_verb alc861vd_6stack_ch8_init[] = {
14184 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14185 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14186 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14187 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14188 { } /* end */
14189};
14190
14191static struct hda_channel_mode alc861vd_6stack_modes[2] = {
14192 { 6, alc861vd_6stack_ch6_init },
14193 { 8, alc861vd_6stack_ch8_init },
14194};
14195
14196static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
14197 {
14198 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14199 .name = "Channel Mode",
14200 .info = alc_ch_mode_info,
14201 .get = alc_ch_mode_get,
14202 .put = alc_ch_mode_put,
14203 },
14204 { } /* end */
14205};
14206
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014207/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
14208 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
14209 */
14210static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
14211 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14212 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14213
14214 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14215 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
14216
14217 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
14218 HDA_OUTPUT),
14219 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
14220 HDA_OUTPUT),
14221 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
14222 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
14223
14224 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
14225 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
14226
14227 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14228
14229 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14230 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14231 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14232
14233 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14234 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14235 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14236
14237 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14238 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14239
14240 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14241 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14242
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014243 { } /* end */
14244};
14245
14246static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
14247 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14248 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14249
14250 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14251
14252 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14253 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14254 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14255
14256 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14257 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14258 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14259
14260 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14261 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14262
14263 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14264 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14265
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014266 { } /* end */
14267};
14268
Kailang Yangbdd148a2007-05-08 15:19:08 +020014269static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
14270 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14271 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
14272 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14273
14274 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14275
14276 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14277 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14278 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14279
14280 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14281 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14282 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14283
14284 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14285 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14286
14287 { } /* end */
14288};
14289
Tobin Davisb419f342008-03-07 11:57:51 +010014290/* Pin assignment: Speaker=0x14, HP = 0x15,
14291 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020014292 */
14293static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010014294 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14295 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014296 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14297 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010014298 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
14299 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14300 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14301 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
14302 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14303 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014304 { } /* end */
14305};
14306
Kailang Yangd1a991a2007-08-15 16:21:59 +020014307/* Pin assignment: Speaker=0x14, Line-out = 0x15,
14308 * Front Mic=0x18, ATAPI Mic = 0x19,
14309 */
14310static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
14311 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14312 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14313 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14314 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
14315 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14316 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14317 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14318 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020014319
Kailang Yangd1a991a2007-08-15 16:21:59 +020014320 { } /* end */
14321};
14322
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014323/*
14324 * generic initialization of ADC, input mixers and output mixers
14325 */
14326static struct hda_verb alc861vd_volume_init_verbs[] = {
14327 /*
14328 * Unmute ADC0 and set the default input to mic-in
14329 */
14330 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14331 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14332
14333 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
14334 * the analog-loopback mixer widget
14335 */
14336 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020014337 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14338 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14339 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14340 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14341 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014342
14343 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020014344 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14345 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14346 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014347 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014348
14349 /*
14350 * Set up output mixers (0x02 - 0x05)
14351 */
14352 /* set vol=0 to output mixers */
14353 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14354 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14355 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14356 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14357
14358 /* set up input amps for analog loopback */
14359 /* Amp Indices: DAC = 0, mixer = 1 */
14360 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14361 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14362 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14363 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14364 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14365 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14366 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14367 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14368
14369 { }
14370};
14371
14372/*
14373 * 3-stack pin configuration:
14374 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
14375 */
14376static struct hda_verb alc861vd_3stack_init_verbs[] = {
14377 /*
14378 * Set pin mode and muting
14379 */
14380 /* set front pin widgets 0x14 for output */
14381 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14382 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14383 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14384
14385 /* Mic (rear) pin: input vref at 80% */
14386 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14387 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14388 /* Front Mic pin: input vref at 80% */
14389 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14390 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14391 /* Line In pin: input */
14392 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14393 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14394 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14395 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14396 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14397 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14398 /* CD pin widget for input */
14399 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14400
14401 { }
14402};
14403
14404/*
14405 * 6-stack pin configuration:
14406 */
14407static struct hda_verb alc861vd_6stack_init_verbs[] = {
14408 /*
14409 * Set pin mode and muting
14410 */
14411 /* set front pin widgets 0x14 for output */
14412 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14413 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14414 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14415
14416 /* Rear Pin: output 1 (0x0d) */
14417 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14418 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14419 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14420 /* CLFE Pin: output 2 (0x0e) */
14421 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14422 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14423 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
14424 /* Side Pin: output 3 (0x0f) */
14425 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14426 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14427 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
14428
14429 /* Mic (rear) pin: input vref at 80% */
14430 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14431 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14432 /* Front Mic pin: input vref at 80% */
14433 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14434 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14435 /* Line In pin: input */
14436 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14437 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14438 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14439 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14440 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14441 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14442 /* CD pin widget for input */
14443 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14444
14445 { }
14446};
14447
Kailang Yangbdd148a2007-05-08 15:19:08 +020014448static struct hda_verb alc861vd_eapd_verbs[] = {
14449 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14450 { }
14451};
14452
Kailang Yangf9423e72008-05-27 12:32:25 +020014453static struct hda_verb alc660vd_eapd_verbs[] = {
14454 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14455 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
14456 { }
14457};
14458
Kailang Yangbdd148a2007-05-08 15:19:08 +020014459static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
14460 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14461 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14462 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
14463 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020014464 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020014465 {}
14466};
14467
Kailang Yangbdd148a2007-05-08 15:19:08 +020014468static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
14469{
14470 unsigned int present;
14471 unsigned char bits;
14472
14473 present = snd_hda_codec_read(codec, 0x18, 0,
14474 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014475 bits = present ? HDA_AMP_MUTE : 0;
14476 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
14477 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014478}
14479
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014480static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020014481{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014482 struct alc_spec *spec = codec->spec;
14483
14484 spec->autocfg.hp_pins[0] = 0x1b;
14485 spec->autocfg.speaker_pins[0] = 0x14;
14486 alc_automute_amp(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014487 alc861vd_lenovo_mic_automute(codec);
14488}
14489
14490static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
14491 unsigned int res)
14492{
14493 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020014494 case ALC880_MIC_EVENT:
14495 alc861vd_lenovo_mic_automute(codec);
14496 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014497 default:
14498 alc_automute_amp_unsol_event(codec, res);
14499 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020014500 }
14501}
14502
Kailang Yang272a5272007-05-14 11:00:38 +020014503static struct hda_verb alc861vd_dallas_verbs[] = {
14504 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14505 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14506 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14507 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14508
14509 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14510 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14511 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14512 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14513 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14514 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14515 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14516 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014517
Kailang Yang272a5272007-05-14 11:00:38 +020014518 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14519 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14520 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14521 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14522 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14523 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14524 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14525 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14526
14527 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14528 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14529 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14530 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14531 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14532 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14533 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14534 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14535
14536 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14537 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14538 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14539 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
14540
14541 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014542 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020014543 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14544
14545 { } /* end */
14546};
14547
14548/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014549static void alc861vd_dallas_init_hook(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020014550{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014551 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020014552
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014553 spec->autocfg.hp_pins[0] = 0x15;
14554 spec->autocfg.speaker_pins[0] = 0x14;
14555 alc_automute_amp(codec);
Kailang Yang272a5272007-05-14 11:00:38 +020014556}
14557
Takashi Iwaicb53c622007-08-10 17:21:45 +020014558#ifdef CONFIG_SND_HDA_POWER_SAVE
14559#define alc861vd_loopbacks alc880_loopbacks
14560#endif
14561
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014562/* pcm configuration: identiacal with ALC880 */
14563#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
14564#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
14565#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
14566#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
14567
14568/*
14569 * configuration and preset
14570 */
14571static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
14572 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020014573 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010014574 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014575 [ALC861VD_3ST] = "3stack",
14576 [ALC861VD_3ST_DIG] = "3stack-digout",
14577 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020014578 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020014579 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020014580 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014581 [ALC861VD_AUTO] = "auto",
14582};
14583
14584static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014585 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
14586 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010014587 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014588 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Takashi Iwai13c94742008-11-05 08:06:08 +010014589 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020014590 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014591 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014592 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020014593 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Kailang Yang272a5272007-05-14 11:00:38 +020014594 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Takashi Iwai542d7c62007-08-16 18:57:30 +020014595 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010014596 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020014597 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010014598 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020014599 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014600 {}
14601};
14602
14603static struct alc_config_preset alc861vd_presets[] = {
14604 [ALC660VD_3ST] = {
14605 .mixers = { alc861vd_3st_mixer },
14606 .init_verbs = { alc861vd_volume_init_verbs,
14607 alc861vd_3stack_init_verbs },
14608 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14609 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014610 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14611 .channel_mode = alc861vd_3stack_2ch_modes,
14612 .input_mux = &alc861vd_capture_source,
14613 },
Mike Crash6963f842007-06-25 12:12:51 +020014614 [ALC660VD_3ST_DIG] = {
14615 .mixers = { alc861vd_3st_mixer },
14616 .init_verbs = { alc861vd_volume_init_verbs,
14617 alc861vd_3stack_init_verbs },
14618 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14619 .dac_nids = alc660vd_dac_nids,
14620 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020014621 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14622 .channel_mode = alc861vd_3stack_2ch_modes,
14623 .input_mux = &alc861vd_capture_source,
14624 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014625 [ALC861VD_3ST] = {
14626 .mixers = { alc861vd_3st_mixer },
14627 .init_verbs = { alc861vd_volume_init_verbs,
14628 alc861vd_3stack_init_verbs },
14629 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14630 .dac_nids = alc861vd_dac_nids,
14631 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14632 .channel_mode = alc861vd_3stack_2ch_modes,
14633 .input_mux = &alc861vd_capture_source,
14634 },
14635 [ALC861VD_3ST_DIG] = {
14636 .mixers = { alc861vd_3st_mixer },
14637 .init_verbs = { alc861vd_volume_init_verbs,
14638 alc861vd_3stack_init_verbs },
14639 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14640 .dac_nids = alc861vd_dac_nids,
14641 .dig_out_nid = ALC861VD_DIGOUT_NID,
14642 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14643 .channel_mode = alc861vd_3stack_2ch_modes,
14644 .input_mux = &alc861vd_capture_source,
14645 },
14646 [ALC861VD_6ST_DIG] = {
14647 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
14648 .init_verbs = { alc861vd_volume_init_verbs,
14649 alc861vd_6stack_init_verbs },
14650 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14651 .dac_nids = alc861vd_dac_nids,
14652 .dig_out_nid = ALC861VD_DIGOUT_NID,
14653 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
14654 .channel_mode = alc861vd_6stack_modes,
14655 .input_mux = &alc861vd_capture_source,
14656 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020014657 [ALC861VD_LENOVO] = {
14658 .mixers = { alc861vd_lenovo_mixer },
14659 .init_verbs = { alc861vd_volume_init_verbs,
14660 alc861vd_3stack_init_verbs,
14661 alc861vd_eapd_verbs,
14662 alc861vd_lenovo_unsol_verbs },
14663 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14664 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020014665 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14666 .channel_mode = alc861vd_3stack_2ch_modes,
14667 .input_mux = &alc861vd_capture_source,
14668 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014669 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020014670 },
Kailang Yang272a5272007-05-14 11:00:38 +020014671 [ALC861VD_DALLAS] = {
14672 .mixers = { alc861vd_dallas_mixer },
14673 .init_verbs = { alc861vd_dallas_verbs },
14674 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14675 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020014676 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14677 .channel_mode = alc861vd_3stack_2ch_modes,
14678 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014679 .unsol_event = alc_automute_amp_unsol_event,
14680 .init_hook = alc861vd_dallas_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014681 },
14682 [ALC861VD_HP] = {
14683 .mixers = { alc861vd_hp_mixer },
14684 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
14685 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14686 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014687 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014688 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14689 .channel_mode = alc861vd_3stack_2ch_modes,
14690 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014691 .unsol_event = alc_automute_amp_unsol_event,
14692 .init_hook = alc861vd_dallas_init_hook,
Kailang Yangea1fb292008-08-26 12:58:38 +020014693 },
Takashi Iwai13c94742008-11-05 08:06:08 +010014694 [ALC660VD_ASUS_V1S] = {
14695 .mixers = { alc861vd_lenovo_mixer },
14696 .init_verbs = { alc861vd_volume_init_verbs,
14697 alc861vd_3stack_init_verbs,
14698 alc861vd_eapd_verbs,
14699 alc861vd_lenovo_unsol_verbs },
14700 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14701 .dac_nids = alc660vd_dac_nids,
14702 .dig_out_nid = ALC861VD_DIGOUT_NID,
14703 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14704 .channel_mode = alc861vd_3stack_2ch_modes,
14705 .input_mux = &alc861vd_capture_source,
14706 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014707 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010014708 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014709};
14710
14711/*
14712 * BIOS auto configuration
14713 */
14714static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
14715 hda_nid_t nid, int pin_type, int dac_idx)
14716{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014717 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014718}
14719
14720static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
14721{
14722 struct alc_spec *spec = codec->spec;
14723 int i;
14724
14725 for (i = 0; i <= HDA_SIDE; i++) {
14726 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014727 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014728 if (nid)
14729 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014730 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014731 }
14732}
14733
14734
14735static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
14736{
14737 struct alc_spec *spec = codec->spec;
14738 hda_nid_t pin;
14739
14740 pin = spec->autocfg.hp_pins[0];
14741 if (pin) /* connect to front and use dac 0 */
14742 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014743 pin = spec->autocfg.speaker_pins[0];
14744 if (pin)
14745 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014746}
14747
14748#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
14749#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
14750
14751static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
14752{
14753 struct alc_spec *spec = codec->spec;
14754 int i;
14755
14756 for (i = 0; i < AUTO_PIN_LAST; i++) {
14757 hda_nid_t nid = spec->autocfg.input_pins[i];
14758 if (alc861vd_is_input_pin(nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010014759 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +010014760 if (nid != ALC861VD_PIN_CD_NID &&
14761 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014762 snd_hda_codec_write(codec, nid, 0,
14763 AC_VERB_SET_AMP_GAIN_MUTE,
14764 AMP_OUT_MUTE);
14765 }
14766 }
14767}
14768
Takashi Iwaif511b012008-08-15 16:46:42 +020014769#define alc861vd_auto_init_input_src alc882_auto_init_input_src
14770
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014771#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
14772#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
14773
14774/* add playback controls from the parsed DAC table */
14775/* Based on ALC880 version. But ALC861VD has separate,
14776 * different NIDs for mute/unmute switch and volume control */
14777static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
14778 const struct auto_pin_cfg *cfg)
14779{
14780 char name[32];
14781 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
14782 hda_nid_t nid_v, nid_s;
14783 int i, err;
14784
14785 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014786 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014787 continue;
14788 nid_v = alc861vd_idx_to_mixer_vol(
14789 alc880_dac_to_idx(
14790 spec->multiout.dac_nids[i]));
14791 nid_s = alc861vd_idx_to_mixer_switch(
14792 alc880_dac_to_idx(
14793 spec->multiout.dac_nids[i]));
14794
14795 if (i == 2) {
14796 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014797 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14798 "Center Playback Volume",
14799 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
14800 HDA_OUTPUT));
14801 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014802 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014803 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14804 "LFE Playback Volume",
14805 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
14806 HDA_OUTPUT));
14807 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014808 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014809 err = add_control(spec, ALC_CTL_BIND_MUTE,
14810 "Center Playback Switch",
14811 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
14812 HDA_INPUT));
14813 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014814 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014815 err = add_control(spec, ALC_CTL_BIND_MUTE,
14816 "LFE Playback Switch",
14817 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
14818 HDA_INPUT));
14819 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014820 return err;
14821 } else {
14822 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014823 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
14824 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
14825 HDA_OUTPUT));
14826 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014827 return err;
14828 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014829 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020014830 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014831 HDA_INPUT));
14832 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014833 return err;
14834 }
14835 }
14836 return 0;
14837}
14838
14839/* add playback controls for speaker and HP outputs */
14840/* Based on ALC880 version. But ALC861VD has separate,
14841 * different NIDs for mute/unmute switch and volume control */
14842static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
14843 hda_nid_t pin, const char *pfx)
14844{
14845 hda_nid_t nid_v, nid_s;
14846 int err;
14847 char name[32];
14848
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014849 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014850 return 0;
14851
14852 if (alc880_is_fixed_pin(pin)) {
14853 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
14854 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014855 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014856 spec->multiout.hp_nid = nid_v;
14857 else
14858 spec->multiout.extra_out_nid[0] = nid_v;
14859 /* control HP volume/switch on the output mixer amp */
14860 nid_v = alc861vd_idx_to_mixer_vol(
14861 alc880_fixed_pin_idx(pin));
14862 nid_s = alc861vd_idx_to_mixer_switch(
14863 alc880_fixed_pin_idx(pin));
14864
14865 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014866 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
14867 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
14868 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014869 return err;
14870 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014871 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
14872 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
14873 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014874 return err;
14875 } else if (alc880_is_multi_pin(pin)) {
14876 /* set manual connection */
14877 /* we have only a switch on HP-out PIN */
14878 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014879 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
14880 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
14881 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014882 return err;
14883 }
14884 return 0;
14885}
14886
14887/* parse the BIOS configuration and set up the alc_spec
14888 * return 1 if successful, 0 if the proper config is not found,
14889 * or a negative error code
14890 * Based on ALC880 version - had to change it to override
14891 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
14892static int alc861vd_parse_auto_config(struct hda_codec *codec)
14893{
14894 struct alc_spec *spec = codec->spec;
14895 int err;
14896 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
14897
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014898 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14899 alc861vd_ignore);
14900 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014901 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014902 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014903 return 0; /* can't find valid BIOS pin config */
14904
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014905 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
14906 if (err < 0)
14907 return err;
14908 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
14909 if (err < 0)
14910 return err;
14911 err = alc861vd_auto_create_extra_out(spec,
14912 spec->autocfg.speaker_pins[0],
14913 "Speaker");
14914 if (err < 0)
14915 return err;
14916 err = alc861vd_auto_create_extra_out(spec,
14917 spec->autocfg.hp_pins[0],
14918 "Headphone");
14919 if (err < 0)
14920 return err;
14921 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
14922 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014923 return err;
14924
14925 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14926
Takashi Iwai0852d7a2009-02-11 11:35:15 +010014927 if (spec->autocfg.dig_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014928 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
14929
Takashi Iwai603c4012008-07-30 15:01:44 +020014930 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014931 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014932
Takashi Iwaid88897e2008-10-31 15:01:37 +010014933 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014934
14935 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014936 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014937
Takashi Iwai776e1842007-08-29 15:07:11 +020014938 err = alc_auto_add_mic_boost(codec);
14939 if (err < 0)
14940 return err;
14941
Takashi Iwai4a79ba32009-04-22 16:31:35 +020014942 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
14943
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014944 return 1;
14945}
14946
14947/* additional initialization for auto-configuration model */
14948static void alc861vd_auto_init(struct hda_codec *codec)
14949{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014950 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014951 alc861vd_auto_init_multi_out(codec);
14952 alc861vd_auto_init_hp_out(codec);
14953 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020014954 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014955 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014956 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014957}
14958
14959static int patch_alc861vd(struct hda_codec *codec)
14960{
14961 struct alc_spec *spec;
14962 int err, board_config;
14963
14964 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
14965 if (spec == NULL)
14966 return -ENOMEM;
14967
14968 codec->spec = spec;
14969
14970 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
14971 alc861vd_models,
14972 alc861vd_cfg_tbl);
14973
14974 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
14975 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
14976 "ALC861VD, trying auto-probe from BIOS...\n");
14977 board_config = ALC861VD_AUTO;
14978 }
14979
14980 if (board_config == ALC861VD_AUTO) {
14981 /* automatic parse from the BIOS config */
14982 err = alc861vd_parse_auto_config(codec);
14983 if (err < 0) {
14984 alc_free(codec);
14985 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014986 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014987 printk(KERN_INFO
14988 "hda_codec: Cannot set up configuration "
14989 "from BIOS. Using base mode...\n");
14990 board_config = ALC861VD_3ST;
14991 }
14992 }
14993
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014994 err = snd_hda_attach_beep_device(codec, 0x23);
14995 if (err < 0) {
14996 alc_free(codec);
14997 return err;
14998 }
14999
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015000 if (board_config != ALC861VD_AUTO)
15001 setup_preset(spec, &alc861vd_presets[board_config]);
15002
Kailang Yang2f893282008-05-27 12:14:47 +020015003 if (codec->vendor_id == 0x10ec0660) {
15004 spec->stream_name_analog = "ALC660-VD Analog";
15005 spec->stream_name_digital = "ALC660-VD Digital";
Kailang Yangf9423e72008-05-27 12:32:25 +020015006 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010015007 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020015008 } else {
15009 spec->stream_name_analog = "ALC861VD Analog";
15010 spec->stream_name_digital = "ALC861VD Digital";
15011 }
15012
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015013 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
15014 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
15015
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015016 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
15017 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
15018
15019 spec->adc_nids = alc861vd_adc_nids;
15020 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +010015021 spec->capsrc_nids = alc861vd_capsrc_nids;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015022 spec->capture_style = CAPT_MIX;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015023
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015024 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015025 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015026
Takashi Iwai2134ea42008-01-10 16:53:55 +010015027 spec->vmaster_nid = 0x02;
15028
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015029 codec->patch_ops = alc_patch_ops;
15030
15031 if (board_config == ALC861VD_AUTO)
15032 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015033#ifdef CONFIG_SND_HDA_POWER_SAVE
15034 if (!spec->loopback.amplist)
15035 spec->loopback.amplist = alc861vd_loopbacks;
15036#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010015037 codec->proc_widget_hook = print_realtek_coef;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015038
15039 return 0;
15040}
15041
15042/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015043 * ALC662 support
15044 *
15045 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
15046 * configuration. Each pin widget can choose any input DACs and a mixer.
15047 * Each ADC is connected from a mixer of all inputs. This makes possible
15048 * 6-channel independent captures.
15049 *
15050 * In addition, an independent DAC for the multi-playback (not used in this
15051 * driver yet).
15052 */
15053#define ALC662_DIGOUT_NID 0x06
15054#define ALC662_DIGIN_NID 0x0a
15055
15056static hda_nid_t alc662_dac_nids[4] = {
15057 /* front, rear, clfe, rear_surr */
15058 0x02, 0x03, 0x04
15059};
15060
Kailang Yang622e84c2009-04-21 07:39:04 +020015061static hda_nid_t alc272_dac_nids[2] = {
15062 0x02, 0x03
15063};
15064
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015065static hda_nid_t alc662_adc_nids[1] = {
15066 /* ADC1-2 */
15067 0x09,
15068};
Takashi Iwaie1406342008-02-11 18:32:32 +010015069
Kailang Yang622e84c2009-04-21 07:39:04 +020015070static hda_nid_t alc272_adc_nids[1] = {
15071 /* ADC1-2 */
15072 0x08,
15073};
15074
Kailang Yang77a261b2008-02-19 11:38:05 +010015075static hda_nid_t alc662_capsrc_nids[1] = { 0x22 };
Kailang Yang622e84c2009-04-21 07:39:04 +020015076static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
15077
Takashi Iwaie1406342008-02-11 18:32:32 +010015078
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015079/* input MUX */
15080/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015081static struct hda_input_mux alc662_capture_source = {
15082 .num_items = 4,
15083 .items = {
15084 { "Mic", 0x0 },
15085 { "Front Mic", 0x1 },
15086 { "Line", 0x2 },
15087 { "CD", 0x4 },
15088 },
15089};
15090
15091static struct hda_input_mux alc662_lenovo_101e_capture_source = {
15092 .num_items = 2,
15093 .items = {
15094 { "Mic", 0x1 },
15095 { "Line", 0x2 },
15096 },
15097};
Kailang Yang291702f2007-10-16 14:28:03 +020015098
15099static struct hda_input_mux alc662_eeepc_capture_source = {
15100 .num_items = 2,
15101 .items = {
15102 { "i-Mic", 0x1 },
15103 { "e-Mic", 0x0 },
15104 },
15105};
15106
Kailang Yang6dda9f42008-05-27 12:05:31 +020015107static struct hda_input_mux alc663_capture_source = {
15108 .num_items = 3,
15109 .items = {
15110 { "Mic", 0x0 },
15111 { "Front Mic", 0x1 },
15112 { "Line", 0x2 },
15113 },
15114};
15115
15116static struct hda_input_mux alc663_m51va_capture_source = {
15117 .num_items = 2,
15118 .items = {
15119 { "Ext-Mic", 0x0 },
15120 { "D-Mic", 0x9 },
15121 },
15122};
15123
Chris Pockelé9541ba12009-05-12 08:08:53 +020015124#if 1 /* set to 0 for testing other input sources below */
15125static struct hda_input_mux alc272_nc10_capture_source = {
15126 .num_items = 2,
15127 .items = {
15128 { "Autoselect Mic", 0x0 },
15129 { "Internal Mic", 0x1 },
15130 },
15131};
15132#else
15133static struct hda_input_mux alc272_nc10_capture_source = {
15134 .num_items = 16,
15135 .items = {
15136 { "Autoselect Mic", 0x0 },
15137 { "Internal Mic", 0x1 },
15138 { "In-0x02", 0x2 },
15139 { "In-0x03", 0x3 },
15140 { "In-0x04", 0x4 },
15141 { "In-0x05", 0x5 },
15142 { "In-0x06", 0x6 },
15143 { "In-0x07", 0x7 },
15144 { "In-0x08", 0x8 },
15145 { "In-0x09", 0x9 },
15146 { "In-0x0a", 0x0a },
15147 { "In-0x0b", 0x0b },
15148 { "In-0x0c", 0x0c },
15149 { "In-0x0d", 0x0d },
15150 { "In-0x0e", 0x0e },
15151 { "In-0x0f", 0x0f },
15152 },
15153};
15154#endif
15155
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015156/*
15157 * 2ch mode
15158 */
15159static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
15160 { 2, NULL }
15161};
15162
15163/*
15164 * 2ch mode
15165 */
15166static struct hda_verb alc662_3ST_ch2_init[] = {
15167 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
15168 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15169 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
15170 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15171 { } /* end */
15172};
15173
15174/*
15175 * 6ch mode
15176 */
15177static struct hda_verb alc662_3ST_ch6_init[] = {
15178 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15179 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15180 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
15181 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15182 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15183 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
15184 { } /* end */
15185};
15186
15187static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
15188 { 2, alc662_3ST_ch2_init },
15189 { 6, alc662_3ST_ch6_init },
15190};
15191
15192/*
15193 * 2ch mode
15194 */
15195static struct hda_verb alc662_sixstack_ch6_init[] = {
15196 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15197 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15198 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15199 { } /* end */
15200};
15201
15202/*
15203 * 6ch mode
15204 */
15205static struct hda_verb alc662_sixstack_ch8_init[] = {
15206 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15207 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15208 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15209 { } /* end */
15210};
15211
15212static struct hda_channel_mode alc662_5stack_modes[2] = {
15213 { 2, alc662_sixstack_ch6_init },
15214 { 6, alc662_sixstack_ch8_init },
15215};
15216
15217/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15218 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15219 */
15220
15221static struct snd_kcontrol_new alc662_base_mixer[] = {
15222 /* output mixer control */
15223 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015224 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015225 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015226 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015227 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15228 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015229 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15230 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015231 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15232
15233 /*Input mixer control */
15234 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
15235 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
15236 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
15237 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
15238 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
15239 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
15240 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
15241 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015242 { } /* end */
15243};
15244
15245static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
15246 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015247 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015248 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15249 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15250 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15251 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15252 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15253 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15254 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15255 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15256 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015257 { } /* end */
15258};
15259
15260static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
15261 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015262 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015263 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015264 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015265 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15266 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015267 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15268 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015269 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15270 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15271 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15272 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15273 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15274 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15275 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15276 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15277 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015278 { } /* end */
15279};
15280
15281static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
15282 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15283 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010015284 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15285 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015286 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15287 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15288 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15289 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15290 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015291 { } /* end */
15292};
15293
Kailang Yang291702f2007-10-16 14:28:03 +020015294static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020015295 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15296 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020015297
15298 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
15299 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15300 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15301
15302 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
15303 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15304 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15305 { } /* end */
15306};
15307
Kailang Yang8c427222008-01-10 13:03:59 +010015308static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020015309 ALC262_HIPPO_MASTER_SWITCH,
15310 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015311 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015312 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15313 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015314 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
15315 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15316 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15317 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15318 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15319 { } /* end */
15320};
15321
Kailang Yangf1d4e282008-08-26 14:03:29 +020015322static struct hda_bind_ctls alc663_asus_bind_master_vol = {
15323 .ops = &snd_hda_bind_vol,
15324 .values = {
15325 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15326 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
15327 0
15328 },
15329};
15330
15331static struct hda_bind_ctls alc663_asus_one_bind_switch = {
15332 .ops = &snd_hda_bind_sw,
15333 .values = {
15334 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15335 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15336 0
15337 },
15338};
15339
Kailang Yang6dda9f42008-05-27 12:05:31 +020015340static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015341 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15342 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
15343 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15344 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15345 { } /* end */
15346};
15347
15348static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
15349 .ops = &snd_hda_bind_sw,
15350 .values = {
15351 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15352 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15353 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15354 0
15355 },
15356};
15357
15358static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
15359 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15360 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
15361 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15362 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15363 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15364 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15365
15366 { } /* end */
15367};
15368
15369static struct hda_bind_ctls alc663_asus_four_bind_switch = {
15370 .ops = &snd_hda_bind_sw,
15371 .values = {
15372 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15373 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15374 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
15375 0
15376 },
15377};
15378
15379static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
15380 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15381 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
15382 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15383 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15384 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15385 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15386 { } /* end */
15387};
15388
15389static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020015390 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15391 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015392 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15393 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15394 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15395 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15396 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15397 { } /* end */
15398};
15399
15400static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
15401 .ops = &snd_hda_bind_vol,
15402 .values = {
15403 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15404 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
15405 0
15406 },
15407};
15408
15409static struct hda_bind_ctls alc663_asus_two_bind_switch = {
15410 .ops = &snd_hda_bind_sw,
15411 .values = {
15412 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15413 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
15414 0
15415 },
15416};
15417
15418static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
15419 HDA_BIND_VOL("Master Playback Volume",
15420 &alc663_asus_two_bind_master_vol),
15421 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15422 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015423 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15424 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15425 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015426 { } /* end */
15427};
15428
15429static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
15430 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15431 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15432 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15433 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15434 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15435 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015436 { } /* end */
15437};
15438
15439static struct snd_kcontrol_new alc663_g71v_mixer[] = {
15440 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15441 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15442 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15443 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15444 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15445
15446 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15447 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15448 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15449 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15450 { } /* end */
15451};
15452
15453static struct snd_kcontrol_new alc663_g50v_mixer[] = {
15454 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15455 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15456 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15457
15458 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15459 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15460 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15461 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15462 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15463 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15464 { } /* end */
15465};
15466
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015467static struct snd_kcontrol_new alc662_chmode_mixer[] = {
15468 {
15469 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15470 .name = "Channel Mode",
15471 .info = alc_ch_mode_info,
15472 .get = alc_ch_mode_get,
15473 .put = alc_ch_mode_put,
15474 },
15475 { } /* end */
15476};
15477
15478static struct hda_verb alc662_init_verbs[] = {
15479 /* ADC: mute amp left and right */
15480 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15481 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15482 /* Front mixer: unmute input/output amp left and right (volume = 0) */
15483
Takashi Iwaicb53c622007-08-10 17:21:45 +020015484 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15485 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15486 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15487 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15488 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015489
Kailang Yangb60dd392007-09-20 12:50:29 +020015490 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15491 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15492 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15493 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15494 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15495 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015496
15497 /* Front Pin: output 0 (0x0c) */
15498 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15499 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15500
15501 /* Rear Pin: output 1 (0x0d) */
15502 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15503 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15504
15505 /* CLFE Pin: output 2 (0x0e) */
15506 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15507 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15508
15509 /* Mic (rear) pin: input vref at 80% */
15510 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15511 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15512 /* Front Mic pin: input vref at 80% */
15513 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15514 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15515 /* Line In pin: input */
15516 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15517 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15518 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15519 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15520 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15521 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15522 /* CD pin widget for input */
15523 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15524
15525 /* FIXME: use matrix-type input source selection */
15526 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15527 /* Input mixer */
15528 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020015529 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015530
15531 /* always trun on EAPD */
15532 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15533 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
15534
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015535 { }
15536};
15537
15538static struct hda_verb alc662_sue_init_verbs[] = {
15539 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15540 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020015541 {}
15542};
15543
15544static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
15545 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15546 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15547 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015548};
15549
Kailang Yang8c427222008-01-10 13:03:59 +010015550/* Set Unsolicited Event*/
15551static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
15552 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15553 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15554 {}
15555};
15556
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015557/*
15558 * generic initialization of ADC, input mixers and output mixers
15559 */
15560static struct hda_verb alc662_auto_init_verbs[] = {
15561 /*
15562 * Unmute ADC and set the default input to mic-in
15563 */
15564 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15565 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15566
15567 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
15568 * mixer widget
15569 * Note: PASD motherboards uses the Line In 2 as the input for front
15570 * panel mic (mic 2)
15571 */
15572 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020015573 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15574 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15575 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15576 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15577 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015578
15579 /*
15580 * Set up output mixers (0x0c - 0x0f)
15581 */
15582 /* set vol=0 to output mixers */
15583 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15584 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15585 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15586
15587 /* set up input amps for analog loopback */
15588 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020015589 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15590 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15591 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15592 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15593 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15594 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015595
15596
15597 /* FIXME: use matrix-type input source selection */
15598 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15599 /* Input mixer */
15600 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020015601 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015602 { }
15603};
15604
Takashi Iwai24fb9172008-09-02 14:48:20 +020015605/* additional verbs for ALC663 */
15606static struct hda_verb alc663_auto_init_verbs[] = {
15607 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15608 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15609 { }
15610};
15611
Kailang Yang6dda9f42008-05-27 12:05:31 +020015612static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015613 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15614 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015615 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15616 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020015617 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15618 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15619 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015620 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15621 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15622 {}
15623};
15624
Kailang Yangf1d4e282008-08-26 14:03:29 +020015625static struct hda_verb alc663_21jd_amic_init_verbs[] = {
15626 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15627 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15628 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15629 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15630 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15631 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15632 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15633 {}
15634};
15635
15636static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
15637 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15638 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15639 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15640 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15641 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15642 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15643 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15644 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15645 {}
15646};
15647
15648static struct hda_verb alc663_15jd_amic_init_verbs[] = {
15649 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15650 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15651 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15652 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15653 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15654 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15655 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15656 {}
15657};
15658
15659static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
15660 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15661 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15662 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15663 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15664 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15665 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15666 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15667 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15668 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15669 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15670 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15671 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15672 {}
15673};
15674
15675static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
15676 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15677 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15678 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15679 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15680 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15681 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15682 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15683 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15684 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15685 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15686 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15687 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15688 {}
15689};
15690
Kailang Yang6dda9f42008-05-27 12:05:31 +020015691static struct hda_verb alc663_g71v_init_verbs[] = {
15692 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15693 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
15694 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
15695
15696 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15697 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15698 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15699
15700 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15701 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
15702 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
15703 {}
15704};
15705
15706static struct hda_verb alc663_g50v_init_verbs[] = {
15707 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15708 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15709 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15710
15711 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15712 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15713 {}
15714};
15715
Kailang Yangf1d4e282008-08-26 14:03:29 +020015716static struct hda_verb alc662_ecs_init_verbs[] = {
15717 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
15718 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15719 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15720 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15721 {}
15722};
15723
Kailang Yang622e84c2009-04-21 07:39:04 +020015724static struct hda_verb alc272_dell_zm1_init_verbs[] = {
15725 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15726 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15727 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15728 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15729 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15730 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15731 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15732 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15733 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
15734 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15735 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15736 {}
15737};
15738
15739static struct hda_verb alc272_dell_init_verbs[] = {
15740 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15741 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15742 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15743 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15744 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15745 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15746 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15747 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15748 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
15749 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15750 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15751 {}
15752};
15753
Kailang Yangf1d4e282008-08-26 14:03:29 +020015754static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
15755 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
15756 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
15757 { } /* end */
15758};
15759
Kailang Yang622e84c2009-04-21 07:39:04 +020015760static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
15761 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
15762 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
15763 { } /* end */
15764};
15765
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015766static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
15767{
15768 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015769 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015770
15771 present = snd_hda_codec_read(codec, 0x14, 0,
15772 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020015773 bits = present ? HDA_AMP_MUTE : 0;
15774 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15775 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015776}
15777
15778static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
15779{
15780 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015781 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015782
15783 present = snd_hda_codec_read(codec, 0x1b, 0,
15784 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020015785 bits = present ? HDA_AMP_MUTE : 0;
15786 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15787 HDA_AMP_MUTE, bits);
15788 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
15789 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015790}
15791
15792static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
15793 unsigned int res)
15794{
15795 if ((res >> 26) == ALC880_HP_EVENT)
15796 alc662_lenovo_101e_all_automute(codec);
15797 if ((res >> 26) == ALC880_FRONT_EVENT)
15798 alc662_lenovo_101e_ispeaker_automute(codec);
15799}
15800
Kailang Yang291702f2007-10-16 14:28:03 +020015801static void alc662_eeepc_mic_automute(struct hda_codec *codec)
15802{
15803 unsigned int present;
15804
15805 present = snd_hda_codec_read(codec, 0x18, 0,
15806 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
15807 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15808 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
15809 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15810 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
15811 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15812 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
15813 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15814 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
15815}
15816
15817/* unsolicited event for HP jack sensing */
15818static void alc662_eeepc_unsol_event(struct hda_codec *codec,
15819 unsigned int res)
15820{
Kailang Yang291702f2007-10-16 14:28:03 +020015821 if ((res >> 26) == ALC880_MIC_EVENT)
15822 alc662_eeepc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020015823 else
15824 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020015825}
15826
15827static void alc662_eeepc_inithook(struct hda_codec *codec)
15828{
Takashi Iwai42171c12009-05-08 14:11:43 +020015829 alc262_hippo1_init_hook(codec);
Kailang Yang291702f2007-10-16 14:28:03 +020015830 alc662_eeepc_mic_automute(codec);
15831}
15832
Kailang Yang8c427222008-01-10 13:03:59 +010015833static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
15834{
Takashi Iwai42171c12009-05-08 14:11:43 +020015835 struct alc_spec *spec = codec->spec;
15836
15837 spec->autocfg.hp_pins[0] = 0x14;
15838 spec->autocfg.speaker_pins[0] = 0x1b;
15839 alc262_hippo_master_update(codec);
Kailang Yang8c427222008-01-10 13:03:59 +010015840}
15841
Kailang Yang6dda9f42008-05-27 12:05:31 +020015842static void alc663_m51va_speaker_automute(struct hda_codec *codec)
15843{
15844 unsigned int present;
15845 unsigned char bits;
15846
15847 present = snd_hda_codec_read(codec, 0x21, 0,
Kailang Yangf1d4e282008-08-26 14:03:29 +020015848 AC_VERB_GET_PIN_SENSE, 0)
15849 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020015850 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020015851 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15852 AMP_IN_MUTE(0), bits);
15853 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15854 AMP_IN_MUTE(0), bits);
15855}
15856
15857static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
15858{
15859 unsigned int present;
15860 unsigned char bits;
15861
15862 present = snd_hda_codec_read(codec, 0x21, 0,
15863 AC_VERB_GET_PIN_SENSE, 0)
15864 & AC_PINSENSE_PRESENCE;
15865 bits = present ? HDA_AMP_MUTE : 0;
15866 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15867 AMP_IN_MUTE(0), bits);
15868 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15869 AMP_IN_MUTE(0), bits);
15870 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
15871 AMP_IN_MUTE(0), bits);
15872 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
15873 AMP_IN_MUTE(0), bits);
15874}
15875
15876static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
15877{
15878 unsigned int present;
15879 unsigned char bits;
15880
15881 present = snd_hda_codec_read(codec, 0x15, 0,
15882 AC_VERB_GET_PIN_SENSE, 0)
15883 & AC_PINSENSE_PRESENCE;
15884 bits = present ? HDA_AMP_MUTE : 0;
15885 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15886 AMP_IN_MUTE(0), bits);
15887 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15888 AMP_IN_MUTE(0), bits);
15889 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
15890 AMP_IN_MUTE(0), bits);
15891 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
15892 AMP_IN_MUTE(0), bits);
15893}
15894
15895static void alc662_f5z_speaker_automute(struct hda_codec *codec)
15896{
15897 unsigned int present;
15898 unsigned char bits;
15899
15900 present = snd_hda_codec_read(codec, 0x1b, 0,
15901 AC_VERB_GET_PIN_SENSE, 0)
15902 & AC_PINSENSE_PRESENCE;
15903 bits = present ? 0 : PIN_OUT;
15904 snd_hda_codec_write(codec, 0x14, 0,
15905 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
15906}
15907
15908static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
15909{
15910 unsigned int present1, present2;
15911
15912 present1 = snd_hda_codec_read(codec, 0x21, 0,
15913 AC_VERB_GET_PIN_SENSE, 0)
15914 & AC_PINSENSE_PRESENCE;
15915 present2 = snd_hda_codec_read(codec, 0x15, 0,
15916 AC_VERB_GET_PIN_SENSE, 0)
15917 & AC_PINSENSE_PRESENCE;
15918
15919 if (present1 || present2) {
15920 snd_hda_codec_write_cache(codec, 0x14, 0,
15921 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
15922 } else {
15923 snd_hda_codec_write_cache(codec, 0x14, 0,
15924 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
15925 }
15926}
15927
15928static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
15929{
15930 unsigned int present1, present2;
15931
15932 present1 = snd_hda_codec_read(codec, 0x1b, 0,
15933 AC_VERB_GET_PIN_SENSE, 0)
15934 & AC_PINSENSE_PRESENCE;
15935 present2 = snd_hda_codec_read(codec, 0x15, 0,
15936 AC_VERB_GET_PIN_SENSE, 0)
15937 & AC_PINSENSE_PRESENCE;
15938
15939 if (present1 || present2) {
15940 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15941 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
15942 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15943 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
15944 } else {
15945 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15946 AMP_IN_MUTE(0), 0);
15947 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15948 AMP_IN_MUTE(0), 0);
15949 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020015950}
15951
15952static void alc663_m51va_mic_automute(struct hda_codec *codec)
15953{
15954 unsigned int present;
15955
15956 present = snd_hda_codec_read(codec, 0x18, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020015957 AC_VERB_GET_PIN_SENSE, 0)
15958 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020015959 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015960 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015961 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015962 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015963 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015964 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015965 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015966 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015967}
15968
15969static void alc663_m51va_unsol_event(struct hda_codec *codec,
15970 unsigned int res)
15971{
15972 switch (res >> 26) {
15973 case ALC880_HP_EVENT:
15974 alc663_m51va_speaker_automute(codec);
15975 break;
15976 case ALC880_MIC_EVENT:
15977 alc663_m51va_mic_automute(codec);
15978 break;
15979 }
15980}
15981
15982static void alc663_m51va_inithook(struct hda_codec *codec)
15983{
15984 alc663_m51va_speaker_automute(codec);
15985 alc663_m51va_mic_automute(codec);
15986}
15987
Kailang Yangf1d4e282008-08-26 14:03:29 +020015988/* ***************** Mode1 ******************************/
15989static void alc663_mode1_unsol_event(struct hda_codec *codec,
15990 unsigned int res)
15991{
15992 switch (res >> 26) {
15993 case ALC880_HP_EVENT:
15994 alc663_m51va_speaker_automute(codec);
15995 break;
15996 case ALC880_MIC_EVENT:
15997 alc662_eeepc_mic_automute(codec);
15998 break;
15999 }
16000}
16001
16002static void alc663_mode1_inithook(struct hda_codec *codec)
16003{
16004 alc663_m51va_speaker_automute(codec);
16005 alc662_eeepc_mic_automute(codec);
16006}
16007/* ***************** Mode2 ******************************/
16008static void alc662_mode2_unsol_event(struct hda_codec *codec,
16009 unsigned int res)
16010{
16011 switch (res >> 26) {
16012 case ALC880_HP_EVENT:
16013 alc662_f5z_speaker_automute(codec);
16014 break;
16015 case ALC880_MIC_EVENT:
16016 alc662_eeepc_mic_automute(codec);
16017 break;
16018 }
16019}
16020
16021static void alc662_mode2_inithook(struct hda_codec *codec)
16022{
16023 alc662_f5z_speaker_automute(codec);
16024 alc662_eeepc_mic_automute(codec);
16025}
16026/* ***************** Mode3 ******************************/
16027static void alc663_mode3_unsol_event(struct hda_codec *codec,
16028 unsigned int res)
16029{
16030 switch (res >> 26) {
16031 case ALC880_HP_EVENT:
16032 alc663_two_hp_m1_speaker_automute(codec);
16033 break;
16034 case ALC880_MIC_EVENT:
16035 alc662_eeepc_mic_automute(codec);
16036 break;
16037 }
16038}
16039
16040static void alc663_mode3_inithook(struct hda_codec *codec)
16041{
16042 alc663_two_hp_m1_speaker_automute(codec);
16043 alc662_eeepc_mic_automute(codec);
16044}
16045/* ***************** Mode4 ******************************/
16046static void alc663_mode4_unsol_event(struct hda_codec *codec,
16047 unsigned int res)
16048{
16049 switch (res >> 26) {
16050 case ALC880_HP_EVENT:
16051 alc663_21jd_two_speaker_automute(codec);
16052 break;
16053 case ALC880_MIC_EVENT:
16054 alc662_eeepc_mic_automute(codec);
16055 break;
16056 }
16057}
16058
16059static void alc663_mode4_inithook(struct hda_codec *codec)
16060{
16061 alc663_21jd_two_speaker_automute(codec);
16062 alc662_eeepc_mic_automute(codec);
16063}
16064/* ***************** Mode5 ******************************/
16065static void alc663_mode5_unsol_event(struct hda_codec *codec,
16066 unsigned int res)
16067{
16068 switch (res >> 26) {
16069 case ALC880_HP_EVENT:
16070 alc663_15jd_two_speaker_automute(codec);
16071 break;
16072 case ALC880_MIC_EVENT:
16073 alc662_eeepc_mic_automute(codec);
16074 break;
16075 }
16076}
16077
16078static void alc663_mode5_inithook(struct hda_codec *codec)
16079{
16080 alc663_15jd_two_speaker_automute(codec);
16081 alc662_eeepc_mic_automute(codec);
16082}
16083/* ***************** Mode6 ******************************/
16084static void alc663_mode6_unsol_event(struct hda_codec *codec,
16085 unsigned int res)
16086{
16087 switch (res >> 26) {
16088 case ALC880_HP_EVENT:
16089 alc663_two_hp_m2_speaker_automute(codec);
16090 break;
16091 case ALC880_MIC_EVENT:
16092 alc662_eeepc_mic_automute(codec);
16093 break;
16094 }
16095}
16096
16097static void alc663_mode6_inithook(struct hda_codec *codec)
16098{
16099 alc663_two_hp_m2_speaker_automute(codec);
16100 alc662_eeepc_mic_automute(codec);
16101}
16102
Kailang Yang6dda9f42008-05-27 12:05:31 +020016103static void alc663_g71v_hp_automute(struct hda_codec *codec)
16104{
16105 unsigned int present;
16106 unsigned char bits;
16107
16108 present = snd_hda_codec_read(codec, 0x21, 0,
16109 AC_VERB_GET_PIN_SENSE, 0)
16110 & AC_PINSENSE_PRESENCE;
16111 bits = present ? HDA_AMP_MUTE : 0;
16112 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16113 HDA_AMP_MUTE, bits);
16114 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16115 HDA_AMP_MUTE, bits);
16116}
16117
16118static void alc663_g71v_front_automute(struct hda_codec *codec)
16119{
16120 unsigned int present;
16121 unsigned char bits;
16122
16123 present = snd_hda_codec_read(codec, 0x15, 0,
16124 AC_VERB_GET_PIN_SENSE, 0)
16125 & AC_PINSENSE_PRESENCE;
16126 bits = present ? HDA_AMP_MUTE : 0;
16127 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16128 HDA_AMP_MUTE, bits);
16129}
16130
16131static void alc663_g71v_unsol_event(struct hda_codec *codec,
16132 unsigned int res)
16133{
16134 switch (res >> 26) {
16135 case ALC880_HP_EVENT:
16136 alc663_g71v_hp_automute(codec);
16137 break;
16138 case ALC880_FRONT_EVENT:
16139 alc663_g71v_front_automute(codec);
16140 break;
16141 case ALC880_MIC_EVENT:
16142 alc662_eeepc_mic_automute(codec);
16143 break;
16144 }
16145}
16146
16147static void alc663_g71v_inithook(struct hda_codec *codec)
16148{
16149 alc663_g71v_front_automute(codec);
16150 alc663_g71v_hp_automute(codec);
16151 alc662_eeepc_mic_automute(codec);
16152}
16153
16154static void alc663_g50v_unsol_event(struct hda_codec *codec,
16155 unsigned int res)
16156{
16157 switch (res >> 26) {
16158 case ALC880_HP_EVENT:
16159 alc663_m51va_speaker_automute(codec);
16160 break;
16161 case ALC880_MIC_EVENT:
16162 alc662_eeepc_mic_automute(codec);
16163 break;
16164 }
16165}
16166
16167static void alc663_g50v_inithook(struct hda_codec *codec)
16168{
16169 alc663_m51va_speaker_automute(codec);
16170 alc662_eeepc_mic_automute(codec);
16171}
16172
Kailang Yangf1d4e282008-08-26 14:03:29 +020016173static struct snd_kcontrol_new alc662_ecs_mixer[] = {
16174 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020016175 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016176
16177 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
16178 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
16179 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
16180
16181 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16182 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16183 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16184 { } /* end */
16185};
16186
Chris Pockelé9541ba12009-05-12 08:08:53 +020016187static struct snd_kcontrol_new alc272_nc10_mixer[] = {
16188 /* Master Playback automatically created from Speaker and Headphone */
16189 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16190 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16191 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16192 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16193
16194 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16195 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16196 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
16197
16198 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16199 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16200 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
16201 { } /* end */
16202};
16203
Takashi Iwaicb53c622007-08-10 17:21:45 +020016204#ifdef CONFIG_SND_HDA_POWER_SAVE
16205#define alc662_loopbacks alc880_loopbacks
16206#endif
16207
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016208
16209/* pcm configuration: identiacal with ALC880 */
16210#define alc662_pcm_analog_playback alc880_pcm_analog_playback
16211#define alc662_pcm_analog_capture alc880_pcm_analog_capture
16212#define alc662_pcm_digital_playback alc880_pcm_digital_playback
16213#define alc662_pcm_digital_capture alc880_pcm_digital_capture
16214
16215/*
16216 * configuration and preset
16217 */
16218static const char *alc662_models[ALC662_MODEL_LAST] = {
16219 [ALC662_3ST_2ch_DIG] = "3stack-dig",
16220 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
16221 [ALC662_3ST_6ch] = "3stack-6ch",
16222 [ALC662_5ST_DIG] = "6stack-dig",
16223 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020016224 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010016225 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016226 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020016227 [ALC663_ASUS_M51VA] = "m51va",
16228 [ALC663_ASUS_G71V] = "g71v",
16229 [ALC663_ASUS_H13] = "h13",
16230 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016231 [ALC663_ASUS_MODE1] = "asus-mode1",
16232 [ALC662_ASUS_MODE2] = "asus-mode2",
16233 [ALC663_ASUS_MODE3] = "asus-mode3",
16234 [ALC663_ASUS_MODE4] = "asus-mode4",
16235 [ALC663_ASUS_MODE5] = "asus-mode5",
16236 [ALC663_ASUS_MODE6] = "asus-mode6",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020016237 [ALC272_DELL] = "dell",
16238 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020016239 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016240 [ALC662_AUTO] = "auto",
16241};
16242
16243static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010016244 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020016245 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
16246 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016247 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
16248 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
16249 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
16250 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
16251 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
16252 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
16253 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
16254 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
16255 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
16256 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
16257 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
16258 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016259 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
16260 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
16261 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016262 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
16263 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
16264 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
16265 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016266 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016267 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
16268 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016269 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016270 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
16271 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
16272 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020016273 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
16274 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
16275 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016276 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
16277 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
16278 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016279 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016280 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
16281 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020016282 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016283 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020016284 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016285 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
16286 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
16287 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016288 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016289 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
16290 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010016291 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020016292 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010016293 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016294 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030016295 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
16296 ALC662_3ST_6ch_DIG),
Chris Pockelé9541ba12009-05-12 08:08:53 +020016297 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030016298 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
16299 ALC662_3ST_6ch_DIG),
Vedran Miletic19c009a2008-09-29 20:29:25 +020016300 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020016301 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016302 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020016303 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020016304 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016305 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
16306 ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016307 {}
16308};
16309
16310static struct alc_config_preset alc662_presets[] = {
16311 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016312 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016313 .init_verbs = { alc662_init_verbs },
16314 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16315 .dac_nids = alc662_dac_nids,
16316 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016317 .dig_in_nid = ALC662_DIGIN_NID,
16318 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16319 .channel_mode = alc662_3ST_2ch_modes,
16320 .input_mux = &alc662_capture_source,
16321 },
16322 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016323 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016324 .init_verbs = { alc662_init_verbs },
16325 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16326 .dac_nids = alc662_dac_nids,
16327 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016328 .dig_in_nid = ALC662_DIGIN_NID,
16329 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16330 .channel_mode = alc662_3ST_6ch_modes,
16331 .need_dac_fix = 1,
16332 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016333 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016334 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016335 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016336 .init_verbs = { alc662_init_verbs },
16337 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16338 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016339 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16340 .channel_mode = alc662_3ST_6ch_modes,
16341 .need_dac_fix = 1,
16342 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016343 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016344 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016345 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016346 .init_verbs = { alc662_init_verbs },
16347 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16348 .dac_nids = alc662_dac_nids,
16349 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016350 .dig_in_nid = ALC662_DIGIN_NID,
16351 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
16352 .channel_mode = alc662_5stack_modes,
16353 .input_mux = &alc662_capture_source,
16354 },
16355 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016356 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016357 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
16358 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16359 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016360 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16361 .channel_mode = alc662_3ST_2ch_modes,
16362 .input_mux = &alc662_lenovo_101e_capture_source,
16363 .unsol_event = alc662_lenovo_101e_unsol_event,
16364 .init_hook = alc662_lenovo_101e_all_automute,
16365 },
Kailang Yang291702f2007-10-16 14:28:03 +020016366 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016367 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020016368 .init_verbs = { alc662_init_verbs,
16369 alc662_eeepc_sue_init_verbs },
16370 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16371 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020016372 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16373 .channel_mode = alc662_3ST_2ch_modes,
16374 .input_mux = &alc662_eeepc_capture_source,
16375 .unsol_event = alc662_eeepc_unsol_event,
16376 .init_hook = alc662_eeepc_inithook,
16377 },
Kailang Yang8c427222008-01-10 13:03:59 +010016378 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016379 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010016380 alc662_chmode_mixer },
16381 .init_verbs = { alc662_init_verbs,
16382 alc662_eeepc_ep20_sue_init_verbs },
16383 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16384 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010016385 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16386 .channel_mode = alc662_3ST_6ch_modes,
16387 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020016388 .unsol_event = alc662_eeepc_unsol_event,
Kailang Yang8c427222008-01-10 13:03:59 +010016389 .init_hook = alc662_eeepc_ep20_inithook,
16390 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016391 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016392 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016393 .init_verbs = { alc662_init_verbs,
16394 alc662_ecs_init_verbs },
16395 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16396 .dac_nids = alc662_dac_nids,
16397 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16398 .channel_mode = alc662_3ST_2ch_modes,
16399 .input_mux = &alc662_eeepc_capture_source,
16400 .unsol_event = alc662_eeepc_unsol_event,
16401 .init_hook = alc662_eeepc_inithook,
16402 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016403 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016404 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016405 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16406 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16407 .dac_nids = alc662_dac_nids,
16408 .dig_out_nid = ALC662_DIGOUT_NID,
16409 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16410 .channel_mode = alc662_3ST_2ch_modes,
16411 .input_mux = &alc663_m51va_capture_source,
16412 .unsol_event = alc663_m51va_unsol_event,
16413 .init_hook = alc663_m51va_inithook,
16414 },
16415 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016416 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016417 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
16418 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16419 .dac_nids = alc662_dac_nids,
16420 .dig_out_nid = ALC662_DIGOUT_NID,
16421 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16422 .channel_mode = alc662_3ST_2ch_modes,
16423 .input_mux = &alc662_eeepc_capture_source,
16424 .unsol_event = alc663_g71v_unsol_event,
16425 .init_hook = alc663_g71v_inithook,
16426 },
16427 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016428 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016429 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16430 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16431 .dac_nids = alc662_dac_nids,
16432 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16433 .channel_mode = alc662_3ST_2ch_modes,
16434 .input_mux = &alc663_m51va_capture_source,
16435 .unsol_event = alc663_m51va_unsol_event,
16436 .init_hook = alc663_m51va_inithook,
16437 },
16438 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016439 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016440 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
16441 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16442 .dac_nids = alc662_dac_nids,
16443 .dig_out_nid = ALC662_DIGOUT_NID,
16444 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16445 .channel_mode = alc662_3ST_6ch_modes,
16446 .input_mux = &alc663_capture_source,
16447 .unsol_event = alc663_g50v_unsol_event,
16448 .init_hook = alc663_g50v_inithook,
16449 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016450 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016451 .mixers = { alc663_m51va_mixer },
16452 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016453 .init_verbs = { alc662_init_verbs,
16454 alc663_21jd_amic_init_verbs },
16455 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16456 .hp_nid = 0x03,
16457 .dac_nids = alc662_dac_nids,
16458 .dig_out_nid = ALC662_DIGOUT_NID,
16459 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16460 .channel_mode = alc662_3ST_2ch_modes,
16461 .input_mux = &alc662_eeepc_capture_source,
16462 .unsol_event = alc663_mode1_unsol_event,
16463 .init_hook = alc663_mode1_inithook,
16464 },
16465 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016466 .mixers = { alc662_1bjd_mixer },
16467 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016468 .init_verbs = { alc662_init_verbs,
16469 alc662_1bjd_amic_init_verbs },
16470 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16471 .dac_nids = alc662_dac_nids,
16472 .dig_out_nid = ALC662_DIGOUT_NID,
16473 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16474 .channel_mode = alc662_3ST_2ch_modes,
16475 .input_mux = &alc662_eeepc_capture_source,
16476 .unsol_event = alc662_mode2_unsol_event,
16477 .init_hook = alc662_mode2_inithook,
16478 },
16479 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016480 .mixers = { alc663_two_hp_m1_mixer },
16481 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016482 .init_verbs = { alc662_init_verbs,
16483 alc663_two_hp_amic_m1_init_verbs },
16484 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16485 .hp_nid = 0x03,
16486 .dac_nids = alc662_dac_nids,
16487 .dig_out_nid = ALC662_DIGOUT_NID,
16488 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16489 .channel_mode = alc662_3ST_2ch_modes,
16490 .input_mux = &alc662_eeepc_capture_source,
16491 .unsol_event = alc663_mode3_unsol_event,
16492 .init_hook = alc663_mode3_inithook,
16493 },
16494 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016495 .mixers = { alc663_asus_21jd_clfe_mixer },
16496 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016497 .init_verbs = { alc662_init_verbs,
16498 alc663_21jd_amic_init_verbs},
16499 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16500 .hp_nid = 0x03,
16501 .dac_nids = alc662_dac_nids,
16502 .dig_out_nid = ALC662_DIGOUT_NID,
16503 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16504 .channel_mode = alc662_3ST_2ch_modes,
16505 .input_mux = &alc662_eeepc_capture_source,
16506 .unsol_event = alc663_mode4_unsol_event,
16507 .init_hook = alc663_mode4_inithook,
16508 },
16509 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016510 .mixers = { alc663_asus_15jd_clfe_mixer },
16511 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016512 .init_verbs = { alc662_init_verbs,
16513 alc663_15jd_amic_init_verbs },
16514 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16515 .hp_nid = 0x03,
16516 .dac_nids = alc662_dac_nids,
16517 .dig_out_nid = ALC662_DIGOUT_NID,
16518 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16519 .channel_mode = alc662_3ST_2ch_modes,
16520 .input_mux = &alc662_eeepc_capture_source,
16521 .unsol_event = alc663_mode5_unsol_event,
16522 .init_hook = alc663_mode5_inithook,
16523 },
16524 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016525 .mixers = { alc663_two_hp_m2_mixer },
16526 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016527 .init_verbs = { alc662_init_verbs,
16528 alc663_two_hp_amic_m2_init_verbs },
16529 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16530 .hp_nid = 0x03,
16531 .dac_nids = alc662_dac_nids,
16532 .dig_out_nid = ALC662_DIGOUT_NID,
16533 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16534 .channel_mode = alc662_3ST_2ch_modes,
16535 .input_mux = &alc662_eeepc_capture_source,
16536 .unsol_event = alc663_mode6_unsol_event,
16537 .init_hook = alc663_mode6_inithook,
16538 },
Kailang Yang622e84c2009-04-21 07:39:04 +020016539 [ALC272_DELL] = {
16540 .mixers = { alc663_m51va_mixer },
16541 .cap_mixer = alc272_auto_capture_mixer,
16542 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
16543 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
16544 .dac_nids = alc662_dac_nids,
16545 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16546 .adc_nids = alc272_adc_nids,
16547 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
16548 .capsrc_nids = alc272_capsrc_nids,
16549 .channel_mode = alc662_3ST_2ch_modes,
16550 .input_mux = &alc663_m51va_capture_source,
16551 .unsol_event = alc663_m51va_unsol_event,
16552 .init_hook = alc663_m51va_inithook,
16553 },
16554 [ALC272_DELL_ZM1] = {
16555 .mixers = { alc663_m51va_mixer },
16556 .cap_mixer = alc662_auto_capture_mixer,
16557 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
16558 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
16559 .dac_nids = alc662_dac_nids,
16560 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16561 .adc_nids = alc662_adc_nids,
16562 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
16563 .capsrc_nids = alc662_capsrc_nids,
16564 .channel_mode = alc662_3ST_2ch_modes,
16565 .input_mux = &alc663_m51va_capture_source,
16566 .unsol_event = alc663_m51va_unsol_event,
16567 .init_hook = alc663_m51va_inithook,
16568 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020016569 [ALC272_SAMSUNG_NC10] = {
16570 .mixers = { alc272_nc10_mixer },
16571 .init_verbs = { alc662_init_verbs,
16572 alc663_21jd_amic_init_verbs },
16573 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
16574 .dac_nids = alc272_dac_nids,
16575 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16576 .channel_mode = alc662_3ST_2ch_modes,
16577 .input_mux = &alc272_nc10_capture_source,
16578 .unsol_event = alc663_mode4_unsol_event,
16579 .init_hook = alc663_mode4_inithook,
16580 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016581};
16582
16583
16584/*
16585 * BIOS auto configuration
16586 */
16587
16588/* add playback controls from the parsed DAC table */
16589static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
16590 const struct auto_pin_cfg *cfg)
16591{
16592 char name[32];
16593 static const char *chname[4] = {
16594 "Front", "Surround", NULL /*CLFE*/, "Side"
16595 };
16596 hda_nid_t nid;
16597 int i, err;
16598
16599 for (i = 0; i < cfg->line_outs; i++) {
16600 if (!spec->multiout.dac_nids[i])
16601 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020016602 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016603 if (i == 2) {
16604 /* Center/LFE */
16605 err = add_control(spec, ALC_CTL_WIDGET_VOL,
16606 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016607 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
16608 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016609 if (err < 0)
16610 return err;
16611 err = add_control(spec, ALC_CTL_WIDGET_VOL,
16612 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016613 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
16614 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016615 if (err < 0)
16616 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016617 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016618 "Center Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016619 HDA_COMPOSE_AMP_VAL(0x0e, 1, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016620 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016621 if (err < 0)
16622 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016623 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016624 "LFE Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016625 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016626 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016627 if (err < 0)
16628 return err;
16629 } else {
16630 sprintf(name, "%s Playback Volume", chname[i]);
16631 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016632 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
16633 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016634 if (err < 0)
16635 return err;
16636 sprintf(name, "%s Playback Switch", chname[i]);
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016637 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16638 HDA_COMPOSE_AMP_VAL(alc880_idx_to_mixer(i),
16639 3, 0, HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016640 if (err < 0)
16641 return err;
16642 }
16643 }
16644 return 0;
16645}
16646
16647/* add playback controls for speaker and HP outputs */
16648static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
16649 const char *pfx)
16650{
16651 hda_nid_t nid;
16652 int err;
16653 char name[32];
16654
16655 if (!pin)
16656 return 0;
16657
Takashi Iwai24fb9172008-09-02 14:48:20 +020016658 if (pin == 0x17) {
16659 /* ALC663 has a mono output pin on 0x17 */
16660 sprintf(name, "%s Playback Switch", pfx);
16661 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16662 HDA_COMPOSE_AMP_VAL(pin, 2, 0, HDA_OUTPUT));
16663 return err;
16664 }
16665
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016666 if (alc880_is_fixed_pin(pin)) {
16667 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai939778a2009-02-05 15:57:55 +010016668 /* printk(KERN_DEBUG "DAC nid=%x\n",nid); */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016669 /* specify the DAC as the extra output */
16670 if (!spec->multiout.hp_nid)
16671 spec->multiout.hp_nid = nid;
16672 else
16673 spec->multiout.extra_out_nid[0] = nid;
16674 /* control HP volume/switch on the output mixer amp */
16675 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16676 sprintf(name, "%s Playback Volume", pfx);
16677 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
16678 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
16679 if (err < 0)
16680 return err;
16681 sprintf(name, "%s Playback Switch", pfx);
16682 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
16683 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
16684 if (err < 0)
16685 return err;
16686 } else if (alc880_is_multi_pin(pin)) {
16687 /* set manual connection */
16688 /* we have only a switch on HP-out PIN */
16689 sprintf(name, "%s Playback Switch", pfx);
16690 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16691 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
16692 if (err < 0)
16693 return err;
16694 }
16695 return 0;
16696}
16697
Takashi Iwai2d864c42009-03-20 12:52:47 +010016698/* return the index of the src widget from the connection list of the nid.
16699 * return -1 if not found
16700 */
16701static int alc662_input_pin_idx(struct hda_codec *codec, hda_nid_t nid,
16702 hda_nid_t src)
16703{
16704 hda_nid_t conn_list[HDA_MAX_CONNECTIONS];
16705 int i, conns;
16706
16707 conns = snd_hda_get_connections(codec, nid, conn_list,
16708 ARRAY_SIZE(conn_list));
16709 if (conns < 0)
16710 return -1;
16711 for (i = 0; i < conns; i++)
16712 if (conn_list[i] == src)
16713 return i;
16714 return -1;
16715}
16716
16717static int alc662_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
16718{
Takashi Iwai1327a322009-03-23 13:07:47 +010016719 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai2d864c42009-03-20 12:52:47 +010016720 return (pincap & AC_PINCAP_IN) != 0;
16721}
16722
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016723/* create playback/capture controls for input pins */
Takashi Iwai2d864c42009-03-20 12:52:47 +010016724static int alc662_auto_create_analog_input_ctls(struct hda_codec *codec,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016725 const struct auto_pin_cfg *cfg)
16726{
Takashi Iwai2d864c42009-03-20 12:52:47 +010016727 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016728 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016729 int i, err, idx;
16730
16731 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai2d864c42009-03-20 12:52:47 +010016732 if (alc662_is_input_pin(codec, cfg->input_pins[i])) {
16733 idx = alc662_input_pin_idx(codec, 0x0b,
16734 cfg->input_pins[i]);
16735 if (idx >= 0) {
16736 err = new_analog_input(spec, cfg->input_pins[i],
16737 auto_pin_cfg_labels[i],
16738 idx, 0x0b);
16739 if (err < 0)
16740 return err;
16741 }
16742 idx = alc662_input_pin_idx(codec, 0x22,
16743 cfg->input_pins[i]);
16744 if (idx >= 0) {
16745 imux->items[imux->num_items].label =
16746 auto_pin_cfg_labels[i];
16747 imux->items[imux->num_items].index = idx;
16748 imux->num_items++;
16749 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016750 }
16751 }
16752 return 0;
16753}
16754
16755static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
16756 hda_nid_t nid, int pin_type,
16757 int dac_idx)
16758{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016759 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016760 /* need the manual connection? */
16761 if (alc880_is_multi_pin(nid)) {
16762 struct alc_spec *spec = codec->spec;
16763 int idx = alc880_multi_pin_idx(nid);
16764 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
16765 AC_VERB_SET_CONNECT_SEL,
16766 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
16767 }
16768}
16769
16770static void alc662_auto_init_multi_out(struct hda_codec *codec)
16771{
16772 struct alc_spec *spec = codec->spec;
16773 int i;
16774
16775 for (i = 0; i <= HDA_SIDE; i++) {
16776 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016777 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016778 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016779 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016780 i);
16781 }
16782}
16783
16784static void alc662_auto_init_hp_out(struct hda_codec *codec)
16785{
16786 struct alc_spec *spec = codec->spec;
16787 hda_nid_t pin;
16788
16789 pin = spec->autocfg.hp_pins[0];
16790 if (pin) /* connect to front */
16791 /* use dac 0 */
16792 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016793 pin = spec->autocfg.speaker_pins[0];
16794 if (pin)
16795 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016796}
16797
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016798#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
16799
16800static void alc662_auto_init_analog_input(struct hda_codec *codec)
16801{
16802 struct alc_spec *spec = codec->spec;
16803 int i;
16804
16805 for (i = 0; i < AUTO_PIN_LAST; i++) {
16806 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai2d864c42009-03-20 12:52:47 +010016807 if (alc662_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010016808 alc_set_input_pin(codec, nid, i);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010016809 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010016810 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016811 snd_hda_codec_write(codec, nid, 0,
16812 AC_VERB_SET_AMP_GAIN_MUTE,
16813 AMP_OUT_MUTE);
16814 }
16815 }
16816}
16817
Takashi Iwaif511b012008-08-15 16:46:42 +020016818#define alc662_auto_init_input_src alc882_auto_init_input_src
16819
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016820static int alc662_parse_auto_config(struct hda_codec *codec)
16821{
16822 struct alc_spec *spec = codec->spec;
16823 int err;
16824 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
16825
16826 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
16827 alc662_ignore);
16828 if (err < 0)
16829 return err;
16830 if (!spec->autocfg.line_outs)
16831 return 0; /* can't find valid BIOS pin config */
16832
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016833 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
16834 if (err < 0)
16835 return err;
16836 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
16837 if (err < 0)
16838 return err;
16839 err = alc662_auto_create_extra_out(spec,
16840 spec->autocfg.speaker_pins[0],
16841 "Speaker");
16842 if (err < 0)
16843 return err;
16844 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
16845 "Headphone");
16846 if (err < 0)
16847 return err;
Takashi Iwai2d864c42009-03-20 12:52:47 +010016848 err = alc662_auto_create_analog_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016849 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016850 return err;
16851
16852 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
16853
Takashi Iwai0852d7a2009-02-11 11:35:15 +010016854 if (spec->autocfg.dig_outs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016855 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
16856
Takashi Iwai603c4012008-07-30 15:01:44 +020016857 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016858 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016859
16860 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016861 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020016862
Takashi Iwaid88897e2008-10-31 15:01:37 +010016863 add_verb(spec, alc662_auto_init_verbs);
Takashi Iwai24fb9172008-09-02 14:48:20 +020016864 if (codec->vendor_id == 0x10ec0663)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016865 add_verb(spec, alc663_auto_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020016866
16867 err = alc_auto_add_mic_boost(codec);
16868 if (err < 0)
16869 return err;
16870
Takashi Iwai4a79ba32009-04-22 16:31:35 +020016871 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
16872
Takashi Iwai8c87286f2007-06-19 12:11:16 +020016873 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016874}
16875
16876/* additional initialization for auto-configuration model */
16877static void alc662_auto_init(struct hda_codec *codec)
16878{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016879 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016880 alc662_auto_init_multi_out(codec);
16881 alc662_auto_init_hp_out(codec);
16882 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020016883 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016884 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020016885 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016886}
16887
16888static int patch_alc662(struct hda_codec *codec)
16889{
16890 struct alc_spec *spec;
16891 int err, board_config;
16892
16893 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
16894 if (!spec)
16895 return -ENOMEM;
16896
16897 codec->spec = spec;
16898
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020016899 alc_fix_pll_init(codec, 0x20, 0x04, 15);
16900
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016901 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
16902 alc662_models,
16903 alc662_cfg_tbl);
16904 if (board_config < 0) {
16905 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
16906 "trying auto-probe from BIOS...\n");
16907 board_config = ALC662_AUTO;
16908 }
16909
16910 if (board_config == ALC662_AUTO) {
16911 /* automatic parse from the BIOS config */
16912 err = alc662_parse_auto_config(codec);
16913 if (err < 0) {
16914 alc_free(codec);
16915 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020016916 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016917 printk(KERN_INFO
16918 "hda_codec: Cannot set up configuration "
16919 "from BIOS. Using base mode...\n");
16920 board_config = ALC662_3ST_2ch_DIG;
16921 }
16922 }
16923
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090016924 err = snd_hda_attach_beep_device(codec, 0x1);
16925 if (err < 0) {
16926 alc_free(codec);
16927 return err;
16928 }
16929
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016930 if (board_config != ALC662_AUTO)
16931 setup_preset(spec, &alc662_presets[board_config]);
16932
Kailang Yang6dda9f42008-05-27 12:05:31 +020016933 if (codec->vendor_id == 0x10ec0663) {
16934 spec->stream_name_analog = "ALC663 Analog";
16935 spec->stream_name_digital = "ALC663 Digital";
Kailang Yang01afd412008-10-15 11:22:09 +020016936 } else if (codec->vendor_id == 0x10ec0272) {
16937 spec->stream_name_analog = "ALC272 Analog";
16938 spec->stream_name_digital = "ALC272 Digital";
Kailang Yang6dda9f42008-05-27 12:05:31 +020016939 } else {
16940 spec->stream_name_analog = "ALC662 Analog";
16941 spec->stream_name_digital = "ALC662 Digital";
16942 }
16943
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016944 spec->stream_analog_playback = &alc662_pcm_analog_playback;
16945 spec->stream_analog_capture = &alc662_pcm_analog_capture;
16946
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016947 spec->stream_digital_playback = &alc662_pcm_digital_playback;
16948 spec->stream_digital_capture = &alc662_pcm_digital_capture;
16949
Takashi Iwaie1406342008-02-11 18:32:32 +010016950 spec->adc_nids = alc662_adc_nids;
16951 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
16952 spec->capsrc_nids = alc662_capsrc_nids;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016953 spec->capture_style = CAPT_MIX;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016954
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016955 if (!spec->cap_mixer)
16956 set_capture_mixer(spec);
Takashi Iwaib9591442009-03-16 15:25:00 +010016957 if (codec->vendor_id == 0x10ec0662)
16958 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
16959 else
16960 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016961
Takashi Iwai2134ea42008-01-10 16:53:55 +010016962 spec->vmaster_nid = 0x02;
16963
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016964 codec->patch_ops = alc_patch_ops;
16965 if (board_config == ALC662_AUTO)
16966 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020016967#ifdef CONFIG_SND_HDA_POWER_SAVE
16968 if (!spec->loopback.amplist)
16969 spec->loopback.amplist = alc662_loopbacks;
16970#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010016971 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016972
16973 return 0;
16974}
16975
16976/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070016977 * patch entries
16978 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010016979static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070016980 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010016981 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016982 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020016983 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016984 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020016985 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016986 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016987 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016988 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
16989 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
16990 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016991 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
16992 .patch = patch_alc883 },
16993 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
16994 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016995 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016996 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070016997 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016998 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Clive Messer669faba2008-09-30 15:49:13 +020016999 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
17000 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Takashi Iwaicb308f92008-04-16 14:13:29 +020017001 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai7943a8a2008-04-16 17:29:09 +020017002 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Kailang Yangdf694da2005-12-05 19:42:22 +010017003 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Kailang Yanga385a522008-10-15 11:20:21 +020017004 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc883 },
Kailang Yang44426082008-10-15 11:18:05 +020017005 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
17006 .patch = patch_alc883 },
Wu Fengguang3fea2cb2008-12-26 12:20:43 +080017007 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017008 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017009 {} /* terminator */
17010};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017011
17012MODULE_ALIAS("snd-hda-codec-id:10ec*");
17013
17014MODULE_LICENSE("GPL");
17015MODULE_DESCRIPTION("Realtek HD-audio codec");
17016
17017static struct hda_codec_preset_list realtek_list = {
17018 .preset = snd_hda_preset_realtek,
17019 .owner = THIS_MODULE,
17020};
17021
17022static int __init patch_realtek_init(void)
17023{
17024 return snd_hda_add_codec_preset(&realtek_list);
17025}
17026
17027static void __exit patch_realtek_exit(void)
17028{
17029 snd_hda_delete_codec_preset(&realtek_list);
17030}
17031
17032module_init(patch_realtek_init)
17033module_exit(patch_realtek_exit)