blob: 62f4d0ca7e1436733fc76fbfe550432ec7aaa023 [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 Iwai812a2cc2009-05-16 10:00:49 +0200280 char stream_name_analog[16]; /* 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 Iwai812a2cc2009-05-16 10:00:49 +0200286 char stream_name_digital[16]; /* 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
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003172 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
3173 "%s Analog", codec->chip_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003174 info->name = spec->stream_name_analog;
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003175
Takashi Iwai4a471b72005-12-07 13:56:29 +01003176 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003177 if (snd_BUG_ON(!spec->multiout.dac_nids))
3178 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003179 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3180 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3181 }
3182 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003183 if (snd_BUG_ON(!spec->adc_nids))
3184 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003185 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3186 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3187 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003188
Takashi Iwai4a471b72005-12-07 13:56:29 +01003189 if (spec->channel_mode) {
3190 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3191 for (i = 0; i < spec->num_channel_mode; i++) {
3192 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3193 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3194 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003195 }
3196 }
3197
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003198 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02003199 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003200 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003201 snprintf(spec->stream_name_digital,
3202 sizeof(spec->stream_name_digital),
3203 "%s Digital", codec->chip_name);
Takashi Iwaie08a0072006-09-07 17:52:14 +02003204 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08003205 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003206 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003207 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01003208 if (spec->dig_out_type)
3209 info->pcm_type = spec->dig_out_type;
3210 else
3211 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003212 if (spec->multiout.dig_out_nid &&
3213 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003214 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
3215 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3216 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01003217 if (spec->dig_in_nid &&
3218 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003219 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
3220 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3221 }
Takashi Iwai963f8032008-08-11 10:04:40 +02003222 /* FIXME: do we need this for all Realtek codec models? */
3223 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003224 }
3225
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003226 if (spec->no_analog)
3227 return 0;
3228
Takashi Iwaie08a0072006-09-07 17:52:14 +02003229 /* If the use of more than one ADC is requested for the current
3230 * model, configure a second analog capture-only PCM.
3231 */
3232 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01003233 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
3234 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003235 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003236 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003237 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01003238 if (spec->alt_dac_nid) {
3239 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3240 *spec->stream_analog_alt_playback;
3241 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3242 spec->alt_dac_nid;
3243 } else {
3244 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3245 alc_pcm_null_stream;
3246 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
3247 }
3248 if (spec->num_adc_nids > 1) {
3249 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3250 *spec->stream_analog_alt_capture;
3251 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
3252 spec->adc_nids[1];
3253 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
3254 spec->num_adc_nids - 1;
3255 } else {
3256 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3257 alc_pcm_null_stream;
3258 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003259 }
3260 }
3261
Linus Torvalds1da177e2005-04-16 15:20:36 -07003262 return 0;
3263}
3264
Takashi Iwai603c4012008-07-30 15:01:44 +02003265static void alc_free_kctls(struct hda_codec *codec)
3266{
3267 struct alc_spec *spec = codec->spec;
3268
3269 if (spec->kctls.list) {
3270 struct snd_kcontrol_new *kctl = spec->kctls.list;
3271 int i;
3272 for (i = 0; i < spec->kctls.used; i++)
3273 kfree(kctl[i].name);
3274 }
3275 snd_array_free(&spec->kctls);
3276}
3277
Linus Torvalds1da177e2005-04-16 15:20:36 -07003278static void alc_free(struct hda_codec *codec)
3279{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003280 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003281
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003282 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003283 return;
3284
Takashi Iwai603c4012008-07-30 15:01:44 +02003285 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003286 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09003287 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003288}
3289
Takashi Iwaie044c392008-10-27 16:56:24 +01003290#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01003291static int alc_resume(struct hda_codec *codec)
3292{
Takashi Iwaie044c392008-10-27 16:56:24 +01003293 codec->patch_ops.init(codec);
3294 snd_hda_codec_resume_amp(codec);
3295 snd_hda_codec_resume_cache(codec);
3296 return 0;
3297}
Takashi Iwaie044c392008-10-27 16:56:24 +01003298#endif
3299
Linus Torvalds1da177e2005-04-16 15:20:36 -07003300/*
3301 */
3302static struct hda_codec_ops alc_patch_ops = {
3303 .build_controls = alc_build_controls,
3304 .build_pcms = alc_build_pcms,
3305 .init = alc_init,
3306 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003307 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01003308#ifdef SND_HDA_NEEDS_RESUME
3309 .resume = alc_resume,
3310#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02003311#ifdef CONFIG_SND_HDA_POWER_SAVE
3312 .check_power_status = alc_check_power_status,
3313#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003314};
3315
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003316
3317/*
3318 * Test configuration for debugging
3319 *
3320 * Almost all inputs/outputs are enabled. I/O pins can be configured via
3321 * enum controls.
3322 */
3323#ifdef CONFIG_SND_DEBUG
3324static hda_nid_t alc880_test_dac_nids[4] = {
3325 0x02, 0x03, 0x04, 0x05
3326};
3327
3328static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003329 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003330 .items = {
3331 { "In-1", 0x0 },
3332 { "In-2", 0x1 },
3333 { "In-3", 0x2 },
3334 { "In-4", 0x3 },
3335 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003336 { "Front", 0x5 },
3337 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003338 },
3339};
3340
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003341static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003342 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003343 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003344 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003345 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003346};
3347
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003348static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
3349 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003350{
3351 static char *texts[] = {
3352 "N/A", "Line Out", "HP Out",
3353 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
3354 };
3355 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3356 uinfo->count = 1;
3357 uinfo->value.enumerated.items = 8;
3358 if (uinfo->value.enumerated.item >= 8)
3359 uinfo->value.enumerated.item = 7;
3360 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3361 return 0;
3362}
3363
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003364static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
3365 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003366{
3367 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3368 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3369 unsigned int pin_ctl, item = 0;
3370
3371 pin_ctl = snd_hda_codec_read(codec, nid, 0,
3372 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3373 if (pin_ctl & AC_PINCTL_OUT_EN) {
3374 if (pin_ctl & AC_PINCTL_HP_EN)
3375 item = 2;
3376 else
3377 item = 1;
3378 } else if (pin_ctl & AC_PINCTL_IN_EN) {
3379 switch (pin_ctl & AC_PINCTL_VREFEN) {
3380 case AC_PINCTL_VREF_HIZ: item = 3; break;
3381 case AC_PINCTL_VREF_50: item = 4; break;
3382 case AC_PINCTL_VREF_GRD: item = 5; break;
3383 case AC_PINCTL_VREF_80: item = 6; break;
3384 case AC_PINCTL_VREF_100: item = 7; break;
3385 }
3386 }
3387 ucontrol->value.enumerated.item[0] = item;
3388 return 0;
3389}
3390
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003391static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
3392 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003393{
3394 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3395 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3396 static unsigned int ctls[] = {
3397 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
3398 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
3399 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
3400 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
3401 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
3402 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
3403 };
3404 unsigned int old_ctl, new_ctl;
3405
3406 old_ctl = snd_hda_codec_read(codec, nid, 0,
3407 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3408 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
3409 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003410 int val;
3411 snd_hda_codec_write_cache(codec, nid, 0,
3412 AC_VERB_SET_PIN_WIDGET_CONTROL,
3413 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003414 val = ucontrol->value.enumerated.item[0] >= 3 ?
3415 HDA_AMP_MUTE : 0;
3416 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3417 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003418 return 1;
3419 }
3420 return 0;
3421}
3422
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003423static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
3424 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003425{
3426 static char *texts[] = {
3427 "Front", "Surround", "CLFE", "Side"
3428 };
3429 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3430 uinfo->count = 1;
3431 uinfo->value.enumerated.items = 4;
3432 if (uinfo->value.enumerated.item >= 4)
3433 uinfo->value.enumerated.item = 3;
3434 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3435 return 0;
3436}
3437
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003438static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
3439 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003440{
3441 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3442 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3443 unsigned int sel;
3444
3445 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
3446 ucontrol->value.enumerated.item[0] = sel & 3;
3447 return 0;
3448}
3449
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003450static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
3451 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003452{
3453 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3454 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3455 unsigned int sel;
3456
3457 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
3458 if (ucontrol->value.enumerated.item[0] != sel) {
3459 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003460 snd_hda_codec_write_cache(codec, nid, 0,
3461 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003462 return 1;
3463 }
3464 return 0;
3465}
3466
3467#define PIN_CTL_TEST(xname,nid) { \
3468 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3469 .name = xname, \
3470 .info = alc_test_pin_ctl_info, \
3471 .get = alc_test_pin_ctl_get, \
3472 .put = alc_test_pin_ctl_put, \
3473 .private_value = nid \
3474 }
3475
3476#define PIN_SRC_TEST(xname,nid) { \
3477 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3478 .name = xname, \
3479 .info = alc_test_pin_src_info, \
3480 .get = alc_test_pin_src_get, \
3481 .put = alc_test_pin_src_put, \
3482 .private_value = nid \
3483 }
3484
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003485static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003486 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3487 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3488 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
3489 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003490 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3491 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
3492 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
3493 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003494 PIN_CTL_TEST("Front Pin Mode", 0x14),
3495 PIN_CTL_TEST("Surround Pin Mode", 0x15),
3496 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
3497 PIN_CTL_TEST("Side Pin Mode", 0x17),
3498 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
3499 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
3500 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
3501 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
3502 PIN_SRC_TEST("In-1 Pin Source", 0x18),
3503 PIN_SRC_TEST("In-2 Pin Source", 0x19),
3504 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
3505 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
3506 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
3507 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
3508 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
3509 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
3510 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
3511 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
3512 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
3513 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
3514 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
3515 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003516 {
3517 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3518 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01003519 .info = alc_ch_mode_info,
3520 .get = alc_ch_mode_get,
3521 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003522 },
3523 { } /* end */
3524};
3525
3526static struct hda_verb alc880_test_init_verbs[] = {
3527 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003528 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3529 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3530 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3531 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3532 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3533 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3534 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3535 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003536 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003537 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3538 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3539 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3540 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003541 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003542 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3543 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3544 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3545 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003546 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003547 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3548 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3549 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3550 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003551 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02003552 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3553 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02003554 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3555 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3556 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003557 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02003558 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3559 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3560 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3561 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003562 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02003563 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003564 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003565 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003566 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003567 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003568 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003569 /* Analog input/passthru */
3570 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3571 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3572 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3573 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3574 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003575 { }
3576};
3577#endif
3578
Linus Torvalds1da177e2005-04-16 15:20:36 -07003579/*
3580 */
3581
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003582static const char *alc880_models[ALC880_MODEL_LAST] = {
3583 [ALC880_3ST] = "3stack",
3584 [ALC880_TCL_S700] = "tcl",
3585 [ALC880_3ST_DIG] = "3stack-digout",
3586 [ALC880_CLEVO] = "clevo",
3587 [ALC880_5ST] = "5stack",
3588 [ALC880_5ST_DIG] = "5stack-digout",
3589 [ALC880_W810] = "w810",
3590 [ALC880_Z71V] = "z71v",
3591 [ALC880_6ST] = "6stack",
3592 [ALC880_6ST_DIG] = "6stack-digout",
3593 [ALC880_ASUS] = "asus",
3594 [ALC880_ASUS_W1V] = "asus-w1v",
3595 [ALC880_ASUS_DIG] = "asus-dig",
3596 [ALC880_ASUS_DIG2] = "asus-dig2",
3597 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003598 [ALC880_UNIWILL_P53] = "uniwill-p53",
3599 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003600 [ALC880_F1734] = "F1734",
3601 [ALC880_LG] = "lg",
3602 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003603 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003604#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003605 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003606#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003607 [ALC880_AUTO] = "auto",
3608};
3609
3610static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003611 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003612 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
3613 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
3614 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
3615 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
3616 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
3617 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
3618 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
3619 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003620 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
3621 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003622 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
3623 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
3624 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
3625 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
3626 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
3627 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
3628 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
3629 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
3630 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
3631 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02003632 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003633 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
3634 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
3635 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01003636 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003637 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003638 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
3639 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003640 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
3641 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003642 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
3643 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
3644 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
3645 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003646 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
3647 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003648 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003649 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003650 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003651 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003652 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
3653 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003654 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003655 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003656 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003657 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003658 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02003659 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003660 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003661 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003662 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003663 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
3664 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003665 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003666 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
3667 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
3668 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
3669 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003670 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
3671 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003672 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003673 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003674 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
3675 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003676 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
3677 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
3678 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01003679 /* default Intel */
3680 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003681 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
3682 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003683 {}
3684};
3685
Takashi Iwai16ded522005-06-10 19:58:24 +02003686/*
Kailang Yangdf694da2005-12-05 19:42:22 +01003687 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02003688 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003689static struct alc_config_preset alc880_presets[] = {
3690 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003691 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003692 .init_verbs = { alc880_volume_init_verbs,
3693 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003694 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003695 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003696 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3697 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003698 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003699 .input_mux = &alc880_capture_source,
3700 },
3701 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003702 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003703 .init_verbs = { alc880_volume_init_verbs,
3704 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003705 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003706 .dac_nids = alc880_dac_nids,
3707 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003708 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3709 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003710 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003711 .input_mux = &alc880_capture_source,
3712 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003713 [ALC880_TCL_S700] = {
3714 .mixers = { alc880_tcl_s700_mixer },
3715 .init_verbs = { alc880_volume_init_verbs,
3716 alc880_pin_tcl_S700_init_verbs,
3717 alc880_gpio2_init_verbs },
3718 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3719 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01003720 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
3721 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01003722 .hp_nid = 0x03,
3723 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3724 .channel_mode = alc880_2_jack_modes,
3725 .input_mux = &alc880_capture_source,
3726 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003727 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003728 .mixers = { alc880_three_stack_mixer,
3729 alc880_five_stack_mixer},
3730 .init_verbs = { alc880_volume_init_verbs,
3731 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003732 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3733 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003734 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3735 .channel_mode = alc880_fivestack_modes,
3736 .input_mux = &alc880_capture_source,
3737 },
3738 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003739 .mixers = { alc880_three_stack_mixer,
3740 alc880_five_stack_mixer },
3741 .init_verbs = { alc880_volume_init_verbs,
3742 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003743 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3744 .dac_nids = alc880_dac_nids,
3745 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003746 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3747 .channel_mode = alc880_fivestack_modes,
3748 .input_mux = &alc880_capture_source,
3749 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003750 [ALC880_6ST] = {
3751 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003752 .init_verbs = { alc880_volume_init_verbs,
3753 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003754 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3755 .dac_nids = alc880_6st_dac_nids,
3756 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3757 .channel_mode = alc880_sixstack_modes,
3758 .input_mux = &alc880_6stack_capture_source,
3759 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003760 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003761 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003762 .init_verbs = { alc880_volume_init_verbs,
3763 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003764 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3765 .dac_nids = alc880_6st_dac_nids,
3766 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003767 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3768 .channel_mode = alc880_sixstack_modes,
3769 .input_mux = &alc880_6stack_capture_source,
3770 },
3771 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003772 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003773 .init_verbs = { alc880_volume_init_verbs,
3774 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003775 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003776 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
3777 .dac_nids = alc880_w810_dac_nids,
3778 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003779 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3780 .channel_mode = alc880_w810_modes,
3781 .input_mux = &alc880_capture_source,
3782 },
3783 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003784 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003785 .init_verbs = { alc880_volume_init_verbs,
3786 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003787 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
3788 .dac_nids = alc880_z71v_dac_nids,
3789 .dig_out_nid = ALC880_DIGOUT_NID,
3790 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003791 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3792 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02003793 .input_mux = &alc880_capture_source,
3794 },
3795 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003796 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003797 .init_verbs = { alc880_volume_init_verbs,
3798 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003799 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
3800 .dac_nids = alc880_f1734_dac_nids,
3801 .hp_nid = 0x02,
3802 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3803 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01003804 .input_mux = &alc880_f1734_capture_source,
3805 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003806 .init_hook = alc880_uniwill_p53_init_hook,
Takashi Iwai16ded522005-06-10 19:58:24 +02003807 },
3808 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003809 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003810 .init_verbs = { alc880_volume_init_verbs,
3811 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003812 alc880_gpio1_init_verbs },
3813 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3814 .dac_nids = alc880_asus_dac_nids,
3815 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3816 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003817 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003818 .input_mux = &alc880_capture_source,
3819 },
3820 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003821 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003822 .init_verbs = { alc880_volume_init_verbs,
3823 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003824 alc880_gpio1_init_verbs },
3825 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3826 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003827 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003828 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3829 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003830 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003831 .input_mux = &alc880_capture_source,
3832 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003833 [ALC880_ASUS_DIG2] = {
3834 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003835 .init_verbs = { alc880_volume_init_verbs,
3836 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01003837 alc880_gpio2_init_verbs }, /* use GPIO2 */
3838 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3839 .dac_nids = alc880_asus_dac_nids,
3840 .dig_out_nid = ALC880_DIGOUT_NID,
3841 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3842 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003843 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003844 .input_mux = &alc880_capture_source,
3845 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003846 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003847 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003848 .init_verbs = { alc880_volume_init_verbs,
3849 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003850 alc880_gpio1_init_verbs },
3851 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3852 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003853 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003854 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3855 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003856 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003857 .input_mux = &alc880_capture_source,
3858 },
3859 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01003860 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02003861 .init_verbs = { alc880_volume_init_verbs,
3862 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003863 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3864 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003865 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003866 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3867 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003868 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003869 .input_mux = &alc880_capture_source,
3870 },
Kailang Yangccc656c2006-10-17 12:32:26 +02003871 [ALC880_UNIWILL] = {
3872 .mixers = { alc880_uniwill_mixer },
3873 .init_verbs = { alc880_volume_init_verbs,
3874 alc880_uniwill_init_verbs },
3875 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3876 .dac_nids = alc880_asus_dac_nids,
3877 .dig_out_nid = ALC880_DIGOUT_NID,
3878 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3879 .channel_mode = alc880_threestack_modes,
3880 .need_dac_fix = 1,
3881 .input_mux = &alc880_capture_source,
3882 .unsol_event = alc880_uniwill_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003883 .init_hook = alc880_uniwill_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02003884 },
3885 [ALC880_UNIWILL_P53] = {
3886 .mixers = { alc880_uniwill_p53_mixer },
3887 .init_verbs = { alc880_volume_init_verbs,
3888 alc880_uniwill_p53_init_verbs },
3889 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3890 .dac_nids = alc880_asus_dac_nids,
3891 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003892 .channel_mode = alc880_threestack_modes,
3893 .input_mux = &alc880_capture_source,
3894 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003895 .init_hook = alc880_uniwill_p53_init_hook,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003896 },
3897 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01003898 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003899 .init_verbs = { alc880_volume_init_verbs,
3900 alc880_uniwill_p53_init_verbs,
3901 alc880_beep_init_verbs },
3902 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3903 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02003904 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003905 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3906 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02003907 .input_mux = &alc880_capture_source,
3908 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003909 .init_hook = alc880_uniwill_p53_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02003910 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003911 [ALC880_CLEVO] = {
3912 .mixers = { alc880_three_stack_mixer },
3913 .init_verbs = { alc880_volume_init_verbs,
3914 alc880_pin_clevo_init_verbs },
3915 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3916 .dac_nids = alc880_dac_nids,
3917 .hp_nid = 0x03,
3918 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3919 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003920 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003921 .input_mux = &alc880_capture_source,
3922 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003923 [ALC880_LG] = {
3924 .mixers = { alc880_lg_mixer },
3925 .init_verbs = { alc880_volume_init_verbs,
3926 alc880_lg_init_verbs },
3927 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
3928 .dac_nids = alc880_lg_dac_nids,
3929 .dig_out_nid = ALC880_DIGOUT_NID,
3930 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
3931 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003932 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003933 .input_mux = &alc880_lg_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003934 .unsol_event = alc_automute_amp_unsol_event,
3935 .init_hook = alc880_lg_init_hook,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003936#ifdef CONFIG_SND_HDA_POWER_SAVE
3937 .loopbacks = alc880_lg_loopbacks,
3938#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003939 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003940 [ALC880_LG_LW] = {
3941 .mixers = { alc880_lg_lw_mixer },
3942 .init_verbs = { alc880_volume_init_verbs,
3943 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003944 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01003945 .dac_nids = alc880_dac_nids,
3946 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003947 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
3948 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01003949 .input_mux = &alc880_lg_lw_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003950 .unsol_event = alc_automute_amp_unsol_event,
3951 .init_hook = alc880_lg_lw_init_hook,
Takashi Iwaid6815182006-03-23 16:06:23 +01003952 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003953 [ALC880_MEDION_RIM] = {
3954 .mixers = { alc880_medion_rim_mixer },
3955 .init_verbs = { alc880_volume_init_verbs,
3956 alc880_medion_rim_init_verbs,
3957 alc_gpio2_init_verbs },
3958 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3959 .dac_nids = alc880_dac_nids,
3960 .dig_out_nid = ALC880_DIGOUT_NID,
3961 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3962 .channel_mode = alc880_2_jack_modes,
3963 .input_mux = &alc880_medion_rim_capture_source,
3964 .unsol_event = alc880_medion_rim_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003965 .init_hook = alc880_medion_rim_init_hook,
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003966 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003967#ifdef CONFIG_SND_DEBUG
3968 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003969 .mixers = { alc880_test_mixer },
3970 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003971 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
3972 .dac_nids = alc880_test_dac_nids,
3973 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003974 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
3975 .channel_mode = alc880_test_modes,
3976 .input_mux = &alc880_test_capture_source,
3977 },
3978#endif
3979};
3980
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003981/*
3982 * Automatic parse of I/O pins from the BIOS configuration
3983 */
3984
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003985enum {
3986 ALC_CTL_WIDGET_VOL,
3987 ALC_CTL_WIDGET_MUTE,
3988 ALC_CTL_BIND_MUTE,
3989};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003990static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003991 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
3992 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01003993 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003994};
3995
3996/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003997static int add_control(struct alc_spec *spec, int type, const char *name,
3998 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003999{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004000 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004001
Takashi Iwai603c4012008-07-30 15:01:44 +02004002 snd_array_init(&spec->kctls, sizeof(*knew), 32);
4003 knew = snd_array_new(&spec->kctls);
4004 if (!knew)
4005 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004006 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07004007 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004008 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004009 return -ENOMEM;
4010 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004011 return 0;
4012}
4013
4014#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
4015#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
4016#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
4017#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
4018#define alc880_is_input_pin(nid) ((nid) >= 0x18)
4019#define alc880_input_pin_idx(nid) ((nid) - 0x18)
4020#define alc880_idx_to_dac(nid) ((nid) + 0x02)
4021#define alc880_dac_to_idx(nid) ((nid) - 0x02)
4022#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
4023#define alc880_idx_to_selector(nid) ((nid) + 0x10)
4024#define ALC880_PIN_CD_NID 0x1c
4025
4026/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004027static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
4028 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004029{
4030 hda_nid_t nid;
4031 int assigned[4];
4032 int i, j;
4033
4034 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004035 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004036
4037 /* check the pins hardwired to audio widget */
4038 for (i = 0; i < cfg->line_outs; i++) {
4039 nid = cfg->line_out_pins[i];
4040 if (alc880_is_fixed_pin(nid)) {
4041 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01004042 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004043 assigned[idx] = 1;
4044 }
4045 }
4046 /* left pins can be connect to any audio widget */
4047 for (i = 0; i < cfg->line_outs; i++) {
4048 nid = cfg->line_out_pins[i];
4049 if (alc880_is_fixed_pin(nid))
4050 continue;
4051 /* search for an empty channel */
4052 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004053 if (!assigned[j]) {
4054 spec->multiout.dac_nids[i] =
4055 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004056 assigned[j] = 1;
4057 break;
4058 }
4059 }
4060 }
4061 spec->multiout.num_dacs = cfg->line_outs;
4062 return 0;
4063}
4064
4065/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01004066static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
4067 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004068{
4069 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004070 static const char *chname[4] = {
4071 "Front", "Surround", NULL /*CLFE*/, "Side"
4072 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004073 hda_nid_t nid;
4074 int i, err;
4075
4076 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004077 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004078 continue;
4079 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4080 if (i == 2) {
4081 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004082 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4083 "Center Playback Volume",
4084 HDA_COMPOSE_AMP_VAL(nid, 1, 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_WIDGET_VOL,
4089 "LFE Playback Volume",
4090 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
4091 HDA_OUTPUT));
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 "Center Playback Switch",
4096 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
4097 HDA_INPUT));
4098 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004099 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004100 err = add_control(spec, ALC_CTL_BIND_MUTE,
4101 "LFE Playback Switch",
4102 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
4103 HDA_INPUT));
4104 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004105 return err;
4106 } else {
4107 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004108 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4109 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4110 HDA_OUTPUT));
4111 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004112 return err;
4113 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004114 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4115 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4116 HDA_INPUT));
4117 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004118 return err;
4119 }
4120 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004121 return 0;
4122}
4123
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004124/* add playback controls for speaker and HP outputs */
4125static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
4126 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004127{
4128 hda_nid_t nid;
4129 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004130 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004131
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004132 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004133 return 0;
4134
4135 if (alc880_is_fixed_pin(pin)) {
4136 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01004137 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004138 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004139 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004140 else
4141 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004142 /* control HP volume/switch on the output mixer amp */
4143 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004144 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004145 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4146 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
4147 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004148 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004149 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004150 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4151 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
4152 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004153 return err;
4154 } else if (alc880_is_multi_pin(pin)) {
4155 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004156 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004157 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004158 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4159 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
4160 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004161 return err;
4162 }
4163 return 0;
4164}
4165
4166/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004167static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4168 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01004169 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004170{
4171 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01004172 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004173
4174 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004175 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4176 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4177 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004178 return err;
4179 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004180 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4181 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4182 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004183 return err;
4184 return 0;
4185}
4186
4187/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01004188static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
4189 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004190{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004191 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004192 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004193
4194 for (i = 0; i < AUTO_PIN_LAST; i++) {
4195 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01004196 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01004197 err = new_analog_input(spec, cfg->input_pins[i],
4198 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01004199 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004200 if (err < 0)
4201 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004202 imux->items[imux->num_items].label =
4203 auto_pin_cfg_labels[i];
4204 imux->items[imux->num_items].index =
4205 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004206 imux->num_items++;
4207 }
4208 }
4209 return 0;
4210}
4211
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004212static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
4213 unsigned int pin_type)
4214{
4215 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4216 pin_type);
4217 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01004218 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4219 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004220}
4221
Kailang Yangdf694da2005-12-05 19:42:22 +01004222static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
4223 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004224 int dac_idx)
4225{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004226 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004227 /* need the manual connection? */
4228 if (alc880_is_multi_pin(nid)) {
4229 struct alc_spec *spec = codec->spec;
4230 int idx = alc880_multi_pin_idx(nid);
4231 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
4232 AC_VERB_SET_CONNECT_SEL,
4233 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
4234 }
4235}
4236
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004237static int get_pin_type(int line_out_type)
4238{
4239 if (line_out_type == AUTO_PIN_HP_OUT)
4240 return PIN_HP;
4241 else
4242 return PIN_OUT;
4243}
4244
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004245static void alc880_auto_init_multi_out(struct hda_codec *codec)
4246{
4247 struct alc_spec *spec = codec->spec;
4248 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02004249
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004250 for (i = 0; i < spec->autocfg.line_outs; i++) {
4251 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004252 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4253 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004254 }
4255}
4256
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004257static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004258{
4259 struct alc_spec *spec = codec->spec;
4260 hda_nid_t pin;
4261
Takashi Iwai82bc9552006-03-21 11:24:42 +01004262 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004263 if (pin) /* connect to front */
4264 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004265 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004266 if (pin) /* connect to front */
4267 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
4268}
4269
4270static void alc880_auto_init_analog_input(struct hda_codec *codec)
4271{
4272 struct alc_spec *spec = codec->spec;
4273 int i;
4274
4275 for (i = 0; i < AUTO_PIN_LAST; i++) {
4276 hda_nid_t nid = spec->autocfg.input_pins[i];
4277 if (alc880_is_input_pin(nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01004278 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01004279 if (nid != ALC880_PIN_CD_NID &&
4280 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004281 snd_hda_codec_write(codec, nid, 0,
4282 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004283 AMP_OUT_MUTE);
4284 }
4285 }
4286}
4287
4288/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004289/* return 1 if successful, 0 if the proper config is not found,
4290 * or a negative error code
4291 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004292static int alc880_parse_auto_config(struct hda_codec *codec)
4293{
4294 struct alc_spec *spec = codec->spec;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004295 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +01004296 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004297
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004298 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4299 alc880_ignore);
4300 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004301 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004302 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004303 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01004304
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004305 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
4306 if (err < 0)
4307 return err;
4308 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
4309 if (err < 0)
4310 return err;
4311 err = alc880_auto_create_extra_out(spec,
4312 spec->autocfg.speaker_pins[0],
4313 "Speaker");
4314 if (err < 0)
4315 return err;
4316 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
4317 "Headphone");
4318 if (err < 0)
4319 return err;
4320 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
4321 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004322 return err;
4323
4324 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4325
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004326 /* check multiple SPDIF-out (for recent codecs) */
4327 for (i = 0; i < spec->autocfg.dig_outs; i++) {
4328 hda_nid_t dig_nid;
4329 err = snd_hda_get_connections(codec,
4330 spec->autocfg.dig_out_pins[i],
4331 &dig_nid, 1);
4332 if (err < 0)
4333 continue;
4334 if (!i)
4335 spec->multiout.dig_out_nid = dig_nid;
4336 else {
4337 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
4338 spec->slave_dig_outs[i - 1] = dig_nid;
4339 if (i == ARRAY_SIZE(spec->slave_dig_outs) - 1)
4340 break;
4341 }
4342 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004343 if (spec->autocfg.dig_in_pin)
4344 spec->dig_in_nid = ALC880_DIGIN_NID;
4345
Takashi Iwai603c4012008-07-30 15:01:44 +02004346 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01004347 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004348
Takashi Iwaid88897e2008-10-31 15:01:37 +01004349 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004350
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004351 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004352 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004353
Takashi Iwai4a79ba32009-04-22 16:31:35 +02004354 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
4355
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004356 return 1;
4357}
4358
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004359/* additional initialization for auto-configuration model */
4360static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004361{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004362 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004363 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004364 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004365 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004366 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02004367 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004368}
4369
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004370static void set_capture_mixer(struct alc_spec *spec)
4371{
Takashi Iwaia23b6882009-03-23 15:21:36 +01004372 static struct snd_kcontrol_new *caps[2][3] = {
4373 { alc_capture_mixer_nosrc1,
4374 alc_capture_mixer_nosrc2,
4375 alc_capture_mixer_nosrc3 },
4376 { alc_capture_mixer1,
4377 alc_capture_mixer2,
4378 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004379 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01004380 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
4381 int mux;
4382 if (spec->input_mux && spec->input_mux->num_items > 1)
4383 mux = 1;
4384 else
4385 mux = 0;
4386 spec->cap_mixer = caps[mux][spec->num_adc_nids - 1];
4387 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004388}
4389
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004390#define set_beep_amp(spec, nid, idx, dir) \
4391 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
4392
4393/*
4394 * OK, here we have finally the patch for ALC880
4395 */
4396
Linus Torvalds1da177e2005-04-16 15:20:36 -07004397static int patch_alc880(struct hda_codec *codec)
4398{
4399 struct alc_spec *spec;
4400 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01004401 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004402
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004403 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004404 if (spec == NULL)
4405 return -ENOMEM;
4406
4407 codec->spec = spec;
4408
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004409 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
4410 alc880_models,
4411 alc880_cfg_tbl);
4412 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +02004413 printk(KERN_INFO "hda_codec: Unknown model for %s, "
4414 "trying auto-probe from BIOS...\n", codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004415 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004416 }
4417
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004418 if (board_config == ALC880_AUTO) {
4419 /* automatic parse from the BIOS config */
4420 err = alc880_parse_auto_config(codec);
4421 if (err < 0) {
4422 alc_free(codec);
4423 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004424 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004425 printk(KERN_INFO
4426 "hda_codec: Cannot set up configuration "
4427 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004428 board_config = ALC880_3ST;
4429 }
4430 }
4431
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09004432 err = snd_hda_attach_beep_device(codec, 0x1);
4433 if (err < 0) {
4434 alc_free(codec);
4435 return err;
4436 }
4437
Kailang Yangdf694da2005-12-05 19:42:22 +01004438 if (board_config != ALC880_AUTO)
4439 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004440
Linus Torvalds1da177e2005-04-16 15:20:36 -07004441 spec->stream_analog_playback = &alc880_pcm_analog_playback;
4442 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01004443 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004444
Linus Torvalds1da177e2005-04-16 15:20:36 -07004445 spec->stream_digital_playback = &alc880_pcm_digital_playback;
4446 spec->stream_digital_capture = &alc880_pcm_digital_capture;
4447
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004448 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004449 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01004450 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004451 /* get type */
4452 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004453 if (wcap != AC_WID_AUD_IN) {
4454 spec->adc_nids = alc880_adc_nids_alt;
4455 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004456 } else {
4457 spec->adc_nids = alc880_adc_nids;
4458 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004459 }
4460 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004461 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004462 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004463
Takashi Iwai2134ea42008-01-10 16:53:55 +01004464 spec->vmaster_nid = 0x0c;
4465
Linus Torvalds1da177e2005-04-16 15:20:36 -07004466 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004467 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004468 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02004469#ifdef CONFIG_SND_HDA_POWER_SAVE
4470 if (!spec->loopback.amplist)
4471 spec->loopback.amplist = alc880_loopbacks;
4472#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01004473 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004474
4475 return 0;
4476}
4477
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004478
Linus Torvalds1da177e2005-04-16 15:20:36 -07004479/*
4480 * ALC260 support
4481 */
4482
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004483static hda_nid_t alc260_dac_nids[1] = {
4484 /* front */
4485 0x02,
4486};
4487
4488static hda_nid_t alc260_adc_nids[1] = {
4489 /* ADC0 */
4490 0x04,
4491};
4492
Kailang Yangdf694da2005-12-05 19:42:22 +01004493static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004494 /* ADC1 */
4495 0x05,
4496};
4497
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004498/* NIDs used when simultaneous access to both ADCs makes sense. Note that
4499 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
4500 */
4501static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004502 /* ADC0, ADC1 */
4503 0x04, 0x05
4504};
4505
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004506#define ALC260_DIGOUT_NID 0x03
4507#define ALC260_DIGIN_NID 0x06
4508
4509static struct hda_input_mux alc260_capture_source = {
4510 .num_items = 4,
4511 .items = {
4512 { "Mic", 0x0 },
4513 { "Front Mic", 0x1 },
4514 { "Line", 0x2 },
4515 { "CD", 0x4 },
4516 },
4517};
4518
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004519/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004520 * headphone jack and the internal CD lines since these are the only pins at
4521 * which audio can appear. For flexibility, also allow the option of
4522 * recording the mixer output on the second ADC (ADC0 doesn't have a
4523 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004524 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004525static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
4526 {
4527 .num_items = 3,
4528 .items = {
4529 { "Mic/Line", 0x0 },
4530 { "CD", 0x4 },
4531 { "Headphone", 0x2 },
4532 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004533 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004534 {
4535 .num_items = 4,
4536 .items = {
4537 { "Mic/Line", 0x0 },
4538 { "CD", 0x4 },
4539 { "Headphone", 0x2 },
4540 { "Mixer", 0x5 },
4541 },
4542 },
4543
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004544};
4545
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004546/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
4547 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004548 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004549static struct hda_input_mux alc260_acer_capture_sources[2] = {
4550 {
4551 .num_items = 4,
4552 .items = {
4553 { "Mic", 0x0 },
4554 { "Line", 0x2 },
4555 { "CD", 0x4 },
4556 { "Headphone", 0x5 },
4557 },
4558 },
4559 {
4560 .num_items = 5,
4561 .items = {
4562 { "Mic", 0x0 },
4563 { "Line", 0x2 },
4564 { "CD", 0x4 },
4565 { "Headphone", 0x6 },
4566 { "Mixer", 0x5 },
4567 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004568 },
4569};
Michael Schwingencc959482009-02-22 18:58:45 +01004570
4571/* Maxdata Favorit 100XS */
4572static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
4573 {
4574 .num_items = 2,
4575 .items = {
4576 { "Line/Mic", 0x0 },
4577 { "CD", 0x4 },
4578 },
4579 },
4580 {
4581 .num_items = 3,
4582 .items = {
4583 { "Line/Mic", 0x0 },
4584 { "CD", 0x4 },
4585 { "Mixer", 0x5 },
4586 },
4587 },
4588};
4589
Linus Torvalds1da177e2005-04-16 15:20:36 -07004590/*
4591 * This is just place-holder, so there's something for alc_build_pcms to look
4592 * at when it calculates the maximum number of channels. ALC260 has no mixer
4593 * element which allows changing the channel mode, so the verb list is
4594 * never used.
4595 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004596static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004597 { 2, NULL },
4598};
4599
Kailang Yangdf694da2005-12-05 19:42:22 +01004600
4601/* Mixer combinations
4602 *
4603 * basic: base_output + input + pc_beep + capture
4604 * HP: base_output + input + capture_alt
4605 * HP_3013: hp_3013 + input + capture
4606 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004607 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01004608 */
4609
4610static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004611 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004612 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004613 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4614 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4615 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4616 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4617 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004618};
Kailang Yangdf694da2005-12-05 19:42:22 +01004619
4620static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004621 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4622 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4623 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4624 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4625 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4626 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4627 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
4628 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004629 { } /* end */
4630};
4631
Takashi Iwaibec15c32008-01-28 18:16:30 +01004632/* update HP, line and mono out pins according to the master switch */
4633static void alc260_hp_master_update(struct hda_codec *codec,
4634 hda_nid_t hp, hda_nid_t line,
4635 hda_nid_t mono)
4636{
4637 struct alc_spec *spec = codec->spec;
4638 unsigned int val = spec->master_sw ? PIN_HP : 0;
4639 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004640 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004641 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004642 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004643 val);
4644 /* mono (speaker) depending on the HP jack sense */
4645 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004646 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004647 val);
4648}
4649
4650static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
4651 struct snd_ctl_elem_value *ucontrol)
4652{
4653 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4654 struct alc_spec *spec = codec->spec;
4655 *ucontrol->value.integer.value = spec->master_sw;
4656 return 0;
4657}
4658
4659static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
4660 struct snd_ctl_elem_value *ucontrol)
4661{
4662 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4663 struct alc_spec *spec = codec->spec;
4664 int val = !!*ucontrol->value.integer.value;
4665 hda_nid_t hp, line, mono;
4666
4667 if (val == spec->master_sw)
4668 return 0;
4669 spec->master_sw = val;
4670 hp = (kcontrol->private_value >> 16) & 0xff;
4671 line = (kcontrol->private_value >> 8) & 0xff;
4672 mono = kcontrol->private_value & 0xff;
4673 alc260_hp_master_update(codec, hp, line, mono);
4674 return 1;
4675}
4676
4677static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
4678 {
4679 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4680 .name = "Master Playback Switch",
4681 .info = snd_ctl_boolean_mono_info,
4682 .get = alc260_hp_master_sw_get,
4683 .put = alc260_hp_master_sw_put,
4684 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
4685 },
4686 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4687 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
4688 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4689 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4690 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
4691 HDA_OUTPUT),
4692 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4693 { } /* end */
4694};
4695
4696static struct hda_verb alc260_hp_unsol_verbs[] = {
4697 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4698 {},
4699};
4700
4701static void alc260_hp_automute(struct hda_codec *codec)
4702{
4703 struct alc_spec *spec = codec->spec;
4704 unsigned int present;
4705
4706 present = snd_hda_codec_read(codec, 0x10, 0,
4707 AC_VERB_GET_PIN_SENSE, 0);
4708 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4709 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
4710}
4711
4712static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
4713{
4714 if ((res >> 26) == ALC880_HP_EVENT)
4715 alc260_hp_automute(codec);
4716}
4717
Kailang Yangdf694da2005-12-05 19:42:22 +01004718static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01004719 {
4720 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4721 .name = "Master Playback Switch",
4722 .info = snd_ctl_boolean_mono_info,
4723 .get = alc260_hp_master_sw_get,
4724 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004725 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01004726 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004727 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4728 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4729 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
4730 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
4731 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4732 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01004733 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4734 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02004735 { } /* end */
4736};
4737
Kailang Yang3f878302008-08-26 13:02:23 +02004738static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
4739 .ops = &snd_hda_bind_vol,
4740 .values = {
4741 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
4742 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
4743 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
4744 0
4745 },
4746};
4747
4748static struct hda_bind_ctls alc260_dc7600_bind_switch = {
4749 .ops = &snd_hda_bind_sw,
4750 .values = {
4751 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
4752 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
4753 0
4754 },
4755};
4756
4757static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
4758 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
4759 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
4760 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
4761 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4762 { } /* end */
4763};
4764
Takashi Iwaibec15c32008-01-28 18:16:30 +01004765static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
4766 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4767 {},
4768};
4769
4770static void alc260_hp_3013_automute(struct hda_codec *codec)
4771{
4772 struct alc_spec *spec = codec->spec;
4773 unsigned int present;
4774
4775 present = snd_hda_codec_read(codec, 0x15, 0,
4776 AC_VERB_GET_PIN_SENSE, 0);
4777 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004778 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01004779}
4780
4781static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
4782 unsigned int res)
4783{
4784 if ((res >> 26) == ALC880_HP_EVENT)
4785 alc260_hp_3013_automute(codec);
4786}
4787
Kailang Yang3f878302008-08-26 13:02:23 +02004788static void alc260_hp_3012_automute(struct hda_codec *codec)
4789{
4790 unsigned int present, bits;
4791
4792 present = snd_hda_codec_read(codec, 0x10, 0,
4793 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
4794
4795 bits = present ? 0 : PIN_OUT;
4796 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4797 bits);
4798 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4799 bits);
4800 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4801 bits);
4802}
4803
4804static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
4805 unsigned int res)
4806{
4807 if ((res >> 26) == ALC880_HP_EVENT)
4808 alc260_hp_3012_automute(codec);
4809}
4810
4811/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004812 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
4813 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004814static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004815 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004816 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004817 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004818 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4819 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4820 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
4821 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004822 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004823 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4824 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004825 { } /* end */
4826};
4827
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004828/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
4829 * versions of the ALC260 don't act on requests to enable mic bias from NID
4830 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
4831 * datasheet doesn't mention this restriction. At this stage it's not clear
4832 * whether this behaviour is intentional or is a hardware bug in chip
4833 * revisions available in early 2006. Therefore for now allow the
4834 * "Headphone Jack Mode" control to span all choices, but if it turns out
4835 * that the lack of mic bias for this NID is intentional we could change the
4836 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4837 *
4838 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
4839 * don't appear to make the mic bias available from the "line" jack, even
4840 * though the NID used for this jack (0x14) can supply it. The theory is
4841 * that perhaps Acer have included blocking capacitors between the ALC260
4842 * and the output jack. If this turns out to be the case for all such
4843 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
4844 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01004845 *
4846 * The C20x Tablet series have a mono internal speaker which is controlled
4847 * via the chip's Mono sum widget and pin complex, so include the necessary
4848 * controls for such models. On models without a "mono speaker" the control
4849 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004850 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004851static struct snd_kcontrol_new alc260_acer_mixer[] = {
4852 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4853 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004854 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004855 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01004856 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004857 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01004858 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004859 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4860 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4861 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4862 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4863 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4864 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4865 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4866 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004867 { } /* end */
4868};
4869
Michael Schwingencc959482009-02-22 18:58:45 +01004870/* Maxdata Favorit 100XS: one output and one input (0x12) jack
4871 */
4872static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
4873 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4874 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
4875 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
4876 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4877 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4878 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4879 { } /* end */
4880};
4881
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004882/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
4883 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
4884 */
4885static struct snd_kcontrol_new alc260_will_mixer[] = {
4886 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4887 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4888 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4889 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4890 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4891 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4892 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4893 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4894 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4895 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004896 { } /* end */
4897};
4898
4899/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
4900 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
4901 */
4902static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
4903 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4904 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4905 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4906 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4907 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4908 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
4909 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
4910 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4911 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4912 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4913 { } /* end */
4914};
4915
Kailang Yangdf694da2005-12-05 19:42:22 +01004916/*
4917 * initialization verbs
4918 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004919static struct hda_verb alc260_init_verbs[] = {
4920 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004921 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004922 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004923 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004924 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004925 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004926 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004927 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004928 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02004929 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004930 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01004931 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004932 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02004933 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004934 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02004935 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004936 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02004937 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4938 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02004939 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004940 /* set connection select to line in (default select for this ADC) */
4941 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02004942 /* mute capture amp left and right */
4943 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4944 /* set connection select to line in (default select for this ADC) */
4945 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02004946 /* set vol=0 Line-Out mixer amp left and right */
4947 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4948 /* unmute pin widget amp left and right (no gain on this amp) */
4949 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4950 /* set vol=0 HP mixer amp left and right */
4951 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4952 /* unmute pin widget amp left and right (no gain on this amp) */
4953 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4954 /* set vol=0 Mono mixer amp left and right */
4955 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4956 /* unmute pin widget amp left and right (no gain on this amp) */
4957 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4958 /* unmute LINE-2 out pin */
4959 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004960 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4961 * Line In 2 = 0x03
4962 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004963 /* mute analog inputs */
4964 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4965 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4966 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4967 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4968 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004969 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004970 /* mute Front out path */
4971 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4972 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4973 /* mute Headphone out path */
4974 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4975 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4976 /* mute Mono out path */
4977 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4978 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004979 { }
4980};
4981
Takashi Iwai474167d2006-05-17 17:17:43 +02004982#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01004983static struct hda_verb alc260_hp_init_verbs[] = {
4984 /* Headphone and output */
4985 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4986 /* mono output */
4987 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4988 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4989 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4990 /* Mic2 (front panel) pin widget for input and vref at 80% */
4991 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4992 /* Line In pin widget for input */
4993 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4994 /* Line-2 pin widget for output */
4995 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4996 /* CD pin widget for input */
4997 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4998 /* unmute amp left and right */
4999 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5000 /* set connection select to line in (default select for this ADC) */
5001 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5002 /* unmute Line-Out mixer amp left and right (volume = 0) */
5003 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5004 /* mute pin widget amp left and right (no gain on this amp) */
5005 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5006 /* unmute HP mixer amp left and right (volume = 0) */
5007 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5008 /* mute pin widget amp left and right (no gain on this amp) */
5009 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005010 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5011 * Line In 2 = 0x03
5012 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005013 /* mute analog inputs */
5014 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5015 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5016 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5017 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5018 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005019 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5020 /* Unmute Front out path */
5021 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5022 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5023 /* Unmute Headphone out path */
5024 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5025 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5026 /* Unmute Mono out path */
5027 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5028 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5029 { }
5030};
Takashi Iwai474167d2006-05-17 17:17:43 +02005031#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005032
5033static struct hda_verb alc260_hp_3013_init_verbs[] = {
5034 /* Line out and output */
5035 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5036 /* mono output */
5037 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5038 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5039 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5040 /* Mic2 (front panel) pin widget for input and vref at 80% */
5041 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5042 /* Line In pin widget for input */
5043 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5044 /* Headphone pin widget for output */
5045 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5046 /* CD pin widget for input */
5047 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5048 /* unmute amp left and right */
5049 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5050 /* set connection select to line in (default select for this ADC) */
5051 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5052 /* unmute Line-Out mixer amp left and right (volume = 0) */
5053 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5054 /* mute pin widget amp left and right (no gain on this amp) */
5055 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5056 /* unmute HP mixer amp left and right (volume = 0) */
5057 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5058 /* mute pin widget amp left and right (no gain on this amp) */
5059 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005060 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5061 * Line In 2 = 0x03
5062 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005063 /* mute analog inputs */
5064 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5065 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5066 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5067 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5068 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005069 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5070 /* Unmute Front out path */
5071 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5072 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5073 /* Unmute Headphone out path */
5074 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5075 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5076 /* Unmute Mono out path */
5077 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5078 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5079 { }
5080};
5081
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005082/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005083 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
5084 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005085 */
5086static struct hda_verb alc260_fujitsu_init_verbs[] = {
5087 /* Disable all GPIOs */
5088 {0x01, AC_VERB_SET_GPIO_MASK, 0},
5089 /* Internal speaker is connected to headphone pin */
5090 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5091 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
5092 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005093 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
5094 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5095 /* Ensure all other unused pins are disabled and muted. */
5096 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5097 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005098 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005099 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005100 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005101 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5102 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5103 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005104
Jonathan Woithef7ace402006-02-28 11:46:14 +01005105 /* Disable digital (SPDIF) pins */
5106 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5107 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005108
Kailang Yangea1fb292008-08-26 12:58:38 +02005109 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01005110 * when acting as an output.
5111 */
5112 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5113
5114 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01005115 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5116 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5117 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5118 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5119 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5120 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5121 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5122 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5123 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005124
Jonathan Woithef7ace402006-02-28 11:46:14 +01005125 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
5126 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5127 /* Unmute Line1 pin widget output buffer since it starts as an output.
5128 * If the pin mode is changed by the user the pin mode control will
5129 * take care of enabling the pin's input/output buffers as needed.
5130 * Therefore there's no need to enable the input buffer at this
5131 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005132 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005133 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02005134 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005135 * mixer ctrl)
5136 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005137 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005138
Jonathan Woithef7ace402006-02-28 11:46:14 +01005139 /* Mute capture amp left and right */
5140 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005141 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01005142 * in (on mic1 pin)
5143 */
5144 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005145
Jonathan Woithef7ace402006-02-28 11:46:14 +01005146 /* Do the same for the second ADC: mute capture input amp and
5147 * set ADC connection to line in (on mic1 pin)
5148 */
5149 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5150 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005151
Jonathan Woithef7ace402006-02-28 11:46:14 +01005152 /* Mute all inputs to mixer widget (even unconnected ones) */
5153 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5154 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5155 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5156 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5157 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5158 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5159 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5160 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005161
5162 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005163};
5164
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005165/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
5166 * similar laptops (adapted from Fujitsu init verbs).
5167 */
5168static struct hda_verb alc260_acer_init_verbs[] = {
5169 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
5170 * the headphone jack. Turn this on and rely on the standard mute
5171 * methods whenever the user wants to turn these outputs off.
5172 */
5173 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5174 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5175 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5176 /* Internal speaker/Headphone jack is connected to Line-out pin */
5177 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5178 /* Internal microphone/Mic jack is connected to Mic1 pin */
5179 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5180 /* Line In jack is connected to Line1 pin */
5181 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01005182 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
5183 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005184 /* Ensure all other unused pins are disabled and muted. */
5185 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5186 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005187 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5188 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5189 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5190 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5191 /* Disable digital (SPDIF) pins */
5192 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5193 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5194
Kailang Yangea1fb292008-08-26 12:58:38 +02005195 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005196 * bus when acting as outputs.
5197 */
5198 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5199 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5200
5201 /* Start with output sum widgets muted and their output gains at min */
5202 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5203 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5204 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5205 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5206 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5207 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5208 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5209 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5210 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5211
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005212 /* Unmute Line-out pin widget amp left and right
5213 * (no equiv mixer ctrl)
5214 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005215 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01005216 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
5217 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005218 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5219 * inputs. If the pin mode is changed by the user the pin mode control
5220 * will take care of enabling the pin's input/output buffers as needed.
5221 * Therefore there's no need to enable the input buffer at this
5222 * stage.
5223 */
5224 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5225 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5226
5227 /* Mute capture amp left and right */
5228 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5229 /* Set ADC connection select to match default mixer setting - mic
5230 * (on mic1 pin)
5231 */
5232 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5233
5234 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005235 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005236 */
5237 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005238 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005239
5240 /* Mute all inputs to mixer widget (even unconnected ones) */
5241 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5242 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5243 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5244 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5245 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5246 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5247 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5248 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5249
5250 { }
5251};
5252
Michael Schwingencc959482009-02-22 18:58:45 +01005253/* Initialisation sequence for Maxdata Favorit 100XS
5254 * (adapted from Acer init verbs).
5255 */
5256static struct hda_verb alc260_favorit100_init_verbs[] = {
5257 /* GPIO 0 enables the output jack.
5258 * Turn this on and rely on the standard mute
5259 * methods whenever the user wants to turn these outputs off.
5260 */
5261 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5262 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5263 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5264 /* Line/Mic input jack is connected to Mic1 pin */
5265 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5266 /* Ensure all other unused pins are disabled and muted. */
5267 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5268 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5269 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5270 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5271 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5272 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5273 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5274 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5275 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5276 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5277 /* Disable digital (SPDIF) pins */
5278 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5279 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5280
5281 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
5282 * bus when acting as outputs.
5283 */
5284 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5285 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5286
5287 /* Start with output sum widgets muted and their output gains at min */
5288 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5289 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5290 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5291 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5292 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5293 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5294 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5295 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5296 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5297
5298 /* Unmute Line-out pin widget amp left and right
5299 * (no equiv mixer ctrl)
5300 */
5301 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5302 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5303 * inputs. If the pin mode is changed by the user the pin mode control
5304 * will take care of enabling the pin's input/output buffers as needed.
5305 * Therefore there's no need to enable the input buffer at this
5306 * stage.
5307 */
5308 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5309
5310 /* Mute capture amp left and right */
5311 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5312 /* Set ADC connection select to match default mixer setting - mic
5313 * (on mic1 pin)
5314 */
5315 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5316
5317 /* Do similar with the second ADC: mute capture input amp and
5318 * set ADC connection to mic to match ALSA's default state.
5319 */
5320 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5321 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5322
5323 /* Mute all inputs to mixer widget (even unconnected ones) */
5324 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5325 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5326 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5327 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5328 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5329 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5330 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5331 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5332
5333 { }
5334};
5335
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005336static struct hda_verb alc260_will_verbs[] = {
5337 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5338 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
5339 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
5340 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5341 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5342 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
5343 {}
5344};
5345
5346static struct hda_verb alc260_replacer_672v_verbs[] = {
5347 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5348 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5349 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
5350
5351 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5352 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5353 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5354
5355 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5356 {}
5357};
5358
5359/* toggle speaker-output according to the hp-jack state */
5360static void alc260_replacer_672v_automute(struct hda_codec *codec)
5361{
5362 unsigned int present;
5363
5364 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
5365 present = snd_hda_codec_read(codec, 0x0f, 0,
5366 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5367 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005368 snd_hda_codec_write_cache(codec, 0x01, 0,
5369 AC_VERB_SET_GPIO_DATA, 1);
5370 snd_hda_codec_write_cache(codec, 0x0f, 0,
5371 AC_VERB_SET_PIN_WIDGET_CONTROL,
5372 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005373 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005374 snd_hda_codec_write_cache(codec, 0x01, 0,
5375 AC_VERB_SET_GPIO_DATA, 0);
5376 snd_hda_codec_write_cache(codec, 0x0f, 0,
5377 AC_VERB_SET_PIN_WIDGET_CONTROL,
5378 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005379 }
5380}
5381
5382static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
5383 unsigned int res)
5384{
5385 if ((res >> 26) == ALC880_HP_EVENT)
5386 alc260_replacer_672v_automute(codec);
5387}
5388
Kailang Yang3f878302008-08-26 13:02:23 +02005389static struct hda_verb alc260_hp_dc7600_verbs[] = {
5390 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
5391 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5392 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5393 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5394 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5395 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5396 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5397 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5398 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5399 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5400 {}
5401};
5402
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005403/* Test configuration for debugging, modelled after the ALC880 test
5404 * configuration.
5405 */
5406#ifdef CONFIG_SND_DEBUG
5407static hda_nid_t alc260_test_dac_nids[1] = {
5408 0x02,
5409};
5410static hda_nid_t alc260_test_adc_nids[2] = {
5411 0x04, 0x05,
5412};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005413/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02005414 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005415 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005416 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005417static struct hda_input_mux alc260_test_capture_sources[2] = {
5418 {
5419 .num_items = 7,
5420 .items = {
5421 { "MIC1 pin", 0x0 },
5422 { "MIC2 pin", 0x1 },
5423 { "LINE1 pin", 0x2 },
5424 { "LINE2 pin", 0x3 },
5425 { "CD pin", 0x4 },
5426 { "LINE-OUT pin", 0x5 },
5427 { "HP-OUT pin", 0x6 },
5428 },
5429 },
5430 {
5431 .num_items = 8,
5432 .items = {
5433 { "MIC1 pin", 0x0 },
5434 { "MIC2 pin", 0x1 },
5435 { "LINE1 pin", 0x2 },
5436 { "LINE2 pin", 0x3 },
5437 { "CD pin", 0x4 },
5438 { "Mixer", 0x5 },
5439 { "LINE-OUT pin", 0x6 },
5440 { "HP-OUT pin", 0x7 },
5441 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005442 },
5443};
5444static struct snd_kcontrol_new alc260_test_mixer[] = {
5445 /* Output driver widgets */
5446 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5447 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5448 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5449 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
5450 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5451 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
5452
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005453 /* Modes for retasking pin widgets
5454 * Note: the ALC260 doesn't seem to act on requests to enable mic
5455 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
5456 * mention this restriction. At this stage it's not clear whether
5457 * this behaviour is intentional or is a hardware bug in chip
5458 * revisions available at least up until early 2006. Therefore for
5459 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
5460 * choices, but if it turns out that the lack of mic bias for these
5461 * NIDs is intentional we could change their modes from
5462 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5463 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005464 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
5465 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
5466 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
5467 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
5468 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
5469 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
5470
5471 /* Loopback mixer controls */
5472 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
5473 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
5474 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
5475 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
5476 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
5477 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
5478 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
5479 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
5480 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5481 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005482 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
5483 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
5484 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
5485 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005486
5487 /* Controls for GPIO pins, assuming they are configured as outputs */
5488 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
5489 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
5490 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
5491 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
5492
Jonathan Woithe92621f12006-02-28 11:47:47 +01005493 /* Switches to allow the digital IO pins to be enabled. The datasheet
5494 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02005495 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01005496 */
5497 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
5498 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
5499
Jonathan Woithef8225f62008-01-08 12:16:54 +01005500 /* A switch allowing EAPD to be enabled. Some laptops seem to use
5501 * this output to turn on an external amplifier.
5502 */
5503 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
5504 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
5505
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005506 { } /* end */
5507};
5508static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005509 /* Enable all GPIOs as outputs with an initial value of 0 */
5510 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
5511 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5512 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
5513
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005514 /* Enable retasking pins as output, initially without power amp */
5515 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5516 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5517 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5518 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5519 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5520 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5521
Jonathan Woithe92621f12006-02-28 11:47:47 +01005522 /* Disable digital (SPDIF) pins initially, but users can enable
5523 * them via a mixer switch. In the case of SPDIF-out, this initverb
5524 * payload also sets the generation to 0, output to be in "consumer"
5525 * PCM format, copyright asserted, no pre-emphasis and no validity
5526 * control.
5527 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005528 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5529 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5530
Kailang Yangea1fb292008-08-26 12:58:38 +02005531 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005532 * OUT1 sum bus when acting as an output.
5533 */
5534 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5535 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
5536 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5537 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
5538
5539 /* Start with output sum widgets muted and their output gains at min */
5540 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5541 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5542 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5543 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5544 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5545 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5546 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5547 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5548 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5549
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005550 /* Unmute retasking pin widget output buffers since the default
5551 * state appears to be output. As the pin mode is changed by the
5552 * user the pin mode control will take care of enabling the pin's
5553 * input/output buffers as needed.
5554 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005555 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5556 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5557 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5558 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5559 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5560 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5561 /* Also unmute the mono-out pin widget */
5562 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5563
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005564 /* Mute capture amp left and right */
5565 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005566 /* Set ADC connection select to match default mixer setting (mic1
5567 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005568 */
5569 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5570
5571 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01005572 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005573 */
5574 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5575 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5576
5577 /* Mute all inputs to mixer widget (even unconnected ones) */
5578 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5579 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5580 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5581 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5582 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5583 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5584 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5585 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5586
5587 { }
5588};
5589#endif
5590
Takashi Iwai63300792008-01-24 15:31:36 +01005591#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
5592#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07005593
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005594#define alc260_pcm_digital_playback alc880_pcm_digital_playback
5595#define alc260_pcm_digital_capture alc880_pcm_digital_capture
5596
Kailang Yangdf694da2005-12-05 19:42:22 +01005597/*
5598 * for BIOS auto-configuration
5599 */
5600
5601static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02005602 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01005603{
5604 hda_nid_t nid_vol;
5605 unsigned long vol_val, sw_val;
5606 char name[32];
5607 int err;
5608
5609 if (nid >= 0x0f && nid < 0x11) {
5610 nid_vol = nid - 0x7;
5611 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5612 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5613 } else if (nid == 0x11) {
5614 nid_vol = nid - 0x7;
5615 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
5616 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
5617 } else if (nid >= 0x12 && nid <= 0x15) {
5618 nid_vol = 0x08;
5619 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5620 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5621 } else
5622 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02005623
Takashi Iwai863b4512008-10-21 17:01:47 +02005624 if (!(*vol_bits & (1 << nid_vol))) {
5625 /* first control for the volume widget */
5626 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
5627 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
5628 if (err < 0)
5629 return err;
5630 *vol_bits |= (1 << nid_vol);
5631 }
Kailang Yangdf694da2005-12-05 19:42:22 +01005632 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005633 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
5634 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005635 return err;
5636 return 1;
5637}
5638
5639/* add playback controls from the parsed DAC table */
5640static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
5641 const struct auto_pin_cfg *cfg)
5642{
5643 hda_nid_t nid;
5644 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02005645 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005646
5647 spec->multiout.num_dacs = 1;
5648 spec->multiout.dac_nids = spec->private_dac_nids;
5649 spec->multiout.dac_nids[0] = 0x02;
5650
5651 nid = cfg->line_out_pins[0];
5652 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005653 err = alc260_add_playback_controls(spec, nid, "Front", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005654 if (err < 0)
5655 return err;
5656 }
5657
Takashi Iwai82bc9552006-03-21 11:24:42 +01005658 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005659 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005660 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005661 if (err < 0)
5662 return err;
5663 }
5664
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005665 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005666 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005667 err = alc260_add_playback_controls(spec, nid, "Headphone",
5668 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005669 if (err < 0)
5670 return err;
5671 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005672 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005673}
5674
5675/* create playback/capture controls for input pins */
5676static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
5677 const struct auto_pin_cfg *cfg)
5678{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005679 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005680 int i, err, idx;
5681
5682 for (i = 0; i < AUTO_PIN_LAST; i++) {
5683 if (cfg->input_pins[i] >= 0x12) {
5684 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005685 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005686 auto_pin_cfg_labels[i], idx,
5687 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005688 if (err < 0)
5689 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005690 imux->items[imux->num_items].label =
5691 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005692 imux->items[imux->num_items].index = idx;
5693 imux->num_items++;
5694 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005695 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01005696 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005697 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005698 auto_pin_cfg_labels[i], idx,
5699 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005700 if (err < 0)
5701 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005702 imux->items[imux->num_items].label =
5703 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005704 imux->items[imux->num_items].index = idx;
5705 imux->num_items++;
5706 }
5707 }
5708 return 0;
5709}
5710
5711static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
5712 hda_nid_t nid, int pin_type,
5713 int sel_idx)
5714{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005715 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01005716 /* need the manual connection? */
5717 if (nid >= 0x12) {
5718 int idx = nid - 0x12;
5719 snd_hda_codec_write(codec, idx + 0x0b, 0,
5720 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01005721 }
5722}
5723
5724static void alc260_auto_init_multi_out(struct hda_codec *codec)
5725{
5726 struct alc_spec *spec = codec->spec;
5727 hda_nid_t nid;
5728
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005729 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005730 if (nid) {
5731 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5732 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
5733 }
Kailang Yangea1fb292008-08-26 12:58:38 +02005734
Takashi Iwai82bc9552006-03-21 11:24:42 +01005735 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005736 if (nid)
5737 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
5738
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005739 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005740 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005741 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005742}
Kailang Yangdf694da2005-12-05 19:42:22 +01005743
5744#define ALC260_PIN_CD_NID 0x16
5745static void alc260_auto_init_analog_input(struct hda_codec *codec)
5746{
5747 struct alc_spec *spec = codec->spec;
5748 int i;
5749
5750 for (i = 0; i < AUTO_PIN_LAST; i++) {
5751 hda_nid_t nid = spec->autocfg.input_pins[i];
5752 if (nid >= 0x12) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01005753 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01005754 if (nid != ALC260_PIN_CD_NID &&
5755 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005756 snd_hda_codec_write(codec, nid, 0,
5757 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01005758 AMP_OUT_MUTE);
5759 }
5760 }
5761}
5762
5763/*
5764 * generic initialization of ADC, input mixers and output mixers
5765 */
5766static struct hda_verb alc260_volume_init_verbs[] = {
5767 /*
5768 * Unmute ADC0-1 and set the default input to mic-in
5769 */
5770 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5771 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5772 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5773 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005774
Kailang Yangdf694da2005-12-05 19:42:22 +01005775 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5776 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005777 * Note: PASD motherboards uses the Line In 2 as the input for
5778 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01005779 */
5780 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005781 /* mute analog inputs */
5782 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5783 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5784 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5785 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5786 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005787
5788 /*
5789 * Set up output mixers (0x08 - 0x0a)
5790 */
5791 /* set vol=0 to output mixers */
5792 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5793 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5794 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5795 /* set up input amps for analog loopback */
5796 /* Amp Indices: DAC = 0, mixer = 1 */
5797 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5798 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5799 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5800 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5801 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5802 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005803
Kailang Yangdf694da2005-12-05 19:42:22 +01005804 { }
5805};
5806
5807static int alc260_parse_auto_config(struct hda_codec *codec)
5808{
5809 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005810 int err;
5811 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
5812
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005813 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5814 alc260_ignore);
5815 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005816 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005817 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
5818 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01005819 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02005820 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01005821 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005822 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
5823 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005824 return err;
5825
5826 spec->multiout.max_channels = 2;
5827
Takashi Iwai0852d7a2009-02-11 11:35:15 +01005828 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01005829 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02005830 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01005831 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01005832
Takashi Iwaid88897e2008-10-31 15:01:37 +01005833 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01005834
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005835 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005836 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005837
Takashi Iwai4a79ba32009-04-22 16:31:35 +02005838 alc_ssid_check(codec, 0x10, 0x15, 0x0f);
5839
Kailang Yangdf694da2005-12-05 19:42:22 +01005840 return 1;
5841}
5842
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005843/* additional initialization for auto-configuration model */
5844static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01005845{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005846 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005847 alc260_auto_init_multi_out(codec);
5848 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005849 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02005850 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005851}
5852
Takashi Iwaicb53c622007-08-10 17:21:45 +02005853#ifdef CONFIG_SND_HDA_POWER_SAVE
5854static struct hda_amp_list alc260_loopbacks[] = {
5855 { 0x07, HDA_INPUT, 0 },
5856 { 0x07, HDA_INPUT, 1 },
5857 { 0x07, HDA_INPUT, 2 },
5858 { 0x07, HDA_INPUT, 3 },
5859 { 0x07, HDA_INPUT, 4 },
5860 { } /* end */
5861};
5862#endif
5863
Kailang Yangdf694da2005-12-05 19:42:22 +01005864/*
5865 * ALC260 configurations
5866 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005867static const char *alc260_models[ALC260_MODEL_LAST] = {
5868 [ALC260_BASIC] = "basic",
5869 [ALC260_HP] = "hp",
5870 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02005871 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005872 [ALC260_FUJITSU_S702X] = "fujitsu",
5873 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005874 [ALC260_WILL] = "will",
5875 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01005876 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005877#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005878 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005879#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005880 [ALC260_AUTO] = "auto",
5881};
5882
5883static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01005884 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005885 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01005886 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01005887 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01005888 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005889 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02005890 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02005891 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005892 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
5893 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
5894 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
5895 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
5896 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
5897 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
5898 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
5899 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
5900 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005901 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01005902 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02005903 {}
5904};
5905
Kailang Yangdf694da2005-12-05 19:42:22 +01005906static struct alc_config_preset alc260_presets[] = {
5907 [ALC260_BASIC] = {
5908 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005909 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01005910 .init_verbs = { alc260_init_verbs },
5911 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5912 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005913 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Kailang Yangdf694da2005-12-05 19:42:22 +01005914 .adc_nids = alc260_adc_nids,
5915 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5916 .channel_mode = alc260_modes,
5917 .input_mux = &alc260_capture_source,
5918 },
5919 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005920 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005921 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005922 .init_verbs = { alc260_init_verbs,
5923 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005924 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5925 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005926 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5927 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01005928 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5929 .channel_mode = alc260_modes,
5930 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005931 .unsol_event = alc260_hp_unsol_event,
5932 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005933 },
Kailang Yang3f878302008-08-26 13:02:23 +02005934 [ALC260_HP_DC7600] = {
5935 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005936 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02005937 .init_verbs = { alc260_init_verbs,
5938 alc260_hp_dc7600_verbs },
5939 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5940 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005941 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5942 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02005943 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5944 .channel_mode = alc260_modes,
5945 .input_mux = &alc260_capture_source,
5946 .unsol_event = alc260_hp_3012_unsol_event,
5947 .init_hook = alc260_hp_3012_automute,
5948 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005949 [ALC260_HP_3013] = {
5950 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005951 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005952 .init_verbs = { alc260_hp_3013_init_verbs,
5953 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005954 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5955 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005956 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5957 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01005958 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5959 .channel_mode = alc260_modes,
5960 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005961 .unsol_event = alc260_hp_3013_unsol_event,
5962 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005963 },
5964 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005965 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01005966 .init_verbs = { alc260_fujitsu_init_verbs },
5967 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5968 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005969 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5970 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01005971 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5972 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005973 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
5974 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01005975 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005976 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005977 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005978 .init_verbs = { alc260_acer_init_verbs },
5979 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5980 .dac_nids = alc260_dac_nids,
5981 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5982 .adc_nids = alc260_dual_adc_nids,
5983 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5984 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005985 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
5986 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005987 },
Michael Schwingencc959482009-02-22 18:58:45 +01005988 [ALC260_FAVORIT100] = {
5989 .mixers = { alc260_favorit100_mixer },
5990 .init_verbs = { alc260_favorit100_init_verbs },
5991 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5992 .dac_nids = alc260_dac_nids,
5993 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5994 .adc_nids = alc260_dual_adc_nids,
5995 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5996 .channel_mode = alc260_modes,
5997 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
5998 .input_mux = alc260_favorit100_capture_sources,
5999 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006000 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006001 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006002 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
6003 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6004 .dac_nids = alc260_dac_nids,
6005 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6006 .adc_nids = alc260_adc_nids,
6007 .dig_out_nid = ALC260_DIGOUT_NID,
6008 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6009 .channel_mode = alc260_modes,
6010 .input_mux = &alc260_capture_source,
6011 },
6012 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006013 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006014 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
6015 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6016 .dac_nids = alc260_dac_nids,
6017 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6018 .adc_nids = alc260_adc_nids,
6019 .dig_out_nid = ALC260_DIGOUT_NID,
6020 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6021 .channel_mode = alc260_modes,
6022 .input_mux = &alc260_capture_source,
6023 .unsol_event = alc260_replacer_672v_unsol_event,
6024 .init_hook = alc260_replacer_672v_automute,
6025 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006026#ifdef CONFIG_SND_DEBUG
6027 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006028 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006029 .init_verbs = { alc260_test_init_verbs },
6030 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
6031 .dac_nids = alc260_test_dac_nids,
6032 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
6033 .adc_nids = alc260_test_adc_nids,
6034 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6035 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006036 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
6037 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006038 },
6039#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006040};
6041
Linus Torvalds1da177e2005-04-16 15:20:36 -07006042static int patch_alc260(struct hda_codec *codec)
6043{
6044 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006045 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006046
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006047 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006048 if (spec == NULL)
6049 return -ENOMEM;
6050
6051 codec->spec = spec;
6052
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006053 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
6054 alc260_models,
6055 alc260_cfg_tbl);
6056 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +02006057 snd_printd(KERN_INFO "hda_codec: Unknown model for %s, "
6058 "trying auto-probe from BIOS...\n",
6059 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01006060 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02006061 }
6062
Kailang Yangdf694da2005-12-05 19:42:22 +01006063 if (board_config == ALC260_AUTO) {
6064 /* automatic parse from the BIOS config */
6065 err = alc260_parse_auto_config(codec);
6066 if (err < 0) {
6067 alc_free(codec);
6068 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006069 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006070 printk(KERN_INFO
6071 "hda_codec: Cannot set up configuration "
6072 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006073 board_config = ALC260_BASIC;
6074 }
Takashi Iwai16ded522005-06-10 19:58:24 +02006075 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006076
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09006077 err = snd_hda_attach_beep_device(codec, 0x1);
6078 if (err < 0) {
6079 alc_free(codec);
6080 return err;
6081 }
6082
Kailang Yangdf694da2005-12-05 19:42:22 +01006083 if (board_config != ALC260_AUTO)
6084 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006085
Linus Torvalds1da177e2005-04-16 15:20:36 -07006086 spec->stream_analog_playback = &alc260_pcm_analog_playback;
6087 spec->stream_analog_capture = &alc260_pcm_analog_capture;
6088
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006089 spec->stream_digital_playback = &alc260_pcm_digital_playback;
6090 spec->stream_digital_capture = &alc260_pcm_digital_capture;
6091
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006092 if (!spec->adc_nids && spec->input_mux) {
6093 /* check whether NID 0x04 is valid */
6094 unsigned int wcap = get_wcaps(codec, 0x04);
6095 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
6096 /* get type */
6097 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
6098 spec->adc_nids = alc260_adc_nids_alt;
6099 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
6100 } else {
6101 spec->adc_nids = alc260_adc_nids;
6102 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
6103 }
6104 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006105 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006106 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006107
Takashi Iwai2134ea42008-01-10 16:53:55 +01006108 spec->vmaster_nid = 0x08;
6109
Linus Torvalds1da177e2005-04-16 15:20:36 -07006110 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006111 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006112 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006113#ifdef CONFIG_SND_HDA_POWER_SAVE
6114 if (!spec->loopback.amplist)
6115 spec->loopback.amplist = alc260_loopbacks;
6116#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01006117 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006118
6119 return 0;
6120}
6121
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006122
Linus Torvalds1da177e2005-04-16 15:20:36 -07006123/*
6124 * ALC882 support
6125 *
6126 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
6127 * configuration. Each pin widget can choose any input DACs and a mixer.
6128 * Each ADC is connected from a mixer of all inputs. This makes possible
6129 * 6-channel independent captures.
6130 *
6131 * In addition, an independent DAC for the multi-playback (not used in this
6132 * driver yet).
6133 */
Kailang Yangdf694da2005-12-05 19:42:22 +01006134#define ALC882_DIGOUT_NID 0x06
6135#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07006136
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01006137static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07006138 { 8, NULL }
6139};
6140
6141static hda_nid_t alc882_dac_nids[4] = {
6142 /* front, rear, clfe, rear_surr */
6143 0x02, 0x03, 0x04, 0x05
6144};
6145
Kailang Yangdf694da2005-12-05 19:42:22 +01006146/* identical with ALC880 */
6147#define alc882_adc_nids alc880_adc_nids
6148#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07006149
Takashi Iwaie1406342008-02-11 18:32:32 +01006150static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
6151static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
6152
Linus Torvalds1da177e2005-04-16 15:20:36 -07006153/* input MUX */
6154/* FIXME: should be a matrix-type input source selection */
6155
6156static struct hda_input_mux alc882_capture_source = {
6157 .num_items = 4,
6158 .items = {
6159 { "Mic", 0x0 },
6160 { "Front Mic", 0x1 },
6161 { "Line", 0x2 },
6162 { "CD", 0x4 },
6163 },
6164};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006165
6166static struct hda_input_mux mb5_capture_source = {
6167 .num_items = 3,
6168 .items = {
6169 { "Mic", 0x1 },
6170 { "Line", 0x2 },
6171 { "CD", 0x4 },
6172 },
6173};
6174
Kailang Yangdf694da2005-12-05 19:42:22 +01006175/*
Kailang Yang272a5272007-05-14 11:00:38 +02006176 * 2ch mode
6177 */
6178static struct hda_verb alc882_3ST_ch2_init[] = {
6179 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6180 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6181 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6182 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6183 { } /* end */
6184};
6185
6186/*
6187 * 6ch mode
6188 */
6189static struct hda_verb alc882_3ST_ch6_init[] = {
6190 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6191 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6192 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6193 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6194 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6195 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6196 { } /* end */
6197};
6198
6199static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
6200 { 2, alc882_3ST_ch2_init },
6201 { 6, alc882_3ST_ch6_init },
6202};
6203
6204/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006205 * 6ch mode
6206 */
6207static struct hda_verb alc882_sixstack_ch6_init[] = {
6208 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6209 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6210 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6211 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6212 { } /* end */
6213};
6214
6215/*
6216 * 8ch mode
6217 */
6218static struct hda_verb alc882_sixstack_ch8_init[] = {
6219 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6220 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6221 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6222 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6223 { } /* end */
6224};
6225
6226static struct hda_channel_mode alc882_sixstack_modes[2] = {
6227 { 6, alc882_sixstack_ch6_init },
6228 { 8, alc882_sixstack_ch8_init },
6229};
6230
Takashi Iwai87350ad2007-08-16 18:19:38 +02006231/*
6232 * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
6233 */
6234
6235/*
6236 * 2ch mode
6237 */
6238static struct hda_verb alc885_mbp_ch2_init[] = {
6239 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6240 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6241 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6242 { } /* end */
6243};
6244
6245/*
6246 * 6ch mode
6247 */
6248static struct hda_verb alc885_mbp_ch6_init[] = {
6249 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6250 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6251 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6252 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6253 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6254 { } /* end */
6255};
6256
6257static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
6258 { 2, alc885_mbp_ch2_init },
6259 { 6, alc885_mbp_ch6_init },
6260};
6261
6262
Linus Torvalds1da177e2005-04-16 15:20:36 -07006263/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6264 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6265 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01006266static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02006267 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006268 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006269 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006270 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006271 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6272 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006273 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6274 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006275 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006276 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006277 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6278 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6279 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6280 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6281 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6282 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006283 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006284 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6285 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006286 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006287 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006288 { } /* end */
6289};
6290
Takashi Iwai87350ad2007-08-16 18:19:38 +02006291static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01006292 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6293 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
6294 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
6295 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
6296 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6297 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006298 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
6299 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01006300 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006301 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
6302 { } /* end */
6303};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006304
6305static struct snd_kcontrol_new alc885_mb5_mixer[] = {
6306 HDA_CODEC_VOLUME("Front Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
6307 HDA_BIND_MUTE ("Front Playback Switch", 0x0d, 0x02, HDA_INPUT),
6308 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6309 HDA_BIND_MUTE ("Line-Out Playback Switch", 0x0c, 0x02, HDA_INPUT),
6310 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6311 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6312 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
6313 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
6314 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
6315 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0x00, HDA_INPUT),
6316 { } /* end */
6317};
Kailang Yangbdd148a2007-05-08 15:19:08 +02006318static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
6319 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6320 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6321 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6322 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6323 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6324 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6325 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6326 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6327 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02006328 { } /* end */
6329};
6330
Kailang Yang272a5272007-05-14 11:00:38 +02006331static struct snd_kcontrol_new alc882_targa_mixer[] = {
6332 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6333 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6334 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6335 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6336 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6337 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6338 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6339 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6340 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006341 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006342 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6343 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006344 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006345 { } /* end */
6346};
6347
6348/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
6349 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
6350 */
6351static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
6352 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6353 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6354 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6355 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
6356 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6357 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6358 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6359 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6360 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
6361 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
6362 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6363 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006364 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006365 { } /* end */
6366};
6367
Takashi Iwai914759b2007-09-06 14:52:04 +02006368static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
6369 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6370 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6371 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6372 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6373 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6374 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6375 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6376 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6377 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6378 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02006379 { } /* end */
6380};
6381
Kailang Yangdf694da2005-12-05 19:42:22 +01006382static struct snd_kcontrol_new alc882_chmode_mixer[] = {
6383 {
6384 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6385 .name = "Channel Mode",
6386 .info = alc_ch_mode_info,
6387 .get = alc_ch_mode_get,
6388 .put = alc_ch_mode_put,
6389 },
6390 { } /* end */
6391};
6392
Linus Torvalds1da177e2005-04-16 15:20:36 -07006393static struct hda_verb alc882_init_verbs[] = {
6394 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006395 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6396 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6397 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006398 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006399 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6400 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6401 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006402 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006403 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6404 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6405 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006406 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006407 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6408 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6409 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006410
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006411 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006412 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006413 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006414 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006415 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006416 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006417 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006418 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006419 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006420 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006421 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006422 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006423 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006424 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006425 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006426 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006427 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006428 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006429 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6430 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006431 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006432 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6433 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006434 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006435 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6436 /* Line-2 In: Headphone output (output 0 - 0x0c) */
6437 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6438 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6439 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006440 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006441 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006442
6443 /* FIXME: use matrix-type input source selection */
6444 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6445 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02006446 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6447 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6448 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6449 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006450 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006451 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6452 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6453 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6454 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006455 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006456 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6457 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6458 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6459 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6460 /* ADC1: mute amp left and right */
6461 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006462 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02006463 /* ADC2: mute amp left and right */
6464 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006465 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02006466 /* ADC3: mute amp left and right */
6467 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006468 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006469
6470 { }
6471};
6472
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006473static struct hda_verb alc882_eapd_verbs[] = {
6474 /* change to EAPD mode */
6475 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006476 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006477 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006478};
6479
Tobin Davis9102cd12006-12-15 10:02:12 +01006480/* Mac Pro test */
6481static struct snd_kcontrol_new alc882_macpro_mixer[] = {
6482 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6483 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6484 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
6485 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
6486 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006487 /* FIXME: this looks suspicious...
Tobin Davis9102cd12006-12-15 10:02:12 +01006488 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
6489 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006490 */
Tobin Davis9102cd12006-12-15 10:02:12 +01006491 { } /* end */
6492};
6493
6494static struct hda_verb alc882_macpro_init_verbs[] = {
6495 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6496 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6497 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6498 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6499 /* Front Pin: output 0 (0x0c) */
6500 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6501 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6502 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6503 /* Front Mic pin: input vref at 80% */
6504 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6505 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6506 /* Speaker: output */
6507 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6508 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6509 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
6510 /* Headphone output (output 0 - 0x0c) */
6511 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6512 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6513 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6514
6515 /* FIXME: use matrix-type input source selection */
6516 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6517 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6518 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6519 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6520 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6521 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6522 /* Input mixer2 */
6523 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6524 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6525 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6526 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6527 /* Input mixer3 */
6528 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6529 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6530 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6531 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6532 /* ADC1: mute amp left and right */
6533 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6534 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6535 /* ADC2: mute amp left and right */
6536 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6537 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6538 /* ADC3: mute amp left and right */
6539 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6540 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6541
6542 { }
6543};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006544
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006545/* Macbook 5,1 */
6546static struct hda_verb alc885_mb5_init_verbs[] = {
6547 /* Front mixer */
6548 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6549 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6550 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6551 /* LineOut mixer */
6552 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6553 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6554 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6555 /* Front Pin: output 0 (0x0d) */
6556 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
6557 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6558 {0x18, AC_VERB_SET_CONNECT_SEL, 0x01},
6559 /* HP Pin: output 0 (0x0c) */
6560 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6561 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6562 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6563 /* Front Mic pin: input vref at 80% */
6564 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6565 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6566 /* Line In pin */
6567 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6568 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6569
6570 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6571 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6572 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6573 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6574 { }
6575};
6576
Takashi Iwai87350ad2007-08-16 18:19:38 +02006577/* Macbook Pro rev3 */
6578static struct hda_verb alc885_mbp3_init_verbs[] = {
6579 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6580 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6581 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6582 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6583 /* Rear mixer */
6584 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6585 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6586 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6587 /* Front Pin: output 0 (0x0c) */
6588 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6589 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6590 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6591 /* HP Pin: output 0 (0x0d) */
6592 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
6593 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6594 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6595 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6596 /* Mic (rear) pin: input vref at 80% */
6597 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6598 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6599 /* Front Mic pin: input vref at 80% */
6600 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6601 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6602 /* Line In pin: use output 1 when in LineOut mode */
6603 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6604 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6605 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
6606
6607 /* FIXME: use matrix-type input source selection */
6608 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6609 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6610 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6611 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6612 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6613 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6614 /* Input mixer2 */
6615 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6616 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6617 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6618 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6619 /* Input mixer3 */
6620 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6621 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6622 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6623 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6624 /* ADC1: mute amp left and right */
6625 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6626 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6627 /* ADC2: mute amp left and right */
6628 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6629 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6630 /* ADC3: mute amp left and right */
6631 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6632 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6633
6634 { }
6635};
6636
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006637/* iMac 24 mixer. */
6638static struct snd_kcontrol_new alc885_imac24_mixer[] = {
6639 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6640 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
6641 { } /* end */
6642};
6643
6644/* iMac 24 init verbs. */
6645static struct hda_verb alc885_imac24_init_verbs[] = {
6646 /* Internal speakers: output 0 (0x0c) */
6647 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6648 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6649 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6650 /* Internal speakers: output 0 (0x0c) */
6651 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6652 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6653 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
6654 /* Headphone: output 0 (0x0c) */
6655 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6656 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6657 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6658 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6659 /* Front Mic: input vref at 80% */
6660 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6661 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6662 { }
6663};
6664
6665/* Toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006666static void alc885_imac24_automute_init_hook(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006667{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006668 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006669
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006670 spec->autocfg.hp_pins[0] = 0x14;
6671 spec->autocfg.speaker_pins[0] = 0x18;
6672 spec->autocfg.speaker_pins[1] = 0x1a;
6673 alc_automute_amp(codec);
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006674}
6675
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006676static void alc885_mbp3_init_hook(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006677{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006678 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006679
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006680 spec->autocfg.hp_pins[0] = 0x15;
6681 spec->autocfg.speaker_pins[0] = 0x14;
6682 alc_automute_amp(codec);
Takashi Iwai87350ad2007-08-16 18:19:38 +02006683}
6684
6685
Kailang Yang272a5272007-05-14 11:00:38 +02006686static struct hda_verb alc882_targa_verbs[] = {
6687 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6688 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6689
6690 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6691 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006692
Kailang Yang272a5272007-05-14 11:00:38 +02006693 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6694 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6695 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6696
6697 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6698 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
6699 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
6700 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
6701 { } /* end */
6702};
6703
6704/* toggle speaker-output according to the hp-jack state */
6705static void alc882_targa_automute(struct hda_codec *codec)
6706{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006707 struct alc_spec *spec = codec->spec;
6708 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006709 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006710 spec->jack_present ? 1 : 3);
6711}
6712
6713static void alc882_targa_init_hook(struct hda_codec *codec)
6714{
6715 struct alc_spec *spec = codec->spec;
6716
6717 spec->autocfg.hp_pins[0] = 0x14;
6718 spec->autocfg.speaker_pins[0] = 0x1b;
6719 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02006720}
6721
6722static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
6723{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006724 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02006725 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02006726}
6727
6728static struct hda_verb alc882_asus_a7j_verbs[] = {
6729 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6730 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6731
6732 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6733 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6734 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006735
Kailang Yang272a5272007-05-14 11:00:38 +02006736 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6737 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6738 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6739
6740 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6741 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6742 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6743 { } /* end */
6744};
6745
Takashi Iwai914759b2007-09-06 14:52:04 +02006746static struct hda_verb alc882_asus_a7m_verbs[] = {
6747 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6748 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6749
6750 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6751 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6752 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006753
Takashi Iwai914759b2007-09-06 14:52:04 +02006754 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6755 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6756 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6757
6758 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6759 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6760 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6761 { } /* end */
6762};
6763
Tobin Davis9102cd12006-12-15 10:02:12 +01006764static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
6765{
6766 unsigned int gpiostate, gpiomask, gpiodir;
6767
6768 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
6769 AC_VERB_GET_GPIO_DATA, 0);
6770
6771 if (!muted)
6772 gpiostate |= (1 << pin);
6773 else
6774 gpiostate &= ~(1 << pin);
6775
6776 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
6777 AC_VERB_GET_GPIO_MASK, 0);
6778 gpiomask |= (1 << pin);
6779
6780 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
6781 AC_VERB_GET_GPIO_DIRECTION, 0);
6782 gpiodir |= (1 << pin);
6783
6784
6785 snd_hda_codec_write(codec, codec->afg, 0,
6786 AC_VERB_SET_GPIO_MASK, gpiomask);
6787 snd_hda_codec_write(codec, codec->afg, 0,
6788 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
6789
6790 msleep(1);
6791
6792 snd_hda_codec_write(codec, codec->afg, 0,
6793 AC_VERB_SET_GPIO_DATA, gpiostate);
6794}
6795
Takashi Iwai7debbe52007-08-16 15:01:03 +02006796/* set up GPIO at initialization */
6797static void alc885_macpro_init_hook(struct hda_codec *codec)
6798{
6799 alc882_gpio_mute(codec, 0, 0);
6800 alc882_gpio_mute(codec, 1, 0);
6801}
6802
6803/* set up GPIO and update auto-muting at initialization */
6804static void alc885_imac24_init_hook(struct hda_codec *codec)
6805{
6806 alc885_macpro_init_hook(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006807 alc885_imac24_automute_init_hook(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02006808}
6809
Kailang Yangdf694da2005-12-05 19:42:22 +01006810/*
6811 * generic initialization of ADC, input mixers and output mixers
6812 */
6813static struct hda_verb alc882_auto_init_verbs[] = {
6814 /*
6815 * Unmute ADC0-2 and set the default input to mic-in
6816 */
6817 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6818 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6819 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6820 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6821 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6822 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6823
Takashi Iwaicb53c622007-08-10 17:21:45 +02006824 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01006825 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006826 * Note: PASD motherboards uses the Line In 2 as the input for
6827 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006828 */
6829 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006830 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6831 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6832 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6833 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6834 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006835
6836 /*
6837 * Set up output mixers (0x0c - 0x0f)
6838 */
6839 /* set vol=0 to output mixers */
6840 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6841 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6842 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6843 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6844 /* set up input amps for analog loopback */
6845 /* Amp Indices: DAC = 0, mixer = 1 */
6846 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6847 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6848 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6849 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6850 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6851 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6852 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6853 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6854 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6855 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6856
6857 /* FIXME: use matrix-type input source selection */
6858 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6859 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6860 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6861 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6862 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6863 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6864 /* Input mixer2 */
6865 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6866 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6867 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6868 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6869 /* Input mixer3 */
6870 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6871 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6872 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6873 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6874
6875 { }
6876};
6877
Takashi Iwaicb53c622007-08-10 17:21:45 +02006878#ifdef CONFIG_SND_HDA_POWER_SAVE
6879#define alc882_loopbacks alc880_loopbacks
6880#endif
6881
Kailang Yangdf694da2005-12-05 19:42:22 +01006882/* pcm configuration: identiacal with ALC880 */
6883#define alc882_pcm_analog_playback alc880_pcm_analog_playback
6884#define alc882_pcm_analog_capture alc880_pcm_analog_capture
6885#define alc882_pcm_digital_playback alc880_pcm_digital_playback
6886#define alc882_pcm_digital_capture alc880_pcm_digital_capture
6887
6888/*
6889 * configuration and preset
6890 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006891static const char *alc882_models[ALC882_MODEL_LAST] = {
6892 [ALC882_3ST_DIG] = "3stack-dig",
6893 [ALC882_6ST_DIG] = "6stack-dig",
6894 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02006895 [ALC882_W2JC] = "w2jc",
Takashi Iwai0438a002007-09-06 14:54:11 +02006896 [ALC882_TARGA] = "targa",
6897 [ALC882_ASUS_A7J] = "asus-a7j",
6898 [ALC882_ASUS_A7M] = "asus-a7m",
Tobin Davis9102cd12006-12-15 10:02:12 +01006899 [ALC885_MACPRO] = "macpro",
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006900 [ALC885_MB5] = "mb5",
Takashi Iwai87350ad2007-08-16 18:19:38 +02006901 [ALC885_MBP3] = "mbp3",
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006902 [ALC885_IMAC24] = "imac24",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006903 [ALC882_AUTO] = "auto",
6904};
6905
6906static struct snd_pci_quirk alc882_cfg_tbl[] = {
6907 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02006908 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Kailang Yangac8842a2007-09-20 12:51:39 +02006909 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
Takashi Iwai914759b2007-09-06 14:52:04 +02006910 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006911 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Claudio Matsuokac5d9f1c2007-07-19 23:18:32 +02006912 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
Tobin Davis7b9470d2006-12-28 13:56:48 +01006913 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006914 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Jiang zhe44447042008-01-28 12:28:24 +01006915 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006916 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
6917 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
6918 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yangdf694da2005-12-05 19:42:22 +01006919 {}
6920};
6921
6922static struct alc_config_preset alc882_presets[] = {
6923 [ALC882_3ST_DIG] = {
6924 .mixers = { alc882_base_mixer },
6925 .init_verbs = { alc882_init_verbs },
6926 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6927 .dac_nids = alc882_dac_nids,
6928 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006929 .dig_in_nid = ALC882_DIGIN_NID,
6930 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6931 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006932 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01006933 .input_mux = &alc882_capture_source,
6934 },
6935 [ALC882_6ST_DIG] = {
6936 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6937 .init_verbs = { alc882_init_verbs },
6938 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6939 .dac_nids = alc882_dac_nids,
6940 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006941 .dig_in_nid = ALC882_DIGIN_NID,
6942 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6943 .channel_mode = alc882_sixstack_modes,
6944 .input_mux = &alc882_capture_source,
6945 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006946 [ALC882_ARIMA] = {
6947 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6948 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
6949 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6950 .dac_nids = alc882_dac_nids,
6951 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6952 .channel_mode = alc882_sixstack_modes,
6953 .input_mux = &alc882_capture_source,
6954 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02006955 [ALC882_W2JC] = {
6956 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
6957 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6958 alc880_gpio1_init_verbs },
6959 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6960 .dac_nids = alc882_dac_nids,
6961 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6962 .channel_mode = alc880_threestack_modes,
6963 .need_dac_fix = 1,
6964 .input_mux = &alc882_capture_source,
6965 .dig_out_nid = ALC882_DIGOUT_NID,
6966 },
Takashi Iwai87350ad2007-08-16 18:19:38 +02006967 [ALC885_MBP3] = {
6968 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
6969 .init_verbs = { alc885_mbp3_init_verbs,
6970 alc880_gpio1_init_verbs },
6971 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6972 .dac_nids = alc882_dac_nids,
6973 .channel_mode = alc885_mbp_6ch_modes,
6974 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
6975 .input_mux = &alc882_capture_source,
6976 .dig_out_nid = ALC882_DIGOUT_NID,
6977 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006978 .unsol_event = alc_automute_amp_unsol_event,
6979 .init_hook = alc885_mbp3_init_hook,
Takashi Iwai87350ad2007-08-16 18:19:38 +02006980 },
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006981 [ALC885_MB5] = {
6982 .mixers = { alc885_mb5_mixer },
6983 .init_verbs = { alc885_mb5_init_verbs,
6984 alc880_gpio1_init_verbs },
6985 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6986 .dac_nids = alc882_dac_nids,
6987 .channel_mode = alc885_mbp_6ch_modes,
6988 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
6989 .input_mux = &mb5_capture_source,
6990 .dig_out_nid = ALC882_DIGOUT_NID,
6991 .dig_in_nid = ALC882_DIGIN_NID,
6992 },
Tobin Davis9102cd12006-12-15 10:02:12 +01006993 [ALC885_MACPRO] = {
6994 .mixers = { alc882_macpro_mixer },
6995 .init_verbs = { alc882_macpro_init_verbs },
6996 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6997 .dac_nids = alc882_dac_nids,
6998 .dig_out_nid = ALC882_DIGOUT_NID,
6999 .dig_in_nid = ALC882_DIGIN_NID,
7000 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
7001 .channel_mode = alc882_ch_modes,
7002 .input_mux = &alc882_capture_source,
Takashi Iwai7debbe52007-08-16 15:01:03 +02007003 .init_hook = alc885_macpro_init_hook,
Tobin Davis9102cd12006-12-15 10:02:12 +01007004 },
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007005 [ALC885_IMAC24] = {
7006 .mixers = { alc885_imac24_mixer },
7007 .init_verbs = { alc885_imac24_init_verbs },
7008 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7009 .dac_nids = alc882_dac_nids,
7010 .dig_out_nid = ALC882_DIGOUT_NID,
7011 .dig_in_nid = ALC882_DIGIN_NID,
7012 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
7013 .channel_mode = alc882_ch_modes,
7014 .input_mux = &alc882_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007015 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai7debbe52007-08-16 15:01:03 +02007016 .init_hook = alc885_imac24_init_hook,
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007017 },
Kailang Yang272a5272007-05-14 11:00:38 +02007018 [ALC882_TARGA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007019 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Kailang Yang272a5272007-05-14 11:00:38 +02007020 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
7021 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7022 .dac_nids = alc882_dac_nids,
7023 .dig_out_nid = ALC882_DIGOUT_NID,
7024 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
7025 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01007026 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02007027 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
7028 .channel_mode = alc882_3ST_6ch_modes,
7029 .need_dac_fix = 1,
7030 .input_mux = &alc882_capture_source,
7031 .unsol_event = alc882_targa_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007032 .init_hook = alc882_targa_init_hook,
Kailang Yang272a5272007-05-14 11:00:38 +02007033 },
7034 [ALC882_ASUS_A7J] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007035 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Kailang Yang272a5272007-05-14 11:00:38 +02007036 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
7037 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7038 .dac_nids = alc882_dac_nids,
7039 .dig_out_nid = ALC882_DIGOUT_NID,
7040 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
7041 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01007042 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02007043 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
7044 .channel_mode = alc882_3ST_6ch_modes,
7045 .need_dac_fix = 1,
7046 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02007047 },
Takashi Iwai914759b2007-09-06 14:52:04 +02007048 [ALC882_ASUS_A7M] = {
7049 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
7050 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
7051 alc880_gpio1_init_verbs,
7052 alc882_asus_a7m_verbs },
7053 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7054 .dac_nids = alc882_dac_nids,
7055 .dig_out_nid = ALC882_DIGOUT_NID,
7056 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
7057 .channel_mode = alc880_threestack_modes,
7058 .need_dac_fix = 1,
7059 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02007060 },
Kailang Yangdf694da2005-12-05 19:42:22 +01007061};
7062
7063
7064/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02007065 * Pin config fixes
7066 */
Kailang Yangea1fb292008-08-26 12:58:38 +02007067enum {
Takashi Iwaif95474e2007-07-10 00:47:43 +02007068 PINFIX_ABIT_AW9D_MAX
7069};
7070
7071static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
7072 { 0x15, 0x01080104 }, /* side */
7073 { 0x16, 0x01011012 }, /* rear */
7074 { 0x17, 0x01016011 }, /* clfe */
7075 { }
7076};
7077
7078static const struct alc_pincfg *alc882_pin_fixes[] = {
7079 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
7080};
7081
7082static struct snd_pci_quirk alc882_pinfix_tbl[] = {
7083 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
7084 {}
7085};
7086
7087/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007088 * BIOS auto configuration
7089 */
7090static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
7091 hda_nid_t nid, int pin_type,
7092 int dac_idx)
7093{
7094 /* set as output */
7095 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007096 int idx;
7097
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007098 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01007099 if (spec->multiout.dac_nids[dac_idx] == 0x25)
7100 idx = 4;
7101 else
7102 idx = spec->multiout.dac_nids[dac_idx] - 2;
Kailang Yangdf694da2005-12-05 19:42:22 +01007103 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
7104
7105}
7106
7107static void alc882_auto_init_multi_out(struct hda_codec *codec)
7108{
7109 struct alc_spec *spec = codec->spec;
7110 int i;
7111
7112 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007113 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007114 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01007115 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007116 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007117 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01007118 }
7119}
7120
7121static void alc882_auto_init_hp_out(struct hda_codec *codec)
7122{
7123 struct alc_spec *spec = codec->spec;
7124 hda_nid_t pin;
7125
Takashi Iwaieb06ed82006-09-20 17:10:27 +02007126 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007127 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007128 /* use dac 0 */
7129 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007130 pin = spec->autocfg.speaker_pins[0];
7131 if (pin)
7132 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01007133}
7134
7135#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
7136#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
7137
7138static void alc882_auto_init_analog_input(struct hda_codec *codec)
7139{
7140 struct alc_spec *spec = codec->spec;
7141 int i;
7142
7143 for (i = 0; i < AUTO_PIN_LAST; i++) {
7144 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai7194cae2008-03-06 16:58:17 +01007145 if (!nid)
7146 continue;
Takashi Iwai23f0c042009-02-26 13:03:58 +01007147 alc_set_input_pin(codec, nid, AUTO_PIN_FRONT_MIC /*i*/);
Takashi Iwai7194cae2008-03-06 16:58:17 +01007148 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
7149 snd_hda_codec_write(codec, nid, 0,
7150 AC_VERB_SET_AMP_GAIN_MUTE,
7151 AMP_OUT_MUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01007152 }
7153}
7154
Takashi Iwaif511b012008-08-15 16:46:42 +02007155static void alc882_auto_init_input_src(struct hda_codec *codec)
7156{
7157 struct alc_spec *spec = codec->spec;
Takashi Iwaif511b012008-08-15 16:46:42 +02007158 int c;
7159
7160 for (c = 0; c < spec->num_adc_nids; c++) {
7161 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
7162 hda_nid_t nid = spec->capsrc_nids[c];
Herton Ronaldo Krzesinskib98b7b32009-01-29 13:18:31 -02007163 unsigned int mux_idx;
7164 const struct hda_input_mux *imux;
Takashi Iwaif511b012008-08-15 16:46:42 +02007165 int conns, mute, idx, item;
7166
7167 conns = snd_hda_get_connections(codec, nid, conn_list,
7168 ARRAY_SIZE(conn_list));
7169 if (conns < 0)
7170 continue;
Herton Ronaldo Krzesinskib98b7b32009-01-29 13:18:31 -02007171 mux_idx = c >= spec->num_mux_defs ? 0 : c;
7172 imux = &spec->input_mux[mux_idx];
Takashi Iwaif511b012008-08-15 16:46:42 +02007173 for (idx = 0; idx < conns; idx++) {
7174 /* if the current connection is the selected one,
7175 * unmute it as default - otherwise mute it
7176 */
7177 mute = AMP_IN_MUTE(idx);
7178 for (item = 0; item < imux->num_items; item++) {
7179 if (imux->items[item].index == idx) {
7180 if (spec->cur_mux[c] == item)
7181 mute = AMP_IN_UNMUTE(idx);
7182 break;
7183 }
7184 }
Herton Ronaldo Krzesinskib98b7b32009-01-29 13:18:31 -02007185 /* check if we have a selector or mixer
7186 * we could check for the widget type instead, but
7187 * just check for Amp-In presence (in case of mixer
7188 * without amp-in there is something wrong, this
7189 * function shouldn't be used or capsrc nid is wrong)
7190 */
7191 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
7192 snd_hda_codec_write(codec, nid, 0,
7193 AC_VERB_SET_AMP_GAIN_MUTE,
7194 mute);
7195 else if (mute != AMP_IN_MUTE(idx))
7196 snd_hda_codec_write(codec, nid, 0,
7197 AC_VERB_SET_CONNECT_SEL,
7198 idx);
Takashi Iwaif511b012008-08-15 16:46:42 +02007199 }
7200 }
7201}
7202
Takashi Iwai776e1842007-08-29 15:07:11 +02007203/* add mic boosts if needed */
7204static int alc_auto_add_mic_boost(struct hda_codec *codec)
7205{
7206 struct alc_spec *spec = codec->spec;
7207 int err;
7208 hda_nid_t nid;
7209
7210 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01007211 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02007212 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7213 "Mic Boost",
7214 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
7215 if (err < 0)
7216 return err;
7217 }
7218 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01007219 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02007220 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7221 "Front Mic Boost",
7222 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
7223 if (err < 0)
7224 return err;
7225 }
7226 return 0;
7227}
7228
Kailang Yangdf694da2005-12-05 19:42:22 +01007229/* almost identical with ALC880 parser... */
7230static int alc882_parse_auto_config(struct hda_codec *codec)
7231{
7232 struct alc_spec *spec = codec->spec;
7233 int err = alc880_parse_auto_config(codec);
7234
7235 if (err < 0)
7236 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02007237 else if (!err)
7238 return 0; /* no config found */
7239
7240 err = alc_auto_add_mic_boost(codec);
7241 if (err < 0)
7242 return err;
7243
7244 /* hack - override the init verbs */
7245 spec->init_verbs[0] = alc882_auto_init_verbs;
7246
7247 return 1; /* config found */
Kailang Yangdf694da2005-12-05 19:42:22 +01007248}
7249
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007250/* additional initialization for auto-configuration model */
7251static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01007252{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007253 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007254 alc882_auto_init_multi_out(codec);
7255 alc882_auto_init_hp_out(codec);
7256 alc882_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02007257 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007258 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02007259 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01007260}
7261
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007262static int patch_alc883(struct hda_codec *codec); /* called in patch_alc882() */
7263
Linus Torvalds1da177e2005-04-16 15:20:36 -07007264static int patch_alc882(struct hda_codec *codec)
7265{
7266 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007267 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007268
Takashi Iwaie560d8d2005-09-09 14:21:46 +02007269 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007270 if (spec == NULL)
7271 return -ENOMEM;
7272
Linus Torvalds1da177e2005-04-16 15:20:36 -07007273 codec->spec = spec;
7274
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007275 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
7276 alc882_models,
7277 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007278
Kailang Yangdf694da2005-12-05 19:42:22 +01007279 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01007280 /* Pick up systems that don't supply PCI SSID */
7281 switch (codec->subsystem_id) {
7282 case 0x106b0c00: /* Mac Pro */
7283 board_config = ALC885_MACPRO;
7284 break;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007285 case 0x106b1000: /* iMac 24 */
Peter Korsgaardf3911c52008-09-27 09:13:45 +02007286 case 0x106b2800: /* AppleTV */
Mark Eggleston3077e442009-01-31 17:57:54 +01007287 case 0x106b3e00: /* iMac 24 Aluminium */
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007288 board_config = ALC885_IMAC24;
7289 break;
Luke Yelavich2d466382009-02-23 13:00:33 +11007290 case 0x106b00a0: /* MacBookPro3,1 - Another revision */
Takashi Iwaic7e07572008-06-26 14:42:51 +02007291 case 0x106b00a1: /* Macbook (might be wrong - PCI SSID?) */
David Woodhouse9c95c432008-09-18 13:37:13 -07007292 case 0x106b00a4: /* MacbookPro4,1 */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007293 case 0x106b2c00: /* Macbook Pro rev3 */
Takashi Iwaic7e07572008-06-26 14:42:51 +02007294 case 0x106b3600: /* Macbook 3.1 */
Luke Yelavich2a884642009-01-28 15:58:38 +11007295 case 0x106b3800: /* MacbookPro4,1 - latter revision */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007296 board_config = ALC885_MBP3;
7297 break;
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007298 case 0x106b3f00: /* Macbook 5,1 */
Takashi Iwai7442f9d2009-05-14 18:20:33 +02007299 case 0x106b4000: /* Macbook Pro 5,1 - FIXME: HP jack sense
7300 * seems not working, so apparently
7301 * no perfect solution yet
7302 */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007303 board_config = ALC885_MB5;
7304 break;
Tobin Davis081d17c2007-02-15 17:46:18 +01007305 default:
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007306 /* ALC889A is handled better as ALC888-compatible */
Clive Messer669faba2008-09-30 15:49:13 +02007307 if (codec->revision_id == 0x100101 ||
7308 codec->revision_id == 0x100103) {
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007309 alc_free(codec);
7310 return patch_alc883(codec);
7311 }
Takashi Iwai6c627f32009-05-18 12:33:36 +02007312 printk(KERN_INFO "hda_codec: Unknown model for %s, "
7313 "trying auto-probe from BIOS...\n",
7314 codec->chip_name);
Tobin Davis081d17c2007-02-15 17:46:18 +01007315 board_config = ALC882_AUTO;
7316 }
Kailang Yangdf694da2005-12-05 19:42:22 +01007317 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007318
Takashi Iwaif95474e2007-07-10 00:47:43 +02007319 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
7320
Kailang Yangdf694da2005-12-05 19:42:22 +01007321 if (board_config == ALC882_AUTO) {
7322 /* automatic parse from the BIOS config */
7323 err = alc882_parse_auto_config(codec);
7324 if (err < 0) {
7325 alc_free(codec);
7326 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007327 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007328 printk(KERN_INFO
7329 "hda_codec: Cannot set up configuration "
7330 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007331 board_config = ALC882_3ST_DIG;
7332 }
7333 }
7334
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09007335 err = snd_hda_attach_beep_device(codec, 0x1);
7336 if (err < 0) {
7337 alc_free(codec);
7338 return err;
7339 }
7340
Kailang Yangdf694da2005-12-05 19:42:22 +01007341 if (board_config != ALC882_AUTO)
7342 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007343
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 Iwai22b530e2009-05-13 11:32:52 +02008625 /* default Acer -- disabled as it causes more problems.
8626 * model=auto should work fine now
8627 */
8628 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008629 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Tobin Davisfebe3372007-06-12 11:27:46 +02008630 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008631 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
8632 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01008633 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01008634 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03008635 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Kailang Yanga01c30c2008-10-15 11:14:58 +02008636 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008637 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01008638 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01008639 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02008640 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Travis Place97ec7102008-05-23 18:31:46 +02008641 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008642 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008643 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008644 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
8645 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02008646 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008647 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Tobin Davis57b14f22007-04-18 23:05:36 +02008648 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008649 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
8650 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
8651 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Jiang zhe4383fae2008-04-14 12:58:57 +02008652 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008653 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01008654 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008655 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
8656 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
8657 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
8658 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
8659 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
8660 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
8661 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
8662 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
8663 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008664 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
8665 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02008666 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01008667 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01008668 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01008669 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02008670 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008671 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008672 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008673 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
8674 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
Takashi Iwaidea0a502009-02-09 17:14:52 +01008675 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04008676 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008677 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02008678 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01008679 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02008680 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008681 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02008682 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02008683 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008684 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
8685 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02008686 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02008687 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01008688 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01008689 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02008690 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008691 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
8692 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008693 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Wu Fengguang4b558992009-01-12 09:18:58 +08008694 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC883_3ST_6ch_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008695 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008696 {}
8697};
8698
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08008699static hda_nid_t alc883_slave_dig_outs[] = {
8700 ALC1200_DIGOUT_NID, 0,
8701};
8702
Wu Fengguangb25c9da2009-02-06 15:02:27 +08008703static hda_nid_t alc1200_slave_dig_outs[] = {
8704 ALC883_DIGOUT_NID, 0,
8705};
8706
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008707static struct alc_config_preset alc883_presets[] = {
8708 [ALC883_3ST_2ch_DIG] = {
8709 .mixers = { alc883_3ST_2ch_mixer },
8710 .init_verbs = { alc883_init_verbs },
8711 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8712 .dac_nids = alc883_dac_nids,
8713 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008714 .dig_in_nid = ALC883_DIGIN_NID,
8715 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8716 .channel_mode = alc883_3ST_2ch_modes,
8717 .input_mux = &alc883_capture_source,
8718 },
8719 [ALC883_3ST_6ch_DIG] = {
8720 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8721 .init_verbs = { alc883_init_verbs },
8722 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8723 .dac_nids = alc883_dac_nids,
8724 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008725 .dig_in_nid = ALC883_DIGIN_NID,
8726 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8727 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008728 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008729 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008730 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008731 [ALC883_3ST_6ch] = {
8732 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8733 .init_verbs = { alc883_init_verbs },
8734 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8735 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008736 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8737 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008738 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008739 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008740 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02008741 [ALC883_3ST_6ch_INTEL] = {
8742 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
8743 .init_verbs = { alc883_init_verbs },
8744 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8745 .dac_nids = alc883_dac_nids,
8746 .dig_out_nid = ALC883_DIGOUT_NID,
8747 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08008748 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +02008749 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
8750 .channel_mode = alc883_3ST_6ch_intel_modes,
8751 .need_dac_fix = 1,
8752 .input_mux = &alc883_3stack_6ch_intel,
8753 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008754 [ALC883_6ST_DIG] = {
8755 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
8756 .init_verbs = { alc883_init_verbs },
8757 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8758 .dac_nids = alc883_dac_nids,
8759 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008760 .dig_in_nid = ALC883_DIGIN_NID,
8761 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8762 .channel_mode = alc883_sixstack_modes,
8763 .input_mux = &alc883_capture_source,
8764 },
Kailang Yangccc656c2006-10-17 12:32:26 +02008765 [ALC883_TARGA_DIG] = {
8766 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
8767 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8768 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8769 .dac_nids = alc883_dac_nids,
8770 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008771 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8772 .channel_mode = alc883_3ST_6ch_modes,
8773 .need_dac_fix = 1,
8774 .input_mux = &alc883_capture_source,
8775 .unsol_event = alc883_tagra_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008776 .init_hook = alc883_tagra_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02008777 },
8778 [ALC883_TARGA_2ch_DIG] = {
8779 .mixers = { alc883_tagra_2ch_mixer},
8780 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8781 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8782 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008783 .adc_nids = alc883_adc_nids_alt,
8784 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangccc656c2006-10-17 12:32:26 +02008785 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008786 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8787 .channel_mode = alc883_3ST_2ch_modes,
8788 .input_mux = &alc883_capture_source,
8789 .unsol_event = alc883_tagra_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008790 .init_hook = alc883_tagra_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02008791 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008792 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008793 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008794 /* On TravelMate laptops, GPIO 0 enables the internal speaker
8795 * and the headphone jack. Turn this on and rely on the
8796 * standard mute methods whenever the user wants to turn
8797 * these outputs off.
8798 */
8799 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
8800 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8801 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008802 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8803 .channel_mode = alc883_3ST_2ch_modes,
8804 .input_mux = &alc883_capture_source,
8805 },
Tobin Davis2880a862007-08-07 11:50:26 +02008806 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008807 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02008808 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02008809 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8810 .dac_nids = alc883_dac_nids,
8811 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02008812 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8813 .channel_mode = alc883_3ST_2ch_modes,
8814 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008815 .unsol_event = alc_automute_amp_unsol_event,
8816 .init_hook = alc883_acer_aspire_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +02008817 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008818 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008819 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008820 alc883_chmode_mixer },
8821 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
8822 alc888_acer_aspire_4930g_verbs },
8823 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8824 .dac_nids = alc883_dac_nids,
8825 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
8826 .adc_nids = alc883_adc_nids_rev,
8827 .capsrc_nids = alc883_capsrc_nids_rev,
8828 .dig_out_nid = ALC883_DIGOUT_NID,
8829 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8830 .channel_mode = alc883_3ST_6ch_modes,
8831 .need_dac_fix = 1,
8832 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008833 ARRAY_SIZE(alc888_2_capture_sources),
8834 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008835 .unsol_event = alc_automute_amp_unsol_event,
8836 .init_hook = alc888_acer_aspire_4930g_init_hook,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008837 },
Tobin Davisc07584c2006-10-13 12:32:16 +02008838 [ALC883_MEDION] = {
8839 .mixers = { alc883_fivestack_mixer,
8840 alc883_chmode_mixer },
8841 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008842 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02008843 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8844 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008845 .adc_nids = alc883_adc_nids_alt,
8846 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Tobin Davisc07584c2006-10-13 12:32:16 +02008847 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8848 .channel_mode = alc883_sixstack_modes,
8849 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008850 },
Kailang Yang272a5272007-05-14 11:00:38 +02008851 [ALC883_MEDION_MD2] = {
8852 .mixers = { alc883_medion_md2_mixer},
8853 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
8854 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8855 .dac_nids = alc883_dac_nids,
8856 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008857 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8858 .channel_mode = alc883_3ST_2ch_modes,
8859 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008860 .unsol_event = alc_automute_amp_unsol_event,
8861 .init_hook = alc883_medion_md2_init_hook,
Kailang Yangea1fb292008-08-26 12:58:38 +02008862 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008863 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008864 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008865 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
8866 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8867 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008868 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8869 .channel_mode = alc883_3ST_2ch_modes,
8870 .input_mux = &alc883_capture_source,
8871 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008872 [ALC883_CLEVO_M720] = {
8873 .mixers = { alc883_clevo_m720_mixer },
8874 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01008875 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8876 .dac_nids = alc883_dac_nids,
8877 .dig_out_nid = ALC883_DIGOUT_NID,
8878 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8879 .channel_mode = alc883_3ST_2ch_modes,
8880 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008881 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008882 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +01008883 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008884 [ALC883_LENOVO_101E_2ch] = {
8885 .mixers = { alc883_lenovo_101e_2ch_mixer},
8886 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
8887 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8888 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008889 .adc_nids = alc883_adc_nids_alt,
8890 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008891 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8892 .channel_mode = alc883_3ST_2ch_modes,
8893 .input_mux = &alc883_lenovo_101e_capture_source,
8894 .unsol_event = alc883_lenovo_101e_unsol_event,
8895 .init_hook = alc883_lenovo_101e_all_automute,
8896 },
Kailang Yang272a5272007-05-14 11:00:38 +02008897 [ALC883_LENOVO_NB0763] = {
8898 .mixers = { alc883_lenovo_nb0763_mixer },
8899 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
8900 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8901 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02008902 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8903 .channel_mode = alc883_3ST_2ch_modes,
8904 .need_dac_fix = 1,
8905 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008906 .unsol_event = alc_automute_amp_unsol_event,
8907 .init_hook = alc883_medion_md2_init_hook,
Kailang Yang272a5272007-05-14 11:00:38 +02008908 },
8909 [ALC888_LENOVO_MS7195_DIG] = {
8910 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8911 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
8912 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8913 .dac_nids = alc883_dac_nids,
8914 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008915 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8916 .channel_mode = alc883_3ST_6ch_modes,
8917 .need_dac_fix = 1,
8918 .input_mux = &alc883_capture_source,
8919 .unsol_event = alc883_lenovo_ms7195_unsol_event,
8920 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02008921 },
8922 [ALC883_HAIER_W66] = {
8923 .mixers = { alc883_tagra_2ch_mixer},
8924 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
8925 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8926 .dac_nids = alc883_dac_nids,
8927 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02008928 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8929 .channel_mode = alc883_3ST_2ch_modes,
8930 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008931 .unsol_event = alc_automute_amp_unsol_event,
8932 .init_hook = alc883_haier_w66_init_hook,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01008933 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008934 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01008935 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008936 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008937 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8938 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008939 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
8940 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008941 .need_dac_fix = 1,
8942 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008943 .unsol_event = alc_automute_amp_unsol_event,
8944 .init_hook = alc888_3st_hp_init_hook,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008945 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008946 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01008947 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008948 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
8949 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8950 .dac_nids = alc883_dac_nids,
8951 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008952 .dig_in_nid = ALC883_DIGIN_NID,
8953 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8954 .channel_mode = alc883_sixstack_modes,
8955 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008956 .unsol_event = alc_automute_amp_unsol_event,
8957 .init_hook = alc888_6st_dell_init_hook,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008958 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008959 [ALC883_MITAC] = {
8960 .mixers = { alc883_mitac_mixer },
8961 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
8962 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8963 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008964 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8965 .channel_mode = alc883_3ST_2ch_modes,
8966 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008967 .unsol_event = alc_automute_amp_unsol_event,
8968 .init_hook = alc883_mitac_init_hook,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008969 },
Jiang zhefb97dc62008-03-06 11:07:11 +01008970 [ALC883_FUJITSU_PI2515] = {
8971 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
8972 .init_verbs = { alc883_init_verbs,
8973 alc883_2ch_fujitsu_pi2515_verbs},
8974 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8975 .dac_nids = alc883_dac_nids,
8976 .dig_out_nid = ALC883_DIGOUT_NID,
8977 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8978 .channel_mode = alc883_3ST_2ch_modes,
8979 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008980 .unsol_event = alc_automute_amp_unsol_event,
8981 .init_hook = alc883_2ch_fujitsu_pi2515_init_hook,
Jiang zhefb97dc62008-03-06 11:07:11 +01008982 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008983 [ALC888_FUJITSU_XA3530] = {
8984 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
8985 .init_verbs = { alc883_init_verbs,
8986 alc888_fujitsu_xa3530_verbs },
8987 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8988 .dac_nids = alc883_dac_nids,
8989 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
8990 .adc_nids = alc883_adc_nids_rev,
8991 .capsrc_nids = alc883_capsrc_nids_rev,
8992 .dig_out_nid = ALC883_DIGOUT_NID,
8993 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
8994 .channel_mode = alc888_4ST_8ch_intel_modes,
8995 .num_mux_defs =
8996 ARRAY_SIZE(alc888_2_capture_sources),
8997 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008998 .unsol_event = alc_automute_amp_unsol_event,
8999 .init_hook = alc888_fujitsu_xa3530_init_hook,
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009000 },
Kailang Yange2757d52008-08-26 13:17:46 +02009001 [ALC888_LENOVO_SKY] = {
9002 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
9003 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
9004 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9005 .dac_nids = alc883_dac_nids,
9006 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +02009007 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9008 .channel_mode = alc883_sixstack_modes,
9009 .need_dac_fix = 1,
9010 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009011 .unsol_event = alc_automute_amp_unsol_event,
9012 .init_hook = alc888_lenovo_sky_init_hook,
Kailang Yange2757d52008-08-26 13:17:46 +02009013 },
9014 [ALC888_ASUS_M90V] = {
9015 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9016 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
9017 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9018 .dac_nids = alc883_dac_nids,
9019 .dig_out_nid = ALC883_DIGOUT_NID,
9020 .dig_in_nid = ALC883_DIGIN_NID,
9021 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9022 .channel_mode = alc883_3ST_6ch_modes,
9023 .need_dac_fix = 1,
9024 .input_mux = &alc883_fujitsu_pi2515_capture_source,
9025 .unsol_event = alc883_mode2_unsol_event,
9026 .init_hook = alc883_mode2_inithook,
9027 },
9028 [ALC888_ASUS_EEE1601] = {
9029 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009030 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +02009031 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
9032 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9033 .dac_nids = alc883_dac_nids,
9034 .dig_out_nid = ALC883_DIGOUT_NID,
9035 .dig_in_nid = ALC883_DIGIN_NID,
9036 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9037 .channel_mode = alc883_3ST_2ch_modes,
9038 .need_dac_fix = 1,
9039 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009040 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +02009041 .init_hook = alc883_eee1601_inithook,
9042 },
Wu Fengguang3ab90932008-11-17 09:51:09 +01009043 [ALC1200_ASUS_P5Q] = {
9044 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9045 .init_verbs = { alc883_init_verbs },
9046 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9047 .dac_nids = alc883_dac_nids,
9048 .dig_out_nid = ALC1200_DIGOUT_NID,
9049 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +08009050 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +01009051 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9052 .channel_mode = alc883_sixstack_modes,
9053 .input_mux = &alc883_capture_source,
9054 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009055};
9056
9057
9058/*
9059 * BIOS auto configuration
9060 */
9061static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
9062 hda_nid_t nid, int pin_type,
9063 int dac_idx)
9064{
9065 /* set as output */
9066 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009067 int idx;
9068
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009069 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009070 if (spec->multiout.dac_nids[dac_idx] == 0x25)
9071 idx = 4;
9072 else
9073 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009074 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
9075
9076}
9077
9078static void alc883_auto_init_multi_out(struct hda_codec *codec)
9079{
9080 struct alc_spec *spec = codec->spec;
9081 int i;
9082
9083 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009084 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009085 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009086 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009087 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009088 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009089 }
9090}
9091
9092static void alc883_auto_init_hp_out(struct hda_codec *codec)
9093{
9094 struct alc_spec *spec = codec->spec;
9095 hda_nid_t pin;
9096
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009097 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009098 if (pin) /* connect to front */
9099 /* use dac 0 */
9100 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009101 pin = spec->autocfg.speaker_pins[0];
9102 if (pin)
9103 alc883_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009104}
9105
9106#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
9107#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
9108
9109static void alc883_auto_init_analog_input(struct hda_codec *codec)
9110{
9111 struct alc_spec *spec = codec->spec;
9112 int i;
9113
9114 for (i = 0; i < AUTO_PIN_LAST; i++) {
9115 hda_nid_t nid = spec->autocfg.input_pins[i];
9116 if (alc883_is_input_pin(nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01009117 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01009118 if (nid != ALC883_PIN_CD_NID &&
9119 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009120 snd_hda_codec_write(codec, nid, 0,
9121 AC_VERB_SET_AMP_GAIN_MUTE,
9122 AMP_OUT_MUTE);
9123 }
9124 }
9125}
9126
Takashi Iwaif511b012008-08-15 16:46:42 +02009127#define alc883_auto_init_input_src alc882_auto_init_input_src
9128
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009129/* almost identical with ALC880 parser... */
9130static int alc883_parse_auto_config(struct hda_codec *codec)
9131{
9132 struct alc_spec *spec = codec->spec;
9133 int err = alc880_parse_auto_config(codec);
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009134 struct auto_pin_cfg *cfg = &spec->autocfg;
9135 int i;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009136
9137 if (err < 0)
9138 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02009139 else if (!err)
9140 return 0; /* no config found */
9141
9142 err = alc_auto_add_mic_boost(codec);
9143 if (err < 0)
9144 return err;
9145
9146 /* hack - override the init verbs */
9147 spec->init_verbs[0] = alc883_auto_init_verbs;
Takashi Iwai776e1842007-08-29 15:07:11 +02009148
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009149 /* setup input_mux for ALC889 */
9150 if (codec->vendor_id == 0x10ec0889) {
9151 /* digital-mic input pin is excluded in alc880_auto_create..()
9152 * because it's under 0x18
9153 */
9154 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
9155 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
9156 struct hda_input_mux *imux = &spec->private_imux[0];
9157 for (i = 1; i < 3; i++)
9158 memcpy(&spec->private_imux[i],
9159 &spec->private_imux[0],
9160 sizeof(spec->private_imux[0]));
9161 imux->items[imux->num_items].label = "Int DMic";
9162 imux->items[imux->num_items].index = 0x0b;
9163 imux->num_items++;
9164 spec->num_mux_defs = 3;
9165 spec->input_mux = spec->private_imux;
9166 }
9167 }
9168
Takashi Iwai776e1842007-08-29 15:07:11 +02009169 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009170}
9171
9172/* additional initialization for auto-configuration model */
9173static void alc883_auto_init(struct hda_codec *codec)
9174{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009175 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009176 alc883_auto_init_multi_out(codec);
9177 alc883_auto_init_hp_out(codec);
9178 alc883_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02009179 alc883_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009180 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02009181 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009182}
9183
9184static int patch_alc883(struct hda_codec *codec)
9185{
9186 struct alc_spec *spec;
9187 int err, board_config;
9188
9189 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
9190 if (spec == NULL)
9191 return -ENOMEM;
9192
9193 codec->spec = spec;
9194
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02009195 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
9196
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009197 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
9198 alc883_models,
9199 alc883_cfg_tbl);
9200 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +02009201 printk(KERN_INFO "hda_codec: Unknown model for %s, "
9202 "trying auto-probe from BIOS...\n", codec->chip_name);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009203 board_config = ALC883_AUTO;
9204 }
9205
9206 if (board_config == ALC883_AUTO) {
9207 /* automatic parse from the BIOS config */
9208 err = alc883_parse_auto_config(codec);
9209 if (err < 0) {
9210 alc_free(codec);
9211 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009212 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009213 printk(KERN_INFO
9214 "hda_codec: Cannot set up configuration "
9215 "from BIOS. Using base mode...\n");
9216 board_config = ALC883_3ST_2ch_DIG;
9217 }
9218 }
9219
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09009220 err = snd_hda_attach_beep_device(codec, 0x1);
9221 if (err < 0) {
9222 alc_free(codec);
9223 return err;
9224 }
9225
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009226 if (board_config != ALC883_AUTO)
9227 setup_preset(spec, &alc883_presets[board_config]);
9228
Kailang Yang2f893282008-05-27 12:14:47 +02009229 switch (codec->vendor_id) {
9230 case 0x10ec0888:
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009231 if (!spec->num_adc_nids) {
9232 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
9233 spec->adc_nids = alc883_adc_nids;
9234 }
9235 if (!spec->capsrc_nids)
9236 spec->capsrc_nids = alc883_capsrc_nids;
9237 spec->capture_style = CAPT_MIX; /* matrix-style capture */
Takashi Iwai4a79ba32009-04-22 16:31:35 +02009238 spec->init_amp = ALC_INIT_DEFAULT; /* always initialize */
Kailang Yang2f893282008-05-27 12:14:47 +02009239 break;
9240 case 0x10ec0889:
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009241 if (!spec->num_adc_nids) {
9242 spec->num_adc_nids = ARRAY_SIZE(alc889_adc_nids);
9243 spec->adc_nids = alc889_adc_nids;
9244 }
9245 if (!spec->capsrc_nids)
9246 spec->capsrc_nids = alc889_capsrc_nids;
9247 spec->capture_style = CAPT_1MUX_MIX; /* 1mux/Nmix-style
9248 capture */
Kailang Yang2f893282008-05-27 12:14:47 +02009249 break;
9250 default:
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009251 if (!spec->num_adc_nids) {
9252 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
9253 spec->adc_nids = alc883_adc_nids;
9254 }
9255 if (!spec->capsrc_nids)
9256 spec->capsrc_nids = alc883_capsrc_nids;
9257 spec->capture_style = CAPT_MIX; /* matrix-style capture */
Kailang Yang2f893282008-05-27 12:14:47 +02009258 break;
9259 }
9260
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009261 spec->stream_analog_playback = &alc883_pcm_analog_playback;
9262 spec->stream_analog_capture = &alc883_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01009263 spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009264
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009265 spec->stream_digital_playback = &alc883_pcm_digital_playback;
9266 spec->stream_digital_capture = &alc883_pcm_digital_capture;
9267
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009268 if (!spec->cap_mixer)
9269 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01009270 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009271
Takashi Iwai2134ea42008-01-10 16:53:55 +01009272 spec->vmaster_nid = 0x0c;
9273
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009274 codec->patch_ops = alc_patch_ops;
9275 if (board_config == ALC883_AUTO)
9276 spec->init_hook = alc883_auto_init;
Kailang Yangf9423e72008-05-27 12:32:25 +02009277
Takashi Iwaicb53c622007-08-10 17:21:45 +02009278#ifdef CONFIG_SND_HDA_POWER_SAVE
9279 if (!spec->loopback.amplist)
9280 spec->loopback.amplist = alc883_loopbacks;
9281#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01009282 codec->proc_widget_hook = print_realtek_coef;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009283
9284 return 0;
9285}
9286
9287/*
Kailang Yangdf694da2005-12-05 19:42:22 +01009288 * ALC262 support
9289 */
9290
9291#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
9292#define ALC262_DIGIN_NID ALC880_DIGIN_NID
9293
9294#define alc262_dac_nids alc260_dac_nids
9295#define alc262_adc_nids alc882_adc_nids
9296#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +01009297#define alc262_capsrc_nids alc882_capsrc_nids
9298#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +01009299
9300#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01009301#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01009302
Kailang Yang4e555fe2008-08-26 13:05:55 +02009303static hda_nid_t alc262_dmic_adc_nids[1] = {
9304 /* ADC0 */
9305 0x09
9306};
9307
9308static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
9309
Kailang Yangdf694da2005-12-05 19:42:22 +01009310static struct snd_kcontrol_new alc262_base_mixer[] = {
9311 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9312 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9313 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9314 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9315 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9316 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9317 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9318 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009319 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009320 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9321 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009322 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009323 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
9324 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9325 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
9326 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009327 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01009328};
9329
Takashi Iwaice875f02008-01-28 18:17:43 +01009330/* update HP, line and mono-out pins according to the master switch */
9331static void alc262_hp_master_update(struct hda_codec *codec)
9332{
9333 struct alc_spec *spec = codec->spec;
9334 int val = spec->master_sw;
9335
9336 /* HP & line-out */
9337 snd_hda_codec_write_cache(codec, 0x1b, 0,
9338 AC_VERB_SET_PIN_WIDGET_CONTROL,
9339 val ? PIN_HP : 0);
9340 snd_hda_codec_write_cache(codec, 0x15, 0,
9341 AC_VERB_SET_PIN_WIDGET_CONTROL,
9342 val ? PIN_HP : 0);
9343 /* mono (speaker) depending on the HP jack sense */
9344 val = val && !spec->jack_present;
9345 snd_hda_codec_write_cache(codec, 0x16, 0,
9346 AC_VERB_SET_PIN_WIDGET_CONTROL,
9347 val ? PIN_OUT : 0);
9348}
9349
9350static void alc262_hp_bpc_automute(struct hda_codec *codec)
9351{
9352 struct alc_spec *spec = codec->spec;
9353 unsigned int presence;
9354 presence = snd_hda_codec_read(codec, 0x1b, 0,
9355 AC_VERB_GET_PIN_SENSE, 0);
9356 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9357 alc262_hp_master_update(codec);
9358}
9359
9360static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
9361{
9362 if ((res >> 26) != ALC880_HP_EVENT)
9363 return;
9364 alc262_hp_bpc_automute(codec);
9365}
9366
9367static void alc262_hp_wildwest_automute(struct hda_codec *codec)
9368{
9369 struct alc_spec *spec = codec->spec;
9370 unsigned int presence;
9371 presence = snd_hda_codec_read(codec, 0x15, 0,
9372 AC_VERB_GET_PIN_SENSE, 0);
9373 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9374 alc262_hp_master_update(codec);
9375}
9376
9377static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
9378 unsigned int res)
9379{
9380 if ((res >> 26) != ALC880_HP_EVENT)
9381 return;
9382 alc262_hp_wildwest_automute(codec);
9383}
9384
Takashi Iwaib72519b2009-05-08 14:31:55 +02009385#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +01009386
9387static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
9388 struct snd_ctl_elem_value *ucontrol)
9389{
9390 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9391 struct alc_spec *spec = codec->spec;
9392 int val = !!*ucontrol->value.integer.value;
9393
9394 if (val == spec->master_sw)
9395 return 0;
9396 spec->master_sw = val;
9397 alc262_hp_master_update(codec);
9398 return 1;
9399}
9400
Takashi Iwaib72519b2009-05-08 14:31:55 +02009401#define ALC262_HP_MASTER_SWITCH \
9402 { \
9403 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
9404 .name = "Master Playback Switch", \
9405 .info = snd_ctl_boolean_mono_info, \
9406 .get = alc262_hp_master_sw_get, \
9407 .put = alc262_hp_master_sw_put, \
9408 }
9409
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009410static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +02009411 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009412 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9413 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9414 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009415 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9416 HDA_OUTPUT),
9417 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9418 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009419 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9420 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009421 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009422 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9423 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009424 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009425 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9426 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9427 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9428 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009429 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
9430 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
9431 { } /* end */
9432};
9433
Kailang Yangcd7509a2007-01-26 18:33:17 +01009434static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +02009435 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +01009436 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9437 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9438 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9439 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009440 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9441 HDA_OUTPUT),
9442 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9443 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009444 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
9445 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009446 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009447 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9448 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9449 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9450 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009451 { } /* end */
9452};
9453
9454static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
9455 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9456 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009457 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009458 { } /* end */
9459};
9460
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009461/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009462static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009463{
9464 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009465
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009466 spec->autocfg.hp_pins[0] = 0x15;
9467 spec->autocfg.speaker_pins[0] = 0x0c; /* HACK: not actually a pin */
9468 alc_automute_amp(codec);
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009469}
9470
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009471static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +01009472 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9473 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009474 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9475 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9476 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9477 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9478 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9479 { } /* end */
9480};
9481
9482static struct hda_verb alc262_hp_t5735_verbs[] = {
9483 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9484 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9485
9486 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9487 { }
9488};
9489
Kailang Yang8c427222008-01-10 13:03:59 +01009490static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +01009491 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9492 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01009493 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
9494 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +01009495 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9496 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9497 { } /* end */
9498};
9499
9500static struct hda_verb alc262_hp_rp5700_verbs[] = {
9501 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9502 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9503 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9504 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9505 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9506 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9507 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9508 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9509 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9510 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9511 {}
9512};
9513
9514static struct hda_input_mux alc262_hp_rp5700_capture_source = {
9515 .num_items = 1,
9516 .items = {
9517 { "Line", 0x1 },
9518 },
9519};
9520
Takashi Iwai42171c12009-05-08 14:11:43 +02009521/* bind hp and internal speaker mute (with plug check) as master switch */
9522static void alc262_hippo_master_update(struct hda_codec *codec)
9523{
9524 struct alc_spec *spec = codec->spec;
9525 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
9526 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
9527 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
9528 unsigned int mute;
9529
9530 /* HP */
9531 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
9532 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
9533 HDA_AMP_MUTE, mute);
9534 /* mute internal speaker per jack sense */
9535 if (spec->jack_present)
9536 mute = HDA_AMP_MUTE;
9537 if (line_nid)
9538 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
9539 HDA_AMP_MUTE, mute);
9540 if (speaker_nid && speaker_nid != line_nid)
9541 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
9542 HDA_AMP_MUTE, mute);
9543}
9544
9545#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
9546
9547static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
9548 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +02009549{
9550 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +02009551 struct alc_spec *spec = codec->spec;
9552 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +02009553
Takashi Iwai42171c12009-05-08 14:11:43 +02009554 if (val == spec->master_sw)
9555 return 0;
9556 spec->master_sw = val;
9557 alc262_hippo_master_update(codec);
9558 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +02009559}
Takashi Iwai5b319542007-07-26 11:49:22 +02009560
Takashi Iwai42171c12009-05-08 14:11:43 +02009561#define ALC262_HIPPO_MASTER_SWITCH \
9562 { \
9563 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
9564 .name = "Master Playback Switch", \
9565 .info = snd_ctl_boolean_mono_info, \
9566 .get = alc262_hippo_master_sw_get, \
9567 .put = alc262_hippo_master_sw_put, \
9568 }
9569
9570static struct snd_kcontrol_new alc262_hippo_mixer[] = {
9571 ALC262_HIPPO_MASTER_SWITCH,
9572 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9573 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9574 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9575 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9576 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9577 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9578 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9579 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9580 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9581 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9582 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9583 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9584 { } /* end */
9585};
9586
9587static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
9588 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9589 ALC262_HIPPO_MASTER_SWITCH,
9590 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9591 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9592 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9593 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9594 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9595 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9596 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9597 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9598 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9599 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9600 { } /* end */
9601};
9602
9603/* mute/unmute internal speaker according to the hp jack and mute state */
9604static void alc262_hippo_automute(struct hda_codec *codec)
9605{
9606 struct alc_spec *spec = codec->spec;
9607 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
9608 unsigned int present;
9609
9610 /* need to execute and sync at first */
9611 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
9612 present = snd_hda_codec_read(codec, hp_nid, 0,
9613 AC_VERB_GET_PIN_SENSE, 0);
9614 spec->jack_present = (present & 0x80000000) != 0;
9615 alc262_hippo_master_update(codec);
9616}
9617
9618static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
9619{
9620 if ((res >> 26) != ALC880_HP_EVENT)
9621 return;
9622 alc262_hippo_automute(codec);
9623}
9624
9625static void alc262_hippo_init_hook(struct hda_codec *codec)
9626{
9627 struct alc_spec *spec = codec->spec;
9628
9629 spec->autocfg.hp_pins[0] = 0x15;
9630 spec->autocfg.speaker_pins[0] = 0x14;
9631 alc262_hippo_automute(codec);
9632}
9633
9634static void alc262_hippo1_init_hook(struct hda_codec *codec)
9635{
9636 struct alc_spec *spec = codec->spec;
9637
9638 spec->autocfg.hp_pins[0] = 0x1b;
9639 spec->autocfg.speaker_pins[0] = 0x14;
9640 alc262_hippo_automute(codec);
9641}
9642
9643
Kailang Yang272a5272007-05-14 11:00:38 +02009644static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +02009645 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +02009646 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +02009647 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9648 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9649 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9650 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9651 { } /* end */
9652};
9653
Kailang Yang83c34212007-07-05 11:43:05 +02009654static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +02009655 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9656 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +02009657 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9658 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9659 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9660 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9661 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9662 { } /* end */
9663};
Kailang Yang272a5272007-05-14 11:00:38 +02009664
Tony Vroonba340e82009-02-02 19:01:30 +00009665static struct snd_kcontrol_new alc262_tyan_mixer[] = {
9666 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9667 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
9668 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
9669 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
9670 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9671 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9672 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9673 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9674 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9675 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9676 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9677 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9678 { } /* end */
9679};
9680
9681static struct hda_verb alc262_tyan_verbs[] = {
9682 /* Headphone automute */
9683 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9684 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9685 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9686
9687 /* P11 AUX_IN, white 4-pin connector */
9688 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9689 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
9690 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
9691 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
9692
9693 {}
9694};
9695
9696/* unsolicited event for HP jack sensing */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009697static void alc262_tyan_init_hook(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +00009698{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009699 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +00009700
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009701 spec->autocfg.hp_pins[0] = 0x1b;
9702 spec->autocfg.speaker_pins[0] = 0x15;
9703 alc_automute_amp(codec);
Tony Vroonba340e82009-02-02 19:01:30 +00009704}
9705
Tony Vroonba340e82009-02-02 19:01:30 +00009706
Kailang Yangdf694da2005-12-05 19:42:22 +01009707#define alc262_capture_mixer alc882_capture_mixer
9708#define alc262_capture_alt_mixer alc882_capture_alt_mixer
9709
9710/*
9711 * generic initialization of ADC, input mixers and output mixers
9712 */
9713static struct hda_verb alc262_init_verbs[] = {
9714 /*
9715 * Unmute ADC0-2 and set the default input to mic-in
9716 */
9717 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9718 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9719 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9720 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9721 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9722 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9723
Takashi Iwaicb53c622007-08-10 17:21:45 +02009724 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01009725 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009726 * Note: PASD motherboards uses the Line In 2 as the input for
9727 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01009728 */
9729 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009730 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9731 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9732 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9733 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9734 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009735
9736 /*
9737 * Set up output mixers (0x0c - 0x0e)
9738 */
9739 /* set vol=0 to output mixers */
9740 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9741 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9742 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9743 /* set up input amps for analog loopback */
9744 /* Amp Indices: DAC = 0, mixer = 1 */
9745 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9746 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9747 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9748 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9749 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9750 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9751
9752 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9753 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9754 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9755 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9756 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9757 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9758
9759 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9760 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9761 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9762 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9763 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +02009764
Kailang Yangdf694da2005-12-05 19:42:22 +01009765 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9766 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +02009767
Kailang Yangdf694da2005-12-05 19:42:22 +01009768 /* FIXME: use matrix-type input source selection */
9769 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9770 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9771 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9772 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9773 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9774 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9775 /* Input mixer2 */
9776 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9777 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9778 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9779 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9780 /* Input mixer3 */
9781 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9782 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9783 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009784 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +01009785
9786 { }
9787};
9788
Kailang Yang4e555fe2008-08-26 13:05:55 +02009789static struct hda_verb alc262_eapd_verbs[] = {
9790 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
9791 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
9792 { }
9793};
9794
Kailang Yangccc656c2006-10-17 12:32:26 +02009795static struct hda_verb alc262_hippo_unsol_verbs[] = {
9796 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9797 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9798 {}
9799};
9800
9801static struct hda_verb alc262_hippo1_unsol_verbs[] = {
9802 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9803 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9804 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9805
9806 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9807 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9808 {}
9809};
9810
Kailang Yang272a5272007-05-14 11:00:38 +02009811static struct hda_verb alc262_sony_unsol_verbs[] = {
9812 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9813 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9814 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
9815
9816 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9817 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +09009818 {}
Kailang Yang272a5272007-05-14 11:00:38 +02009819};
9820
Kailang Yang4e555fe2008-08-26 13:05:55 +02009821static struct hda_input_mux alc262_dmic_capture_source = {
9822 .num_items = 2,
9823 .items = {
9824 { "Int DMic", 0x9 },
9825 { "Mic", 0x0 },
9826 },
9827};
9828
9829static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
9830 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9831 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9832 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9833 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9834 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +02009835 { } /* end */
9836};
9837
9838static struct hda_verb alc262_toshiba_s06_verbs[] = {
9839 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9840 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9841 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9842 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9843 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
9844 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9845 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
9846 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9847 {}
9848};
9849
9850static void alc262_dmic_automute(struct hda_codec *codec)
9851{
9852 unsigned int present;
9853
9854 present = snd_hda_codec_read(codec, 0x18, 0,
9855 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9856 snd_hda_codec_write(codec, 0x22, 0,
9857 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x09);
9858}
9859
Kailang Yang4e555fe2008-08-26 13:05:55 +02009860
9861/* unsolicited event for HP jack sensing */
9862static void alc262_toshiba_s06_unsol_event(struct hda_codec *codec,
9863 unsigned int res)
9864{
Kailang Yang4e555fe2008-08-26 13:05:55 +02009865 if ((res >> 26) == ALC880_MIC_EVENT)
9866 alc262_dmic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009867 else
9868 alc_sku_unsol_event(codec, res);
Kailang Yang4e555fe2008-08-26 13:05:55 +02009869}
9870
9871static void alc262_toshiba_s06_init_hook(struct hda_codec *codec)
9872{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009873 struct alc_spec *spec = codec->spec;
9874
9875 spec->autocfg.hp_pins[0] = 0x15;
9876 spec->autocfg.speaker_pins[0] = 0x14;
9877 alc_automute_pin(codec);
Kailang Yang4e555fe2008-08-26 13:05:55 +02009878 alc262_dmic_automute(codec);
9879}
9880
Takashi Iwai834be882006-03-01 14:16:17 +01009881/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +02009882 * nec model
9883 * 0x15 = headphone
9884 * 0x16 = internal speaker
9885 * 0x18 = external mic
9886 */
9887
9888static struct snd_kcontrol_new alc262_nec_mixer[] = {
9889 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
9890 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
9891
9892 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9893 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9894 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9895
9896 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9897 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9898 { } /* end */
9899};
9900
9901static struct hda_verb alc262_nec_verbs[] = {
9902 /* Unmute Speaker */
9903 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9904
9905 /* Headphone */
9906 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9907 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9908
9909 /* External mic to headphone */
9910 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9911 /* External mic to speaker */
9912 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9913 {}
9914};
9915
9916/*
Takashi Iwai834be882006-03-01 14:16:17 +01009917 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +01009918 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
9919 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +01009920 */
9921
9922#define ALC_HP_EVENT 0x37
9923
9924static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
9925 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9926 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +01009927 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9928 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +01009929 {}
9930};
9931
Jiang zhe0e31daf2008-03-20 12:12:39 +01009932static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
9933 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9934 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9935 {}
9936};
9937
Takashi Iwai834be882006-03-01 14:16:17 +01009938static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009939 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +01009940 .items = {
9941 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009942 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +01009943 { "CD", 0x4 },
9944 },
9945};
9946
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009947static struct hda_input_mux alc262_HP_capture_source = {
9948 .num_items = 5,
9949 .items = {
9950 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +02009951 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009952 { "Line", 0x2 },
9953 { "CD", 0x4 },
9954 { "AUX IN", 0x6 },
9955 },
9956};
9957
zhejiangaccbe492007-08-31 12:36:05 +02009958static struct hda_input_mux alc262_HP_D7000_capture_source = {
9959 .num_items = 4,
9960 .items = {
9961 { "Mic", 0x0 },
9962 { "Front Mic", 0x2 },
9963 { "Line", 0x1 },
9964 { "CD", 0x4 },
9965 },
9966};
9967
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009968/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +01009969static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
9970{
9971 struct alc_spec *spec = codec->spec;
9972 unsigned int mute;
9973
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009974 if (force || !spec->sense_updated) {
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009975 unsigned int present;
Takashi Iwai834be882006-03-01 14:16:17 +01009976 /* need to execute and sync at first */
9977 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009978 /* check laptop HP jack */
9979 present = snd_hda_codec_read(codec, 0x14, 0,
9980 AC_VERB_GET_PIN_SENSE, 0);
9981 /* need to execute and sync at first */
9982 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9983 /* check docking HP jack */
9984 present |= snd_hda_codec_read(codec, 0x1b, 0,
9985 AC_VERB_GET_PIN_SENSE, 0);
9986 if (present & AC_PINSENSE_PRESENCE)
9987 spec->jack_present = 1;
9988 else
9989 spec->jack_present = 0;
Takashi Iwai834be882006-03-01 14:16:17 +01009990 spec->sense_updated = 1;
9991 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009992 /* unmute internal speaker only if both HPs are unplugged and
9993 * master switch is on
9994 */
9995 if (spec->jack_present)
9996 mute = HDA_AMP_MUTE;
9997 else
Takashi Iwai834be882006-03-01 14:16:17 +01009998 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009999 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10000 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010010001}
10002
10003/* unsolicited event for HP jack sensing */
10004static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
10005 unsigned int res)
10006{
10007 if ((res >> 26) != ALC_HP_EVENT)
10008 return;
10009 alc262_fujitsu_automute(codec, 1);
10010}
10011
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010012static void alc262_fujitsu_init_hook(struct hda_codec *codec)
10013{
10014 alc262_fujitsu_automute(codec, 1);
10015}
10016
Takashi Iwai834be882006-03-01 14:16:17 +010010017/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020010018static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
10019 .ops = &snd_hda_bind_vol,
10020 .values = {
10021 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
10022 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
10023 0
10024 },
10025};
Takashi Iwai834be882006-03-01 14:16:17 +010010026
Jiang zhe0e31daf2008-03-20 12:12:39 +010010027/* mute/unmute internal speaker according to the hp jack and mute state */
10028static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
10029{
10030 struct alc_spec *spec = codec->spec;
10031 unsigned int mute;
10032
10033 if (force || !spec->sense_updated) {
10034 unsigned int present_int_hp;
10035 /* need to execute and sync at first */
10036 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10037 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
10038 AC_VERB_GET_PIN_SENSE, 0);
10039 spec->jack_present = (present_int_hp & 0x80000000) != 0;
10040 spec->sense_updated = 1;
10041 }
10042 if (spec->jack_present) {
10043 /* mute internal speaker */
10044 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10045 HDA_AMP_MUTE, HDA_AMP_MUTE);
10046 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10047 HDA_AMP_MUTE, HDA_AMP_MUTE);
10048 } else {
10049 /* unmute internal speaker if necessary */
10050 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
10051 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10052 HDA_AMP_MUTE, mute);
10053 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10054 HDA_AMP_MUTE, mute);
10055 }
10056}
10057
10058/* unsolicited event for HP jack sensing */
10059static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
10060 unsigned int res)
10061{
10062 if ((res >> 26) != ALC_HP_EVENT)
10063 return;
10064 alc262_lenovo_3000_automute(codec, 1);
10065}
10066
Takashi Iwai834be882006-03-01 14:16:17 +010010067/* bind hp and internal speaker mute (with plug check) */
10068static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
10069 struct snd_ctl_elem_value *ucontrol)
10070{
10071 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10072 long *valp = ucontrol->value.integer.value;
10073 int change;
10074
Tony Vroon5d9fab22008-03-14 17:09:18 +010010075 change = snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10076 HDA_AMP_MUTE,
10077 valp ? 0 : HDA_AMP_MUTE);
10078 change |= snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
10079 HDA_AMP_MUTE,
10080 valp ? 0 : HDA_AMP_MUTE);
10081
Takashi Iwai82beb8f2007-08-10 17:09:26 +020010082 if (change)
10083 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010010084 return change;
10085}
10086
10087static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020010088 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010010089 {
10090 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10091 .name = "Master Playback Switch",
10092 .info = snd_hda_mixer_amp_switch_info,
10093 .get = snd_hda_mixer_amp_switch_get,
10094 .put = alc262_fujitsu_master_sw_put,
10095 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10096 },
10097 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10098 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10099 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10100 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10101 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010102 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10103 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10104 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010010105 { } /* end */
10106};
10107
Jiang zhe0e31daf2008-03-20 12:12:39 +010010108/* bind hp and internal speaker mute (with plug check) */
10109static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
10110 struct snd_ctl_elem_value *ucontrol)
10111{
10112 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10113 long *valp = ucontrol->value.integer.value;
10114 int change;
10115
10116 change = snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
10117 HDA_AMP_MUTE,
10118 valp ? 0 : HDA_AMP_MUTE);
10119
10120 if (change)
10121 alc262_lenovo_3000_automute(codec, 0);
10122 return change;
10123}
10124
10125static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
10126 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10127 {
10128 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10129 .name = "Master Playback Switch",
10130 .info = snd_hda_mixer_amp_switch_info,
10131 .get = snd_hda_mixer_amp_switch_get,
10132 .put = alc262_lenovo_3000_master_sw_put,
10133 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
10134 },
10135 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10136 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10137 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10138 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10139 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10140 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10141 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10142 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10143 { } /* end */
10144};
10145
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010146static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
10147 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020010148 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010149 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10150 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10151 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10152 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10153 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10154 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10155 { } /* end */
10156};
10157
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010158/* additional init verbs for Benq laptops */
10159static struct hda_verb alc262_EAPD_verbs[] = {
10160 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10161 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
10162 {}
10163};
10164
Kailang Yang83c34212007-07-05 11:43:05 +020010165static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
10166 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10167 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10168
10169 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10170 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
10171 {}
10172};
10173
Tobin Davisf651b502007-10-26 12:40:47 +020010174/* Samsung Q1 Ultra Vista model setup */
10175static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010176 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10177 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010178 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10179 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10180 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010181 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010182 { } /* end */
10183};
10184
10185static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010186 /* output mixer */
10187 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10188 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10189 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10190 /* speaker */
10191 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10192 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10193 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10194 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10195 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020010196 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010197 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10198 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10199 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10200 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10201 /* internal mic */
10202 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10203 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10204 /* ADC, choose mic */
10205 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10206 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10207 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10208 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10209 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10210 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10211 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10212 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10213 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
10214 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020010215 {}
10216};
10217
Tobin Davisf651b502007-10-26 12:40:47 +020010218/* mute/unmute internal speaker according to the hp jack and mute state */
10219static void alc262_ultra_automute(struct hda_codec *codec)
10220{
10221 struct alc_spec *spec = codec->spec;
10222 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020010223
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010224 mute = 0;
10225 /* auto-mute only when HP is used as HP */
10226 if (!spec->cur_mux[0]) {
10227 unsigned int present;
10228 /* need to execute and sync at first */
10229 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
10230 present = snd_hda_codec_read(codec, 0x15, 0,
10231 AC_VERB_GET_PIN_SENSE, 0);
10232 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
10233 if (spec->jack_present)
10234 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020010235 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010236 /* mute/unmute internal speaker */
10237 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10238 HDA_AMP_MUTE, mute);
10239 /* mute/unmute HP */
10240 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10241 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020010242}
10243
10244/* unsolicited event for HP jack sensing */
10245static void alc262_ultra_unsol_event(struct hda_codec *codec,
10246 unsigned int res)
10247{
10248 if ((res >> 26) != ALC880_HP_EVENT)
10249 return;
10250 alc262_ultra_automute(codec);
10251}
10252
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010253static struct hda_input_mux alc262_ultra_capture_source = {
10254 .num_items = 2,
10255 .items = {
10256 { "Mic", 0x1 },
10257 { "Headphone", 0x7 },
10258 },
10259};
10260
10261static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
10262 struct snd_ctl_elem_value *ucontrol)
10263{
10264 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10265 struct alc_spec *spec = codec->spec;
10266 int ret;
10267
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010268 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010269 if (!ret)
10270 return 0;
10271 /* reprogram the HP pin as mic or HP according to the input source */
10272 snd_hda_codec_write_cache(codec, 0x15, 0,
10273 AC_VERB_SET_PIN_WIDGET_CONTROL,
10274 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
10275 alc262_ultra_automute(codec); /* mute/unmute HP */
10276 return ret;
10277}
10278
10279static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
10280 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10281 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10282 {
10283 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10284 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010285 .info = alc_mux_enum_info,
10286 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010287 .put = alc262_ultra_mux_enum_put,
10288 },
10289 { } /* end */
10290};
10291
Kailang Yangdf694da2005-12-05 19:42:22 +010010292/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010293static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
10294 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010010295{
10296 hda_nid_t nid;
10297 int err;
10298
10299 spec->multiout.num_dacs = 1; /* only use one dac */
10300 spec->multiout.dac_nids = spec->private_dac_nids;
10301 spec->multiout.dac_nids[0] = 2;
10302
10303 nid = cfg->line_out_pins[0];
10304 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010305 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10306 "Front Playback Volume",
10307 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
10308 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010309 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010310 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10311 "Front Playback Switch",
10312 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
10313 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010314 return err;
10315 }
10316
Takashi Iwai82bc9552006-03-21 11:24:42 +010010317 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010318 if (nid) {
10319 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010320 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10321 "Speaker Playback Volume",
10322 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10323 HDA_OUTPUT));
10324 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010325 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010326 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10327 "Speaker Playback Switch",
10328 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10329 HDA_OUTPUT));
10330 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010331 return err;
10332 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010333 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10334 "Speaker Playback Switch",
10335 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10336 HDA_OUTPUT));
10337 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010338 return err;
10339 }
10340 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +020010341 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010342 if (nid) {
10343 /* spec->multiout.hp_nid = 2; */
10344 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010345 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10346 "Headphone Playback Volume",
10347 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10348 HDA_OUTPUT));
10349 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010350 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010351 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10352 "Headphone Playback Switch",
10353 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10354 HDA_OUTPUT));
10355 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010356 return err;
10357 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010358 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10359 "Headphone Playback Switch",
10360 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10361 HDA_OUTPUT));
10362 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010363 return err;
10364 }
10365 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010366 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010010367}
10368
10369/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010370#define alc262_auto_create_analog_input_ctls \
10371 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010010372
10373/*
10374 * generic initialization of ADC, input mixers and output mixers
10375 */
10376static struct hda_verb alc262_volume_init_verbs[] = {
10377 /*
10378 * Unmute ADC0-2 and set the default input to mic-in
10379 */
10380 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10381 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10382 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10383 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10384 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10385 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10386
Takashi Iwaicb53c622007-08-10 17:21:45 +020010387 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010388 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010389 * Note: PASD motherboards uses the Line In 2 as the input for
10390 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010391 */
10392 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010393 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10394 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10395 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10396 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10397 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010398
10399 /*
10400 * Set up output mixers (0x0c - 0x0f)
10401 */
10402 /* set vol=0 to output mixers */
10403 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10404 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10405 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020010406
Kailang Yangdf694da2005-12-05 19:42:22 +010010407 /* set up input amps for analog loopback */
10408 /* Amp Indices: DAC = 0, mixer = 1 */
10409 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10410 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10411 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10412 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10413 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10414 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10415
10416 /* FIXME: use matrix-type input source selection */
10417 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10418 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10419 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10420 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10421 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10422 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10423 /* Input mixer2 */
10424 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10425 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10426 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10427 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10428 /* Input mixer3 */
10429 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10430 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10431 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10432 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10433
10434 { }
10435};
10436
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010437static struct hda_verb alc262_HP_BPC_init_verbs[] = {
10438 /*
10439 * Unmute ADC0-2 and set the default input to mic-in
10440 */
10441 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10442 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10443 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10444 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10445 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10446 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10447
Takashi Iwaicb53c622007-08-10 17:21:45 +020010448 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010449 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010450 * Note: PASD motherboards uses the Line In 2 as the input for
10451 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010452 */
10453 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010454 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10455 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10456 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10457 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10458 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10459 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10460 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020010461
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010462 /*
10463 * Set up output mixers (0x0c - 0x0e)
10464 */
10465 /* set vol=0 to output mixers */
10466 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10467 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10468 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10469
10470 /* set up input amps for analog loopback */
10471 /* Amp Indices: DAC = 0, mixer = 1 */
10472 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10473 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10474 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10475 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10476 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10477 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10478
Takashi Iwaice875f02008-01-28 18:17:43 +010010479 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010480 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10481 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10482
10483 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10484 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10485
10486 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10487 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10488
10489 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10490 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10491 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10492 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10493 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10494
10495 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10496 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10497 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10498 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10499 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10500 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10501
10502
10503 /* FIXME: use matrix-type input source selection */
10504 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10505 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10506 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10507 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10508 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10509 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10510 /* Input mixer2 */
10511 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10512 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10513 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10514 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10515 /* Input mixer3 */
10516 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10517 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10518 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10519 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10520
Takashi Iwaice875f02008-01-28 18:17:43 +010010521 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10522
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010523 { }
10524};
10525
Kailang Yangcd7509a2007-01-26 18:33:17 +010010526static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
10527 /*
10528 * Unmute ADC0-2 and set the default input to mic-in
10529 */
10530 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10531 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10532 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10533 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10534 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10535 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10536
Takashi Iwaicb53c622007-08-10 17:21:45 +020010537 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010010538 * mixer widget
10539 * Note: PASD motherboards uses the Line In 2 as the input for front
10540 * panel mic (mic 2)
10541 */
10542 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010543 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10544 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10545 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10546 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10547 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10548 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10549 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10550 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010010551 /*
10552 * Set up output mixers (0x0c - 0x0e)
10553 */
10554 /* set vol=0 to output mixers */
10555 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10556 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10557 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10558
10559 /* set up input amps for analog loopback */
10560 /* Amp Indices: DAC = 0, mixer = 1 */
10561 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10562 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10563 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10564 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10565 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10566 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10567
10568
10569 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
10570 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
10571 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
10572 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
10573 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10574 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
10575 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
10576
10577 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10578 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10579
10580 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10581 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
10582
10583 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
10584 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10585 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10586 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10587 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10588 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10589
10590 /* FIXME: use matrix-type input source selection */
10591 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10592 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10593 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
10594 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
10595 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
10596 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
10597 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
10598 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10599 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
10600 /* Input mixer2 */
10601 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10602 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10603 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10604 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10605 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10606 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10607 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10608 /* Input mixer3 */
10609 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10610 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10611 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10612 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10613 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10614 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10615 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10616
Takashi Iwaice875f02008-01-28 18:17:43 +010010617 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10618
Kailang Yangcd7509a2007-01-26 18:33:17 +010010619 { }
10620};
10621
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010622static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
10623
10624 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
10625 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10626 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
10627
10628 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
10629 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10630 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10631 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10632
10633 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
10634 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10635 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10636 {}
10637};
10638
10639
Takashi Iwaicb53c622007-08-10 17:21:45 +020010640#ifdef CONFIG_SND_HDA_POWER_SAVE
10641#define alc262_loopbacks alc880_loopbacks
10642#endif
10643
Kailang Yangdf694da2005-12-05 19:42:22 +010010644/* pcm configuration: identiacal with ALC880 */
10645#define alc262_pcm_analog_playback alc880_pcm_analog_playback
10646#define alc262_pcm_analog_capture alc880_pcm_analog_capture
10647#define alc262_pcm_digital_playback alc880_pcm_digital_playback
10648#define alc262_pcm_digital_capture alc880_pcm_digital_capture
10649
10650/*
10651 * BIOS auto configuration
10652 */
10653static int alc262_parse_auto_config(struct hda_codec *codec)
10654{
10655 struct alc_spec *spec = codec->spec;
10656 int err;
10657 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
10658
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010659 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10660 alc262_ignore);
10661 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010662 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010663 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010010664 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010665 spec->multiout.max_channels = 2;
10666 spec->no_analog = 1;
10667 goto dig_only;
10668 }
Kailang Yangdf694da2005-12-05 19:42:22 +010010669 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010670 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010671 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
10672 if (err < 0)
10673 return err;
10674 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
10675 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010676 return err;
10677
10678 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10679
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010680 dig_only:
Takashi Iwai0852d7a2009-02-11 11:35:15 +010010681 if (spec->autocfg.dig_outs) {
Kailang Yangdf694da2005-12-05 19:42:22 +010010682 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
Takashi Iwai0852d7a2009-02-11 11:35:15 +010010683 spec->dig_out_type = spec->autocfg.dig_out_type[0];
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010684 }
Kailang Yangdf694da2005-12-05 19:42:22 +010010685 if (spec->autocfg.dig_in_pin)
10686 spec->dig_in_nid = ALC262_DIGIN_NID;
10687
Takashi Iwai603c4012008-07-30 15:01:44 +020010688 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010010689 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010010690
Takashi Iwaid88897e2008-10-31 15:01:37 +010010691 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020010692 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020010693 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010694
Takashi Iwai776e1842007-08-29 15:07:11 +020010695 err = alc_auto_add_mic_boost(codec);
10696 if (err < 0)
10697 return err;
10698
Takashi Iwai4a79ba32009-04-22 16:31:35 +020010699 alc_ssid_check(codec, 0x15, 0x14, 0x1b);
10700
Kailang Yangdf694da2005-12-05 19:42:22 +010010701 return 1;
10702}
10703
10704#define alc262_auto_init_multi_out alc882_auto_init_multi_out
10705#define alc262_auto_init_hp_out alc882_auto_init_hp_out
10706#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020010707#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010010708
10709
10710/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010711static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010010712{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010713 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010010714 alc262_auto_init_multi_out(codec);
10715 alc262_auto_init_hp_out(codec);
10716 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020010717 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010718 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020010719 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010010720}
10721
10722/*
10723 * configuration and preset
10724 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010725static const char *alc262_models[ALC262_MODEL_LAST] = {
10726 [ALC262_BASIC] = "basic",
10727 [ALC262_HIPPO] = "hippo",
10728 [ALC262_HIPPO_1] = "hippo_1",
10729 [ALC262_FUJITSU] = "fujitsu",
10730 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010010731 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010010732 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010010733 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010734 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020010735 [ALC262_BENQ_T31] = "benq-t31",
10736 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020010737 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010738 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020010739 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010010740 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010741 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000010742 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010743 [ALC262_AUTO] = "auto",
10744};
10745
10746static struct snd_pci_quirk alc262_cfg_tbl[] = {
10747 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010748 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010010749 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
10750 ALC262_HP_BPC),
10751 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
10752 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010010753 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
10754 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010755 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010756 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010757 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010758 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010759 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010760 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010761 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010762 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010763 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
10764 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
10765 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010766 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
10767 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010010768 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010769 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010770 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010771 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010010772 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwaif872a912009-02-26 00:57:01 +010010773 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
10774 ALC262_SONY_ASSAMD),
Akio Idehara36ca6e12008-06-09 22:57:40 +090010775 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010776 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020010777 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010778 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010010779 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000010780 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010010781 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
10782 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110010783 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010010784 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010785 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020010786 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010787 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010010788 {}
10789};
10790
10791static struct alc_config_preset alc262_presets[] = {
10792 [ALC262_BASIC] = {
10793 .mixers = { alc262_base_mixer },
10794 .init_verbs = { alc262_init_verbs },
10795 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10796 .dac_nids = alc262_dac_nids,
10797 .hp_nid = 0x03,
10798 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10799 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010010800 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010010801 },
Kailang Yangccc656c2006-10-17 12:32:26 +020010802 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020010803 .mixers = { alc262_hippo_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +020010804 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
10805 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10806 .dac_nids = alc262_dac_nids,
10807 .hp_nid = 0x03,
10808 .dig_out_nid = ALC262_DIGOUT_NID,
10809 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10810 .channel_mode = alc262_modes,
10811 .input_mux = &alc262_capture_source,
10812 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020010813 .init_hook = alc262_hippo_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +020010814 },
10815 [ALC262_HIPPO_1] = {
10816 .mixers = { alc262_hippo1_mixer },
10817 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
10818 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10819 .dac_nids = alc262_dac_nids,
10820 .hp_nid = 0x02,
10821 .dig_out_nid = ALC262_DIGOUT_NID,
10822 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10823 .channel_mode = alc262_modes,
10824 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020010825 .unsol_event = alc262_hippo_unsol_event,
10826 .init_hook = alc262_hippo1_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +020010827 },
Takashi Iwai834be882006-03-01 14:16:17 +010010828 [ALC262_FUJITSU] = {
10829 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010830 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
10831 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010010832 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10833 .dac_nids = alc262_dac_nids,
10834 .hp_nid = 0x03,
10835 .dig_out_nid = ALC262_DIGOUT_NID,
10836 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10837 .channel_mode = alc262_modes,
10838 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010839 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010840 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010010841 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010842 [ALC262_HP_BPC] = {
10843 .mixers = { alc262_HP_BPC_mixer },
10844 .init_verbs = { alc262_HP_BPC_init_verbs },
10845 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10846 .dac_nids = alc262_dac_nids,
10847 .hp_nid = 0x03,
10848 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10849 .channel_mode = alc262_modes,
10850 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010851 .unsol_event = alc262_hp_bpc_unsol_event,
10852 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010853 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010010854 [ALC262_HP_BPC_D7000_WF] = {
10855 .mixers = { alc262_HP_BPC_WildWest_mixer },
10856 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
10857 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10858 .dac_nids = alc262_dac_nids,
10859 .hp_nid = 0x03,
10860 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10861 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020010862 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010863 .unsol_event = alc262_hp_wildwest_unsol_event,
10864 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010865 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010010866 [ALC262_HP_BPC_D7000_WL] = {
10867 .mixers = { alc262_HP_BPC_WildWest_mixer,
10868 alc262_HP_BPC_WildWest_option_mixer },
10869 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
10870 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10871 .dac_nids = alc262_dac_nids,
10872 .hp_nid = 0x03,
10873 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10874 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020010875 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010876 .unsol_event = alc262_hp_wildwest_unsol_event,
10877 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010878 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010879 [ALC262_HP_TC_T5735] = {
10880 .mixers = { alc262_hp_t5735_mixer },
10881 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
10882 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10883 .dac_nids = alc262_dac_nids,
10884 .hp_nid = 0x03,
10885 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10886 .channel_mode = alc262_modes,
10887 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010888 .unsol_event = alc_automute_amp_unsol_event,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010889 .init_hook = alc262_hp_t5735_init_hook,
Kailang Yang8c427222008-01-10 13:03:59 +010010890 },
10891 [ALC262_HP_RP5700] = {
10892 .mixers = { alc262_hp_rp5700_mixer },
10893 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
10894 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10895 .dac_nids = alc262_dac_nids,
10896 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10897 .channel_mode = alc262_modes,
10898 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010899 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010900 [ALC262_BENQ_ED8] = {
10901 .mixers = { alc262_base_mixer },
10902 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
10903 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10904 .dac_nids = alc262_dac_nids,
10905 .hp_nid = 0x03,
10906 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10907 .channel_mode = alc262_modes,
10908 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010909 },
Kailang Yang272a5272007-05-14 11:00:38 +020010910 [ALC262_SONY_ASSAMD] = {
10911 .mixers = { alc262_sony_mixer },
10912 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
10913 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10914 .dac_nids = alc262_dac_nids,
10915 .hp_nid = 0x02,
10916 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10917 .channel_mode = alc262_modes,
10918 .input_mux = &alc262_capture_source,
10919 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020010920 .init_hook = alc262_hippo_init_hook,
Kailang Yang83c34212007-07-05 11:43:05 +020010921 },
10922 [ALC262_BENQ_T31] = {
10923 .mixers = { alc262_benq_t31_mixer },
10924 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
10925 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10926 .dac_nids = alc262_dac_nids,
10927 .hp_nid = 0x03,
10928 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10929 .channel_mode = alc262_modes,
10930 .input_mux = &alc262_capture_source,
10931 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020010932 .init_hook = alc262_hippo_init_hook,
Kailang Yangea1fb292008-08-26 12:58:38 +020010933 },
Tobin Davisf651b502007-10-26 12:40:47 +020010934 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010935 .mixers = { alc262_ultra_mixer },
10936 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010937 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020010938 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10939 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020010940 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10941 .channel_mode = alc262_modes,
10942 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010943 .adc_nids = alc262_adc_nids, /* ADC0 */
10944 .capsrc_nids = alc262_capsrc_nids,
10945 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020010946 .unsol_event = alc262_ultra_unsol_event,
10947 .init_hook = alc262_ultra_automute,
10948 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010010949 [ALC262_LENOVO_3000] = {
10950 .mixers = { alc262_lenovo_3000_mixer },
10951 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
10952 alc262_lenovo_3000_unsol_verbs },
10953 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10954 .dac_nids = alc262_dac_nids,
10955 .hp_nid = 0x03,
10956 .dig_out_nid = ALC262_DIGOUT_NID,
10957 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10958 .channel_mode = alc262_modes,
10959 .input_mux = &alc262_fujitsu_capture_source,
10960 .unsol_event = alc262_lenovo_3000_unsol_event,
10961 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010962 [ALC262_NEC] = {
10963 .mixers = { alc262_nec_mixer },
10964 .init_verbs = { alc262_nec_verbs },
10965 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10966 .dac_nids = alc262_dac_nids,
10967 .hp_nid = 0x03,
10968 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10969 .channel_mode = alc262_modes,
10970 .input_mux = &alc262_capture_source,
10971 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020010972 [ALC262_TOSHIBA_S06] = {
10973 .mixers = { alc262_toshiba_s06_mixer },
10974 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
10975 alc262_eapd_verbs },
10976 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10977 .capsrc_nids = alc262_dmic_capsrc_nids,
10978 .dac_nids = alc262_dac_nids,
10979 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
10980 .dig_out_nid = ALC262_DIGOUT_NID,
10981 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10982 .channel_mode = alc262_modes,
10983 .input_mux = &alc262_dmic_capture_source,
10984 .unsol_event = alc262_toshiba_s06_unsol_event,
10985 .init_hook = alc262_toshiba_s06_init_hook,
10986 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010987 [ALC262_TOSHIBA_RX1] = {
10988 .mixers = { alc262_toshiba_rx1_mixer },
10989 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
10990 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10991 .dac_nids = alc262_dac_nids,
10992 .hp_nid = 0x03,
10993 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10994 .channel_mode = alc262_modes,
10995 .input_mux = &alc262_capture_source,
10996 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020010997 .init_hook = alc262_hippo_init_hook,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010998 },
Tony Vroonba340e82009-02-02 19:01:30 +000010999 [ALC262_TYAN] = {
11000 .mixers = { alc262_tyan_mixer },
11001 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
11002 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11003 .dac_nids = alc262_dac_nids,
11004 .hp_nid = 0x02,
11005 .dig_out_nid = ALC262_DIGOUT_NID,
11006 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11007 .channel_mode = alc262_modes,
11008 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011009 .unsol_event = alc_automute_amp_unsol_event,
11010 .init_hook = alc262_tyan_init_hook,
Tony Vroonba340e82009-02-02 19:01:30 +000011011 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011012};
11013
11014static int patch_alc262(struct hda_codec *codec)
11015{
11016 struct alc_spec *spec;
11017 int board_config;
11018 int err;
11019
Robert P. J. Daydc041e02006-12-19 14:44:15 +010011020 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010011021 if (spec == NULL)
11022 return -ENOMEM;
11023
11024 codec->spec = spec;
11025#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011026 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
11027 * under-run
11028 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011029 {
11030 int tmp;
11031 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11032 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
11033 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11034 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
11035 }
11036#endif
11037
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020011038 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
11039
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011040 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
11041 alc262_models,
11042 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010011043
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011044 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020011045 printk(KERN_INFO "hda_codec: Unknown model for %s, "
11046 "trying auto-probe from BIOS...\n", codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010011047 board_config = ALC262_AUTO;
11048 }
11049
11050 if (board_config == ALC262_AUTO) {
11051 /* automatic parse from the BIOS config */
11052 err = alc262_parse_auto_config(codec);
11053 if (err < 0) {
11054 alc_free(codec);
11055 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011056 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011057 printk(KERN_INFO
11058 "hda_codec: Cannot set up configuration "
11059 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011060 board_config = ALC262_BASIC;
11061 }
11062 }
11063
Takashi Iwai07eba612009-02-19 08:06:35 +010011064 if (!spec->no_analog) {
11065 err = snd_hda_attach_beep_device(codec, 0x1);
11066 if (err < 0) {
11067 alc_free(codec);
11068 return err;
11069 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090011070 }
11071
Kailang Yangdf694da2005-12-05 19:42:22 +010011072 if (board_config != ALC262_AUTO)
11073 setup_preset(spec, &alc262_presets[board_config]);
11074
Kailang Yangdf694da2005-12-05 19:42:22 +010011075 spec->stream_analog_playback = &alc262_pcm_analog_playback;
11076 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020011077
Kailang Yangdf694da2005-12-05 19:42:22 +010011078 spec->stream_digital_playback = &alc262_pcm_digital_playback;
11079 spec->stream_digital_capture = &alc262_pcm_digital_capture;
11080
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011081 spec->capture_style = CAPT_MIX;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011082 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011083 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +010011084 unsigned int wcap = get_wcaps(codec, 0x07);
11085
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011086 /* get type */
11087 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +010011088 if (wcap != AC_WID_AUD_IN) {
11089 spec->adc_nids = alc262_adc_nids_alt;
11090 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwai88c71a92008-02-14 17:27:17 +010011091 spec->capsrc_nids = alc262_capsrc_nids_alt;
Kailang Yangdf694da2005-12-05 19:42:22 +010011092 } else {
11093 spec->adc_nids = alc262_adc_nids;
11094 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
Takashi Iwai88c71a92008-02-14 17:27:17 +010011095 spec->capsrc_nids = alc262_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010011096 }
11097 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011098 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011099 set_capture_mixer(spec);
Takashi Iwai07eba612009-02-19 08:06:35 +010011100 if (!spec->no_analog)
11101 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010011102
Takashi Iwai2134ea42008-01-10 16:53:55 +010011103 spec->vmaster_nid = 0x0c;
11104
Kailang Yangdf694da2005-12-05 19:42:22 +010011105 codec->patch_ops = alc_patch_ops;
11106 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011107 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011108#ifdef CONFIG_SND_HDA_POWER_SAVE
11109 if (!spec->loopback.amplist)
11110 spec->loopback.amplist = alc262_loopbacks;
11111#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010011112 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020011113
Kailang Yangdf694da2005-12-05 19:42:22 +010011114 return 0;
11115}
11116
Kailang Yangdf694da2005-12-05 19:42:22 +010011117/*
Kailang Yanga361d842007-06-05 12:30:55 +020011118 * ALC268 channel source setting (2 channel)
11119 */
11120#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
11121#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020011122
Kailang Yanga361d842007-06-05 12:30:55 +020011123static hda_nid_t alc268_dac_nids[2] = {
11124 /* front, hp */
11125 0x02, 0x03
11126};
11127
11128static hda_nid_t alc268_adc_nids[2] = {
11129 /* ADC0-1 */
11130 0x08, 0x07
11131};
11132
11133static hda_nid_t alc268_adc_nids_alt[1] = {
11134 /* ADC0 */
11135 0x08
11136};
11137
Takashi Iwaie1406342008-02-11 18:32:32 +010011138static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
11139
Kailang Yanga361d842007-06-05 12:30:55 +020011140static struct snd_kcontrol_new alc268_base_mixer[] = {
11141 /* output mixer control */
11142 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11143 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11144 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11145 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011146 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11147 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11148 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020011149 { }
11150};
11151
Takashi Iwai42171c12009-05-08 14:11:43 +020011152static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
11153 /* output mixer control */
11154 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11155 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11156 ALC262_HIPPO_MASTER_SWITCH,
11157 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),
11160 { }
11161};
11162
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011163/* bind Beep switches of both NID 0x0f and 0x10 */
11164static struct hda_bind_ctls alc268_bind_beep_sw = {
11165 .ops = &snd_hda_bind_sw,
11166 .values = {
11167 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
11168 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
11169 0
11170 },
11171};
11172
11173static struct snd_kcontrol_new alc268_beep_mixer[] = {
11174 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
11175 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
11176 { }
11177};
11178
Kailang Yangd1a991a2007-08-15 16:21:59 +020011179static struct hda_verb alc268_eapd_verbs[] = {
11180 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11181 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11182 { }
11183};
11184
Takashi Iwaid2738092007-08-16 14:59:45 +020011185/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020011186static struct hda_verb alc268_toshiba_verbs[] = {
11187 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11188 { } /* end */
11189};
11190
Kailang Yang8ef355d2008-08-26 13:10:22 +020011191static struct hda_input_mux alc268_acer_lc_capture_source = {
11192 .num_items = 2,
11193 .items = {
11194 { "i-Mic", 0x6 },
11195 { "E-Mic", 0x0 },
11196 },
11197};
11198
Takashi Iwaid2738092007-08-16 14:59:45 +020011199/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020011200/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020011201static struct hda_bind_ctls alc268_acer_bind_master_vol = {
11202 .ops = &snd_hda_bind_vol,
11203 .values = {
11204 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
11205 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
11206 0
11207 },
11208};
11209
Takashi Iwai889c4392007-08-23 18:56:52 +020011210/* mute/unmute internal speaker according to the hp jack and mute state */
11211static void alc268_acer_automute(struct hda_codec *codec, int force)
11212{
11213 struct alc_spec *spec = codec->spec;
11214 unsigned int mute;
11215
11216 if (force || !spec->sense_updated) {
11217 unsigned int present;
11218 present = snd_hda_codec_read(codec, 0x14, 0,
11219 AC_VERB_GET_PIN_SENSE, 0);
11220 spec->jack_present = (present & 0x80000000) != 0;
11221 spec->sense_updated = 1;
11222 }
11223 if (spec->jack_present)
11224 mute = HDA_AMP_MUTE; /* mute internal speaker */
11225 else /* unmute internal speaker if necessary */
11226 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
11227 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11228 HDA_AMP_MUTE, mute);
11229}
11230
11231
11232/* bind hp and internal speaker mute (with plug check) */
11233static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
11234 struct snd_ctl_elem_value *ucontrol)
11235{
11236 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11237 long *valp = ucontrol->value.integer.value;
11238 int change;
11239
11240 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
11241 HDA_AMP_MUTE,
11242 valp[0] ? 0 : HDA_AMP_MUTE);
11243 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
11244 HDA_AMP_MUTE,
11245 valp[1] ? 0 : HDA_AMP_MUTE);
11246 if (change)
11247 alc268_acer_automute(codec, 0);
11248 return change;
11249}
Takashi Iwaid2738092007-08-16 14:59:45 +020011250
Kailang Yang8ef355d2008-08-26 13:10:22 +020011251static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
11252 /* output mixer control */
11253 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11254 {
11255 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11256 .name = "Master Playback Switch",
11257 .info = snd_hda_mixer_amp_switch_info,
11258 .get = snd_hda_mixer_amp_switch_get,
11259 .put = alc268_acer_master_sw_put,
11260 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11261 },
11262 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
11263 { }
11264};
11265
Takashi Iwaid2738092007-08-16 14:59:45 +020011266static struct snd_kcontrol_new alc268_acer_mixer[] = {
11267 /* output mixer control */
11268 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11269 {
11270 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11271 .name = "Master Playback Switch",
11272 .info = snd_hda_mixer_amp_switch_info,
11273 .get = snd_hda_mixer_amp_switch_get,
11274 .put = alc268_acer_master_sw_put,
11275 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11276 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011277 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11278 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11279 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020011280 { }
11281};
11282
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011283static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
11284 /* output mixer control */
11285 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11286 {
11287 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11288 .name = "Master Playback Switch",
11289 .info = snd_hda_mixer_amp_switch_info,
11290 .get = snd_hda_mixer_amp_switch_get,
11291 .put = alc268_acer_master_sw_put,
11292 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11293 },
11294 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11295 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11296 { }
11297};
11298
Kailang Yang8ef355d2008-08-26 13:10:22 +020011299static struct hda_verb alc268_acer_aspire_one_verbs[] = {
11300 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11301 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11302 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11303 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11304 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
11305 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
11306 { }
11307};
11308
Takashi Iwaid2738092007-08-16 14:59:45 +020011309static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011310 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
11311 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020011312 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11313 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011314 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11315 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020011316 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11317 { }
11318};
11319
11320/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020011321#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
11322#define alc268_toshiba_init_hook alc262_hippo_init_hook
Takashi Iwaid2738092007-08-16 14:59:45 +020011323
11324static void alc268_acer_unsol_event(struct hda_codec *codec,
11325 unsigned int res)
11326{
Takashi Iwai889c4392007-08-23 18:56:52 +020011327 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020011328 return;
11329 alc268_acer_automute(codec, 1);
11330}
11331
Takashi Iwai889c4392007-08-23 18:56:52 +020011332static void alc268_acer_init_hook(struct hda_codec *codec)
11333{
11334 alc268_acer_automute(codec, 1);
11335}
11336
Kailang Yang8ef355d2008-08-26 13:10:22 +020011337/* toggle speaker-output according to the hp-jack state */
11338static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
11339{
11340 unsigned int present;
11341 unsigned char bits;
11342
11343 present = snd_hda_codec_read(codec, 0x15, 0,
11344 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11345 bits = present ? AMP_IN_MUTE(0) : 0;
11346 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
11347 AMP_IN_MUTE(0), bits);
11348 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
11349 AMP_IN_MUTE(0), bits);
11350}
11351
11352
11353static void alc268_acer_mic_automute(struct hda_codec *codec)
11354{
11355 unsigned int present;
11356
11357 present = snd_hda_codec_read(codec, 0x18, 0,
11358 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11359 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_CONNECT_SEL,
11360 present ? 0x0 : 0x6);
11361}
11362
11363static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
11364 unsigned int res)
11365{
11366 if ((res >> 26) == ALC880_HP_EVENT)
11367 alc268_aspire_one_speaker_automute(codec);
11368 if ((res >> 26) == ALC880_MIC_EVENT)
11369 alc268_acer_mic_automute(codec);
11370}
11371
11372static void alc268_acer_lc_init_hook(struct hda_codec *codec)
11373{
11374 alc268_aspire_one_speaker_automute(codec);
11375 alc268_acer_mic_automute(codec);
11376}
11377
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011378static struct snd_kcontrol_new alc268_dell_mixer[] = {
11379 /* output mixer control */
11380 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11381 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11382 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11383 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11384 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11385 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11386 { }
11387};
11388
11389static struct hda_verb alc268_dell_verbs[] = {
11390 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11391 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11392 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11393 { }
11394};
11395
11396/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011397static void alc268_dell_init_hook(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011398{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011399 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011400
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011401 spec->autocfg.hp_pins[0] = 0x15;
11402 spec->autocfg.speaker_pins[0] = 0x14;
11403 alc_automute_pin(codec);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011404}
11405
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011406static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
11407 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11408 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11409 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11410 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11411 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11412 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
11413 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
11414 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11415 { }
11416};
11417
11418static struct hda_verb alc267_quanta_il1_verbs[] = {
11419 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11420 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
11421 { }
11422};
11423
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011424static void alc267_quanta_il1_mic_automute(struct hda_codec *codec)
11425{
11426 unsigned int present;
11427
11428 present = snd_hda_codec_read(codec, 0x18, 0,
11429 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11430 snd_hda_codec_write(codec, 0x23, 0,
11431 AC_VERB_SET_CONNECT_SEL,
11432 present ? 0x00 : 0x01);
11433}
11434
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011435static void alc267_quanta_il1_init_hook(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011436{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011437 struct alc_spec *spec = codec->spec;
11438
11439 spec->autocfg.hp_pins[0] = 0x15;
11440 spec->autocfg.speaker_pins[0] = 0x14;
11441 alc_automute_pin(codec);
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011442 alc267_quanta_il1_mic_automute(codec);
11443}
11444
11445static void alc267_quanta_il1_unsol_event(struct hda_codec *codec,
11446 unsigned int res)
11447{
11448 switch (res >> 26) {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011449 case ALC880_MIC_EVENT:
11450 alc267_quanta_il1_mic_automute(codec);
11451 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011452 default:
11453 alc_sku_unsol_event(codec, res);
11454 break;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011455 }
11456}
11457
Kailang Yanga361d842007-06-05 12:30:55 +020011458/*
11459 * generic initialization of ADC, input mixers and output mixers
11460 */
11461static struct hda_verb alc268_base_init_verbs[] = {
11462 /* Unmute DAC0-1 and set vol = 0 */
11463 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011464 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011465
11466 /*
11467 * Set up output mixers (0x0c - 0x0e)
11468 */
11469 /* set vol=0 to output mixers */
11470 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020011471 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
11472
11473 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11474 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11475
11476 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11477 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11478 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11479 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11480 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11481 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11482 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11483 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11484
11485 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11486 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11487 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11488 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011489 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011490
11491 /* set PCBEEP vol = 0, mute connections */
11492 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11493 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11494 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020011495
Jiang Zhea9b3aa82007-12-20 13:13:13 +010011496 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020011497
Jiang Zhea9b3aa82007-12-20 13:13:13 +010011498 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
11499 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11500 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
11501 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011502
Kailang Yanga361d842007-06-05 12:30:55 +020011503 { }
11504};
11505
11506/*
11507 * generic initialization of ADC, input mixers and output mixers
11508 */
11509static struct hda_verb alc268_volume_init_verbs[] = {
11510 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010011511 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11512 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011513
11514 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11515 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11516 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11517 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11518 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11519
Kailang Yanga361d842007-06-05 12:30:55 +020011520 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020011521 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11522 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11523
11524 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011525 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011526
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011527 /* set PCBEEP vol = 0, mute connections */
11528 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11529 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11530 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020011531
11532 { }
11533};
11534
Kailang Yanga361d842007-06-05 12:30:55 +020011535static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
11536 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11537 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11538 {
11539 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11540 /* The multiple "Capture Source" controls confuse alsamixer
11541 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020011542 */
11543 /* .name = "Capture Source", */
11544 .name = "Input Source",
11545 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011546 .info = alc_mux_enum_info,
11547 .get = alc_mux_enum_get,
11548 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020011549 },
11550 { } /* end */
11551};
11552
11553static struct snd_kcontrol_new alc268_capture_mixer[] = {
11554 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11555 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11556 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
11557 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
11558 {
11559 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11560 /* The multiple "Capture Source" controls confuse alsamixer
11561 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020011562 */
11563 /* .name = "Capture Source", */
11564 .name = "Input Source",
11565 .count = 2,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011566 .info = alc_mux_enum_info,
11567 .get = alc_mux_enum_get,
11568 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020011569 },
11570 { } /* end */
11571};
11572
11573static struct hda_input_mux alc268_capture_source = {
11574 .num_items = 4,
11575 .items = {
11576 { "Mic", 0x0 },
11577 { "Front Mic", 0x1 },
11578 { "Line", 0x2 },
11579 { "CD", 0x3 },
11580 },
11581};
11582
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011583static struct hda_input_mux alc268_acer_capture_source = {
11584 .num_items = 3,
11585 .items = {
11586 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011587 { "Internal Mic", 0x1 },
11588 { "Line", 0x2 },
11589 },
11590};
11591
11592static struct hda_input_mux alc268_acer_dmic_capture_source = {
11593 .num_items = 3,
11594 .items = {
11595 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011596 { "Internal Mic", 0x6 },
11597 { "Line", 0x2 },
11598 },
11599};
11600
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011601#ifdef CONFIG_SND_DEBUG
11602static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011603 /* Volume widgets */
11604 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11605 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11606 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
11607 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
11608 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
11609 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
11610 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
11611 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
11612 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
11613 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
11614 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
11615 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
11616 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010011617 /* The below appears problematic on some hardwares */
11618 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011619 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11620 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
11621 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
11622 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
11623
11624 /* Modes for retasking pin widgets */
11625 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
11626 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
11627 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
11628 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
11629
11630 /* Controls for GPIO pins, assuming they are configured as outputs */
11631 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
11632 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
11633 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
11634 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
11635
11636 /* Switches to allow the digital SPDIF output pin to be enabled.
11637 * The ALC268 does not have an SPDIF input.
11638 */
11639 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
11640
11641 /* A switch allowing EAPD to be enabled. Some laptops seem to use
11642 * this output to turn on an external amplifier.
11643 */
11644 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
11645 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
11646
11647 { } /* end */
11648};
11649#endif
11650
Kailang Yanga361d842007-06-05 12:30:55 +020011651/* create input playback/capture controls for the given pin */
11652static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
11653 const char *ctlname, int idx)
11654{
11655 char name[32];
11656 int err;
11657
11658 sprintf(name, "%s Playback Volume", ctlname);
11659 if (nid == 0x14) {
11660 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11661 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
11662 HDA_OUTPUT));
11663 if (err < 0)
11664 return err;
11665 } else if (nid == 0x15) {
11666 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11667 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
11668 HDA_OUTPUT));
11669 if (err < 0)
11670 return err;
11671 } else
11672 return -1;
11673 sprintf(name, "%s Playback Switch", ctlname);
11674 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
11675 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
11676 if (err < 0)
11677 return err;
11678 return 0;
11679}
11680
11681/* add playback controls from the parsed DAC table */
11682static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
11683 const struct auto_pin_cfg *cfg)
11684{
11685 hda_nid_t nid;
11686 int err;
11687
11688 spec->multiout.num_dacs = 2; /* only use one dac */
11689 spec->multiout.dac_nids = spec->private_dac_nids;
11690 spec->multiout.dac_nids[0] = 2;
11691 spec->multiout.dac_nids[1] = 3;
11692
11693 nid = cfg->line_out_pins[0];
11694 if (nid)
Kailang Yangea1fb292008-08-26 12:58:38 +020011695 alc268_new_analog_output(spec, nid, "Front", 0);
Kailang Yanga361d842007-06-05 12:30:55 +020011696
11697 nid = cfg->speaker_pins[0];
11698 if (nid == 0x1d) {
11699 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11700 "Speaker Playback Volume",
11701 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
11702 if (err < 0)
11703 return err;
11704 }
11705 nid = cfg->hp_pins[0];
11706 if (nid)
11707 alc268_new_analog_output(spec, nid, "Headphone", 0);
11708
11709 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
11710 if (nid == 0x16) {
11711 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11712 "Mono Playback Switch",
11713 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
11714 if (err < 0)
11715 return err;
11716 }
Kailang Yangea1fb292008-08-26 12:58:38 +020011717 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020011718}
11719
11720/* create playback/capture controls for input pins */
11721static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
11722 const struct auto_pin_cfg *cfg)
11723{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011724 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020011725 int i, idx1;
11726
11727 for (i = 0; i < AUTO_PIN_LAST; i++) {
11728 switch(cfg->input_pins[i]) {
11729 case 0x18:
11730 idx1 = 0; /* Mic 1 */
11731 break;
11732 case 0x19:
11733 idx1 = 1; /* Mic 2 */
11734 break;
11735 case 0x1a:
11736 idx1 = 2; /* Line In */
11737 break;
Kailang Yangea1fb292008-08-26 12:58:38 +020011738 case 0x1c:
Kailang Yanga361d842007-06-05 12:30:55 +020011739 idx1 = 3; /* CD */
11740 break;
Takashi Iwai7194cae2008-03-06 16:58:17 +010011741 case 0x12:
11742 case 0x13:
11743 idx1 = 6; /* digital mics */
11744 break;
Kailang Yanga361d842007-06-05 12:30:55 +020011745 default:
11746 continue;
11747 }
11748 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
11749 imux->items[imux->num_items].index = idx1;
Kailang Yangea1fb292008-08-26 12:58:38 +020011750 imux->num_items++;
Kailang Yanga361d842007-06-05 12:30:55 +020011751 }
11752 return 0;
11753}
11754
11755static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
11756{
11757 struct alc_spec *spec = codec->spec;
11758 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
11759 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
11760 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
11761 unsigned int dac_vol1, dac_vol2;
11762
11763 if (speaker_nid) {
11764 snd_hda_codec_write(codec, speaker_nid, 0,
11765 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
11766 snd_hda_codec_write(codec, 0x0f, 0,
11767 AC_VERB_SET_AMP_GAIN_MUTE,
11768 AMP_IN_UNMUTE(1));
11769 snd_hda_codec_write(codec, 0x10, 0,
11770 AC_VERB_SET_AMP_GAIN_MUTE,
11771 AMP_IN_UNMUTE(1));
11772 } else {
11773 snd_hda_codec_write(codec, 0x0f, 0,
11774 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
11775 snd_hda_codec_write(codec, 0x10, 0,
11776 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
11777 }
11778
11779 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020011780 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020011781 dac_vol2 = AMP_OUT_ZERO;
11782 else if (line_nid == 0x15)
11783 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020011784 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020011785 dac_vol2 = AMP_OUT_ZERO;
11786 else if (hp_nid == 0x15)
11787 dac_vol1 = AMP_OUT_ZERO;
11788 if (line_nid != 0x16 || hp_nid != 0x16 ||
11789 spec->autocfg.line_out_pins[1] != 0x16 ||
11790 spec->autocfg.line_out_pins[2] != 0x16)
11791 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
11792
11793 snd_hda_codec_write(codec, 0x02, 0,
11794 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
11795 snd_hda_codec_write(codec, 0x03, 0,
11796 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
11797}
11798
11799/* pcm configuration: identiacal with ALC880 */
11800#define alc268_pcm_analog_playback alc880_pcm_analog_playback
11801#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010011802#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020011803#define alc268_pcm_digital_playback alc880_pcm_digital_playback
11804
11805/*
11806 * BIOS auto configuration
11807 */
11808static int alc268_parse_auto_config(struct hda_codec *codec)
11809{
11810 struct alc_spec *spec = codec->spec;
11811 int err;
11812 static hda_nid_t alc268_ignore[] = { 0 };
11813
11814 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11815 alc268_ignore);
11816 if (err < 0)
11817 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010011818 if (!spec->autocfg.line_outs) {
11819 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
11820 spec->multiout.max_channels = 2;
11821 spec->no_analog = 1;
11822 goto dig_only;
11823 }
Kailang Yanga361d842007-06-05 12:30:55 +020011824 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010011825 }
Kailang Yanga361d842007-06-05 12:30:55 +020011826 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
11827 if (err < 0)
11828 return err;
11829 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
11830 if (err < 0)
11831 return err;
11832
11833 spec->multiout.max_channels = 2;
11834
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010011835 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020011836 /* digital only support output */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010011837 if (spec->autocfg.dig_outs) {
Kailang Yanga361d842007-06-05 12:30:55 +020011838 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010011839 spec->dig_out_type = spec->autocfg.dig_out_type[0];
11840 }
Takashi Iwai603c4012008-07-30 15:01:44 +020011841 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011842 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020011843
Takashi Iwai892981f2009-03-02 08:04:35 +010011844 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011845 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011846
Takashi Iwaid88897e2008-10-31 15:01:37 +010011847 add_verb(spec, alc268_volume_init_verbs);
Kailang Yanga361d842007-06-05 12:30:55 +020011848 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011849 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020011850
Takashi Iwai776e1842007-08-29 15:07:11 +020011851 err = alc_auto_add_mic_boost(codec);
11852 if (err < 0)
11853 return err;
11854
Kailang Yanga361d842007-06-05 12:30:55 +020011855 return 1;
11856}
11857
11858#define alc268_auto_init_multi_out alc882_auto_init_multi_out
11859#define alc268_auto_init_hp_out alc882_auto_init_hp_out
11860#define alc268_auto_init_analog_input alc882_auto_init_analog_input
11861
11862/* init callback for auto-configuration model -- overriding the default init */
11863static void alc268_auto_init(struct hda_codec *codec)
11864{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011865 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020011866 alc268_auto_init_multi_out(codec);
11867 alc268_auto_init_hp_out(codec);
11868 alc268_auto_init_mono_speaker_out(codec);
11869 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011870 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020011871 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020011872}
11873
11874/*
11875 * configuration and preset
11876 */
11877static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011878 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020011879 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020011880 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020011881 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011882 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020011883 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011884 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011885 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011886#ifdef CONFIG_SND_DEBUG
11887 [ALC268_TEST] = "test",
11888#endif
Kailang Yanga361d842007-06-05 12:30:55 +020011889 [ALC268_AUTO] = "auto",
11890};
11891
11892static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020011893 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011894 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010011895 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011896 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010011897 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020011898 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
11899 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011900 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Takashi Iwai57d13922009-01-08 15:52:09 +010011901 SND_PCI_QUIRK(0x1028, 0x02b0, "Dell Inspiron Mini9", ALC268_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011902 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
Kailang Yanga361d842007-06-05 12:30:55 +020011903 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Kailang Yangd1a991a2007-08-15 16:21:59 +020011904 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
Takashi Iwai8e7f00f2007-09-07 10:58:58 +020011905 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
Travis Place2346d0c2008-09-01 08:24:00 +020011906 SND_PCI_QUIRK(0x1179, 0xff64, "TOSHIBA L305", ALC268_TOSHIBA),
Tony Vroon378bd6a2008-06-04 12:08:30 +020011907 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020011908 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011909 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011910 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Kailang Yanga361d842007-06-05 12:30:55 +020011911 {}
11912};
11913
11914static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011915 [ALC267_QUANTA_IL1] = {
Takashi Iwai22971e32009-02-10 11:56:44 +010011916 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011917 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11918 alc267_quanta_il1_verbs },
11919 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11920 .dac_nids = alc268_dac_nids,
11921 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11922 .adc_nids = alc268_adc_nids_alt,
11923 .hp_nid = 0x03,
11924 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11925 .channel_mode = alc268_modes,
11926 .input_mux = &alc268_capture_source,
11927 .unsol_event = alc267_quanta_il1_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011928 .init_hook = alc267_quanta_il1_init_hook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011929 },
Kailang Yanga361d842007-06-05 12:30:55 +020011930 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011931 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
11932 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020011933 .init_verbs = { alc268_base_init_verbs },
11934 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11935 .dac_nids = alc268_dac_nids,
11936 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11937 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011938 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020011939 .hp_nid = 0x03,
11940 .dig_out_nid = ALC268_DIGOUT_NID,
11941 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11942 .channel_mode = alc268_modes,
11943 .input_mux = &alc268_capture_source,
11944 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020011945 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011946 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011947 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020011948 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11949 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020011950 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11951 .dac_nids = alc268_dac_nids,
11952 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11953 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011954 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020011955 .hp_nid = 0x03,
11956 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11957 .channel_mode = alc268_modes,
11958 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020011959 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011960 .init_hook = alc268_toshiba_init_hook,
Takashi Iwaid2738092007-08-16 14:59:45 +020011961 },
11962 [ALC268_ACER] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011963 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
11964 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020011965 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11966 alc268_acer_verbs },
11967 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11968 .dac_nids = alc268_dac_nids,
11969 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11970 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011971 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020011972 .hp_nid = 0x02,
11973 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11974 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011975 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020011976 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020011977 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020011978 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011979 [ALC268_ACER_DMIC] = {
11980 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
11981 alc268_beep_mixer },
11982 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11983 alc268_acer_verbs },
11984 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11985 .dac_nids = alc268_dac_nids,
11986 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11987 .adc_nids = alc268_adc_nids_alt,
11988 .capsrc_nids = alc268_capsrc_nids,
11989 .hp_nid = 0x02,
11990 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11991 .channel_mode = alc268_modes,
11992 .input_mux = &alc268_acer_dmic_capture_source,
11993 .unsol_event = alc268_acer_unsol_event,
11994 .init_hook = alc268_acer_init_hook,
11995 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020011996 [ALC268_ACER_ASPIRE_ONE] = {
11997 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010011998 alc268_beep_mixer,
11999 alc268_capture_alt_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012000 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12001 alc268_acer_aspire_one_verbs },
12002 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12003 .dac_nids = alc268_dac_nids,
12004 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12005 .adc_nids = alc268_adc_nids_alt,
12006 .capsrc_nids = alc268_capsrc_nids,
12007 .hp_nid = 0x03,
12008 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12009 .channel_mode = alc268_modes,
12010 .input_mux = &alc268_acer_lc_capture_source,
12011 .unsol_event = alc268_acer_lc_unsol_event,
12012 .init_hook = alc268_acer_lc_init_hook,
12013 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012014 [ALC268_DELL] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012015 .mixers = { alc268_dell_mixer, alc268_beep_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012016 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12017 alc268_dell_verbs },
12018 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12019 .dac_nids = alc268_dac_nids,
12020 .hp_nid = 0x02,
12021 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12022 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012023 .unsol_event = alc_sku_unsol_event,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012024 .init_hook = alc268_dell_init_hook,
12025 .input_mux = &alc268_capture_source,
12026 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012027 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012028 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12029 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012030 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12031 alc268_toshiba_verbs },
12032 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12033 .dac_nids = alc268_dac_nids,
12034 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12035 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012036 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012037 .hp_nid = 0x03,
12038 .dig_out_nid = ALC268_DIGOUT_NID,
12039 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12040 .channel_mode = alc268_modes,
12041 .input_mux = &alc268_capture_source,
12042 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020012043 .init_hook = alc268_toshiba_init_hook
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012044 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012045#ifdef CONFIG_SND_DEBUG
12046 [ALC268_TEST] = {
12047 .mixers = { alc268_test_mixer, alc268_capture_mixer },
12048 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12049 alc268_volume_init_verbs },
12050 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12051 .dac_nids = alc268_dac_nids,
12052 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12053 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012054 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012055 .hp_nid = 0x03,
12056 .dig_out_nid = ALC268_DIGOUT_NID,
12057 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12058 .channel_mode = alc268_modes,
12059 .input_mux = &alc268_capture_source,
12060 },
12061#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012062};
12063
12064static int patch_alc268(struct hda_codec *codec)
12065{
12066 struct alc_spec *spec;
12067 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010012068 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020012069
12070 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
12071 if (spec == NULL)
12072 return -ENOMEM;
12073
12074 codec->spec = spec;
12075
12076 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
12077 alc268_models,
12078 alc268_cfg_tbl);
12079
12080 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020012081 printk(KERN_INFO "hda_codec: Unknown model for %s, "
12082 "trying auto-probe from BIOS...\n", codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020012083 board_config = ALC268_AUTO;
12084 }
12085
12086 if (board_config == ALC268_AUTO) {
12087 /* automatic parse from the BIOS config */
12088 err = alc268_parse_auto_config(codec);
12089 if (err < 0) {
12090 alc_free(codec);
12091 return err;
12092 } else if (!err) {
12093 printk(KERN_INFO
12094 "hda_codec: Cannot set up configuration "
12095 "from BIOS. Using base mode...\n");
12096 board_config = ALC268_3ST;
12097 }
12098 }
12099
12100 if (board_config != ALC268_AUTO)
12101 setup_preset(spec, &alc268_presets[board_config]);
12102
Kailang Yanga361d842007-06-05 12:30:55 +020012103 spec->stream_analog_playback = &alc268_pcm_analog_playback;
12104 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010012105 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020012106
Kailang Yanga361d842007-06-05 12:30:55 +020012107 spec->stream_digital_playback = &alc268_pcm_digital_playback;
12108
Takashi Iwai22971e32009-02-10 11:56:44 +010012109 has_beep = 0;
12110 for (i = 0; i < spec->num_mixers; i++) {
12111 if (spec->mixers[i] == alc268_beep_mixer) {
12112 has_beep = 1;
12113 break;
12114 }
12115 }
12116
12117 if (has_beep) {
12118 err = snd_hda_attach_beep_device(codec, 0x1);
12119 if (err < 0) {
12120 alc_free(codec);
12121 return err;
12122 }
12123 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
12124 /* override the amp caps for beep generator */
12125 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012126 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
12127 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
12128 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
12129 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010012130 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012131
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012132 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012133 /* check whether NID 0x07 is valid */
12134 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010012135 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020012136
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012137 /* get type */
12138 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwai67ebcb02008-02-19 15:03:57 +010012139 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012140 spec->adc_nids = alc268_adc_nids_alt;
12141 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012142 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012143 } else {
12144 spec->adc_nids = alc268_adc_nids;
12145 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012146 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020012147 }
Takashi Iwaie1406342008-02-11 18:32:32 +010012148 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai85860c02008-02-19 15:00:15 +010012149 /* set default input source */
12150 for (i = 0; i < spec->num_adc_nids; i++)
12151 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
12152 0, AC_VERB_SET_CONNECT_SEL,
12153 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020012154 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010012155
12156 spec->vmaster_nid = 0x02;
12157
Kailang Yanga361d842007-06-05 12:30:55 +020012158 codec->patch_ops = alc_patch_ops;
12159 if (board_config == ALC268_AUTO)
12160 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020012161
Takashi Iwaidaead532008-11-28 12:55:36 +010012162 codec->proc_widget_hook = print_realtek_coef;
12163
Kailang Yanga361d842007-06-05 12:30:55 +020012164 return 0;
12165}
12166
12167/*
Kailang Yangf6a92242007-12-13 16:52:54 +010012168 * ALC269 channel source setting (2 channel)
12169 */
12170#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
12171
12172#define alc269_dac_nids alc260_dac_nids
12173
12174static hda_nid_t alc269_adc_nids[1] = {
12175 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020012176 0x08,
12177};
12178
Takashi Iwaie01bf502008-08-21 16:25:07 +020012179static hda_nid_t alc269_capsrc_nids[1] = {
12180 0x23,
12181};
12182
12183/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
12184 * not a mux!
12185 */
12186
Kailang Yangf53281e2008-07-18 12:36:43 +020012187static struct hda_input_mux alc269_eeepc_dmic_capture_source = {
12188 .num_items = 2,
12189 .items = {
12190 { "i-Mic", 0x5 },
12191 { "e-Mic", 0x0 },
12192 },
12193};
12194
12195static struct hda_input_mux alc269_eeepc_amic_capture_source = {
12196 .num_items = 2,
12197 .items = {
12198 { "i-Mic", 0x1 },
12199 { "e-Mic", 0x0 },
12200 },
Kailang Yangf6a92242007-12-13 16:52:54 +010012201};
12202
12203#define alc269_modes alc260_modes
12204#define alc269_capture_source alc880_lg_lw_capture_source
12205
12206static struct snd_kcontrol_new alc269_base_mixer[] = {
12207 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12208 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12209 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12210 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12211 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12212 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12213 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12214 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12215 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12216 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12217 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12218 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
12219 { } /* end */
12220};
12221
Kailang Yang60db6b52008-08-26 13:13:00 +020012222static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
12223 /* output mixer control */
12224 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12225 {
12226 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12227 .name = "Master Playback Switch",
12228 .info = snd_hda_mixer_amp_switch_info,
12229 .get = snd_hda_mixer_amp_switch_get,
12230 .put = alc268_acer_master_sw_put,
12231 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12232 },
12233 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12234 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12235 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12236 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12237 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12238 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020012239 { }
12240};
12241
Tony Vroon64154832008-11-06 15:08:49 +000012242static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
12243 /* output mixer control */
12244 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12245 {
12246 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12247 .name = "Master Playback Switch",
12248 .info = snd_hda_mixer_amp_switch_info,
12249 .get = snd_hda_mixer_amp_switch_get,
12250 .put = alc268_acer_master_sw_put,
12251 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12252 },
12253 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12254 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12255 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12256 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12257 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12258 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12259 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
12260 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
12261 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000012262 { }
12263};
12264
Kailang Yangf53281e2008-07-18 12:36:43 +020012265/* bind volumes of both NID 0x0c and 0x0d */
12266static struct hda_bind_ctls alc269_epc_bind_vol = {
12267 .ops = &snd_hda_bind_vol,
12268 .values = {
12269 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
12270 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
12271 0
12272 },
12273};
12274
12275static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
12276 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12277 HDA_BIND_VOL("LineOut Playback Volume", &alc269_epc_bind_vol),
12278 HDA_CODEC_MUTE("LineOut Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12279 { } /* end */
12280};
12281
Kailang Yangf6a92242007-12-13 16:52:54 +010012282/* capture mixer elements */
Kailang Yangf53281e2008-07-18 12:36:43 +020012283static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
12284 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12285 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012286 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12287 { } /* end */
12288};
12289
12290/* FSC amilo */
12291static struct snd_kcontrol_new alc269_fujitsu_mixer[] = {
12292 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12293 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12294 HDA_BIND_VOL("PCM Playback Volume", &alc269_epc_bind_vol),
Kailang Yangf53281e2008-07-18 12:36:43 +020012295 { } /* end */
12296};
12297
Kailang Yang60db6b52008-08-26 13:13:00 +020012298static struct hda_verb alc269_quanta_fl1_verbs[] = {
12299 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12300 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12301 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12302 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12303 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12304 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12305 { }
12306};
12307
Tony Vroon64154832008-11-06 15:08:49 +000012308static struct hda_verb alc269_lifebook_verbs[] = {
12309 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12310 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
12311 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12312 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12313 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12314 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12315 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12316 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12317 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12318 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12319 { }
12320};
12321
Kailang Yang60db6b52008-08-26 13:13:00 +020012322/* toggle speaker-output according to the hp-jack state */
12323static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
12324{
12325 unsigned int present;
12326 unsigned char bits;
12327
12328 present = snd_hda_codec_read(codec, 0x15, 0,
12329 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12330 bits = present ? AMP_IN_MUTE(0) : 0;
12331 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12332 AMP_IN_MUTE(0), bits);
12333 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12334 AMP_IN_MUTE(0), bits);
12335
12336 snd_hda_codec_write(codec, 0x20, 0,
12337 AC_VERB_SET_COEF_INDEX, 0x0c);
12338 snd_hda_codec_write(codec, 0x20, 0,
12339 AC_VERB_SET_PROC_COEF, 0x680);
12340
12341 snd_hda_codec_write(codec, 0x20, 0,
12342 AC_VERB_SET_COEF_INDEX, 0x0c);
12343 snd_hda_codec_write(codec, 0x20, 0,
12344 AC_VERB_SET_PROC_COEF, 0x480);
12345}
12346
Tony Vroon64154832008-11-06 15:08:49 +000012347/* toggle speaker-output according to the hp-jacks state */
12348static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
12349{
12350 unsigned int present;
12351 unsigned char bits;
12352
12353 /* Check laptop headphone socket */
12354 present = snd_hda_codec_read(codec, 0x15, 0,
12355 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12356
12357 /* Check port replicator headphone socket */
12358 present |= snd_hda_codec_read(codec, 0x1a, 0,
12359 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12360
12361 bits = present ? AMP_IN_MUTE(0) : 0;
12362 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12363 AMP_IN_MUTE(0), bits);
12364 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12365 AMP_IN_MUTE(0), bits);
12366
12367 snd_hda_codec_write(codec, 0x20, 0,
12368 AC_VERB_SET_COEF_INDEX, 0x0c);
12369 snd_hda_codec_write(codec, 0x20, 0,
12370 AC_VERB_SET_PROC_COEF, 0x680);
12371
12372 snd_hda_codec_write(codec, 0x20, 0,
12373 AC_VERB_SET_COEF_INDEX, 0x0c);
12374 snd_hda_codec_write(codec, 0x20, 0,
12375 AC_VERB_SET_PROC_COEF, 0x480);
12376}
12377
Kailang Yang60db6b52008-08-26 13:13:00 +020012378static void alc269_quanta_fl1_mic_automute(struct hda_codec *codec)
12379{
12380 unsigned int present;
12381
12382 present = snd_hda_codec_read(codec, 0x18, 0,
12383 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12384 snd_hda_codec_write(codec, 0x23, 0,
12385 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x1);
12386}
12387
Tony Vroon64154832008-11-06 15:08:49 +000012388static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
12389{
12390 unsigned int present_laptop;
12391 unsigned int present_dock;
12392
12393 present_laptop = snd_hda_codec_read(codec, 0x18, 0,
12394 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12395
12396 present_dock = snd_hda_codec_read(codec, 0x1b, 0,
12397 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12398
12399 /* Laptop mic port overrides dock mic port, design decision */
12400 if (present_dock)
12401 snd_hda_codec_write(codec, 0x23, 0,
12402 AC_VERB_SET_CONNECT_SEL, 0x3);
12403 if (present_laptop)
12404 snd_hda_codec_write(codec, 0x23, 0,
12405 AC_VERB_SET_CONNECT_SEL, 0x0);
12406 if (!present_dock && !present_laptop)
12407 snd_hda_codec_write(codec, 0x23, 0,
12408 AC_VERB_SET_CONNECT_SEL, 0x1);
12409}
12410
Kailang Yang60db6b52008-08-26 13:13:00 +020012411static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
12412 unsigned int res)
12413{
12414 if ((res >> 26) == ALC880_HP_EVENT)
12415 alc269_quanta_fl1_speaker_automute(codec);
12416 if ((res >> 26) == ALC880_MIC_EVENT)
12417 alc269_quanta_fl1_mic_automute(codec);
12418}
12419
Tony Vroon64154832008-11-06 15:08:49 +000012420static void alc269_lifebook_unsol_event(struct hda_codec *codec,
12421 unsigned int res)
12422{
12423 if ((res >> 26) == ALC880_HP_EVENT)
12424 alc269_lifebook_speaker_automute(codec);
12425 if ((res >> 26) == ALC880_MIC_EVENT)
12426 alc269_lifebook_mic_autoswitch(codec);
12427}
12428
Kailang Yang60db6b52008-08-26 13:13:00 +020012429static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
12430{
12431 alc269_quanta_fl1_speaker_automute(codec);
12432 alc269_quanta_fl1_mic_automute(codec);
12433}
12434
Tony Vroon64154832008-11-06 15:08:49 +000012435static void alc269_lifebook_init_hook(struct hda_codec *codec)
12436{
12437 alc269_lifebook_speaker_automute(codec);
12438 alc269_lifebook_mic_autoswitch(codec);
12439}
12440
Kailang Yang60db6b52008-08-26 13:13:00 +020012441static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
12442 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12443 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
12444 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12445 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
12446 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12447 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12448 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12449 {}
12450};
12451
12452static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
12453 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12454 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
12455 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12456 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
12457 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12458 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12459 {}
12460};
12461
12462/* toggle speaker-output according to the hp-jack state */
12463static void alc269_speaker_automute(struct hda_codec *codec)
12464{
12465 unsigned int present;
12466 unsigned char bits;
12467
12468 present = snd_hda_codec_read(codec, 0x15, 0,
12469 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12470 bits = present ? AMP_IN_MUTE(0) : 0;
12471 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12472 AMP_IN_MUTE(0), bits);
12473 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12474 AMP_IN_MUTE(0), bits);
12475}
12476
12477static void alc269_eeepc_dmic_automute(struct hda_codec *codec)
12478{
12479 unsigned int present;
12480
12481 present = snd_hda_codec_read(codec, 0x18, 0,
12482 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12483 snd_hda_codec_write(codec, 0x23, 0,
12484 AC_VERB_SET_CONNECT_SEL, (present ? 0 : 5));
12485}
12486
12487static void alc269_eeepc_amic_automute(struct hda_codec *codec)
12488{
12489 unsigned int present;
12490
12491 present = snd_hda_codec_read(codec, 0x18, 0,
12492 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12493 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12494 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
12495 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12496 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
12497}
12498
12499/* unsolicited event for HP jack sensing */
12500static void alc269_eeepc_dmic_unsol_event(struct hda_codec *codec,
12501 unsigned int res)
12502{
12503 if ((res >> 26) == ALC880_HP_EVENT)
12504 alc269_speaker_automute(codec);
12505
12506 if ((res >> 26) == ALC880_MIC_EVENT)
12507 alc269_eeepc_dmic_automute(codec);
12508}
12509
12510static void alc269_eeepc_dmic_inithook(struct hda_codec *codec)
12511{
12512 alc269_speaker_automute(codec);
12513 alc269_eeepc_dmic_automute(codec);
12514}
12515
12516/* unsolicited event for HP jack sensing */
12517static void alc269_eeepc_amic_unsol_event(struct hda_codec *codec,
12518 unsigned int res)
12519{
12520 if ((res >> 26) == ALC880_HP_EVENT)
12521 alc269_speaker_automute(codec);
12522
12523 if ((res >> 26) == ALC880_MIC_EVENT)
12524 alc269_eeepc_amic_automute(codec);
12525}
12526
12527static void alc269_eeepc_amic_inithook(struct hda_codec *codec)
12528{
12529 alc269_speaker_automute(codec);
12530 alc269_eeepc_amic_automute(codec);
12531}
12532
Kailang Yangf6a92242007-12-13 16:52:54 +010012533/*
12534 * generic initialization of ADC, input mixers and output mixers
12535 */
12536static struct hda_verb alc269_init_verbs[] = {
12537 /*
12538 * Unmute ADC0 and set the default input to mic-in
12539 */
Kailang Yang60db6b52008-08-26 13:13:00 +020012540 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010012541
12542 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
12543 * analog-loopback mixer widget
12544 * Note: PASD motherboards uses the Line In 2 as the input for
12545 * front panel mic (mic 2)
12546 */
12547 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
12548 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12549 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12550 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12551 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12552 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12553
12554 /*
12555 * Set up output mixers (0x0c - 0x0e)
12556 */
12557 /* set vol=0 to output mixers */
12558 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12559 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12560
12561 /* set up input amps for analog loopback */
12562 /* Amp Indices: DAC = 0, mixer = 1 */
12563 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12564 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12565 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12566 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12567 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12568 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12569
12570 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12571 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12572 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12573 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12574 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12575 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12576 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12577
12578 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12579 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12580 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12581 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12582 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12583 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12584 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12585
12586 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
12587 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12588
12589 /* FIXME: use matrix-type input source selection */
12590 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
12591 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang60db6b52008-08-26 13:13:00 +020012592 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12593 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangf6a92242007-12-13 16:52:54 +010012594 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12595 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12596
12597 /* set EAPD */
12598 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12599 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12600 { }
12601};
12602
12603/* add playback controls from the parsed DAC table */
12604static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
12605 const struct auto_pin_cfg *cfg)
12606{
12607 hda_nid_t nid;
12608 int err;
12609
12610 spec->multiout.num_dacs = 1; /* only use one dac */
12611 spec->multiout.dac_nids = spec->private_dac_nids;
12612 spec->multiout.dac_nids[0] = 2;
12613
12614 nid = cfg->line_out_pins[0];
12615 if (nid) {
12616 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12617 "Front Playback Volume",
12618 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
12619 if (err < 0)
12620 return err;
12621 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12622 "Front Playback Switch",
12623 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
12624 if (err < 0)
12625 return err;
12626 }
12627
12628 nid = cfg->speaker_pins[0];
12629 if (nid) {
12630 if (!cfg->line_out_pins[0]) {
12631 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12632 "Speaker Playback Volume",
12633 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12634 HDA_OUTPUT));
12635 if (err < 0)
12636 return err;
12637 }
12638 if (nid == 0x16) {
12639 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12640 "Speaker Playback Switch",
12641 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12642 HDA_OUTPUT));
12643 if (err < 0)
12644 return err;
12645 } else {
12646 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12647 "Speaker Playback Switch",
12648 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12649 HDA_OUTPUT));
12650 if (err < 0)
12651 return err;
12652 }
12653 }
12654 nid = cfg->hp_pins[0];
12655 if (nid) {
12656 /* spec->multiout.hp_nid = 2; */
12657 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
12658 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12659 "Headphone Playback Volume",
12660 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12661 HDA_OUTPUT));
12662 if (err < 0)
12663 return err;
12664 }
12665 if (nid == 0x16) {
12666 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12667 "Headphone Playback Switch",
12668 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12669 HDA_OUTPUT));
12670 if (err < 0)
12671 return err;
12672 } else {
12673 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12674 "Headphone Playback Switch",
12675 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12676 HDA_OUTPUT));
12677 if (err < 0)
12678 return err;
12679 }
12680 }
12681 return 0;
12682}
12683
Takashi Iwaiee956e02008-10-31 17:16:31 +010012684static int alc269_auto_create_analog_input_ctls(struct alc_spec *spec,
12685 const struct auto_pin_cfg *cfg)
12686{
12687 int err;
12688
12689 err = alc880_auto_create_analog_input_ctls(spec, cfg);
12690 if (err < 0)
12691 return err;
12692 /* digital-mic input pin is excluded in alc880_auto_create..()
12693 * because it's under 0x18
12694 */
12695 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
12696 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012697 struct hda_input_mux *imux = &spec->private_imux[0];
Takashi Iwaiee956e02008-10-31 17:16:31 +010012698 imux->items[imux->num_items].label = "Int Mic";
12699 imux->items[imux->num_items].index = 0x05;
12700 imux->num_items++;
12701 }
12702 return 0;
12703}
Kailang Yangf6a92242007-12-13 16:52:54 +010012704
12705#ifdef CONFIG_SND_HDA_POWER_SAVE
12706#define alc269_loopbacks alc880_loopbacks
12707#endif
12708
12709/* pcm configuration: identiacal with ALC880 */
12710#define alc269_pcm_analog_playback alc880_pcm_analog_playback
12711#define alc269_pcm_analog_capture alc880_pcm_analog_capture
12712#define alc269_pcm_digital_playback alc880_pcm_digital_playback
12713#define alc269_pcm_digital_capture alc880_pcm_digital_capture
12714
Takashi Iwaif03d3112009-03-05 14:18:16 +010012715static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
12716 .substreams = 1,
12717 .channels_min = 2,
12718 .channels_max = 8,
12719 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
12720 /* NID is set in alc_build_pcms */
12721 .ops = {
12722 .open = alc880_playback_pcm_open,
12723 .prepare = alc880_playback_pcm_prepare,
12724 .cleanup = alc880_playback_pcm_cleanup
12725 },
12726};
12727
12728static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
12729 .substreams = 1,
12730 .channels_min = 2,
12731 .channels_max = 2,
12732 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
12733 /* NID is set in alc_build_pcms */
12734};
12735
Kailang Yangf6a92242007-12-13 16:52:54 +010012736/*
12737 * BIOS auto configuration
12738 */
12739static int alc269_parse_auto_config(struct hda_codec *codec)
12740{
12741 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010012742 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010012743 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
12744
12745 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12746 alc269_ignore);
12747 if (err < 0)
12748 return err;
12749
12750 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
12751 if (err < 0)
12752 return err;
12753 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
12754 if (err < 0)
12755 return err;
12756
12757 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12758
Takashi Iwai0852d7a2009-02-11 11:35:15 +010012759 if (spec->autocfg.dig_outs)
Kailang Yangf6a92242007-12-13 16:52:54 +010012760 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
12761
Takashi Iwai603c4012008-07-30 15:01:44 +020012762 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012763 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010012764
Takashi Iwaid88897e2008-10-31 15:01:37 +010012765 add_verb(spec, alc269_init_verbs);
Kailang Yangf6a92242007-12-13 16:52:54 +010012766 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012767 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie01bf502008-08-21 16:25:07 +020012768 /* set default input source */
12769 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
12770 0, AC_VERB_SET_CONNECT_SEL,
12771 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010012772
12773 err = alc_auto_add_mic_boost(codec);
12774 if (err < 0)
12775 return err;
12776
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012777 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012778 set_capture_mixer(spec);
Kailang Yangf53281e2008-07-18 12:36:43 +020012779
Kailang Yangf6a92242007-12-13 16:52:54 +010012780 return 1;
12781}
12782
12783#define alc269_auto_init_multi_out alc882_auto_init_multi_out
12784#define alc269_auto_init_hp_out alc882_auto_init_hp_out
12785#define alc269_auto_init_analog_input alc882_auto_init_analog_input
12786
12787
12788/* init callback for auto-configuration model -- overriding the default init */
12789static void alc269_auto_init(struct hda_codec *codec)
12790{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012791 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010012792 alc269_auto_init_multi_out(codec);
12793 alc269_auto_init_hp_out(codec);
12794 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012795 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012796 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010012797}
12798
12799/*
12800 * configuration and preset
12801 */
12802static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020012803 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020012804 [ALC269_QUANTA_FL1] = "quanta",
12805 [ALC269_ASUS_EEEPC_P703] = "eeepc-p703",
Takashi Iwai26f5df22008-11-03 17:39:46 +010012806 [ALC269_ASUS_EEEPC_P901] = "eeepc-p901",
Tony Vroon64154832008-11-06 15:08:49 +000012807 [ALC269_FUJITSU] = "fujitsu",
12808 [ALC269_LIFEBOOK] = "lifebook"
Kailang Yangf6a92242007-12-13 16:52:54 +010012809};
12810
12811static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020012812 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020012813 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
12814 ALC269_ASUS_EEEPC_P703),
Kailang Yang622e84c2009-04-21 07:39:04 +020012815 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_ASUS_EEEPC_P703),
12816 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_ASUS_EEEPC_P703),
12817 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_ASUS_EEEPC_P703),
12818 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_ASUS_EEEPC_P703),
12819 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_ASUS_EEEPC_P703),
12820 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_ASUS_EEEPC_P703),
Kailang Yangf53281e2008-07-18 12:36:43 +020012821 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
12822 ALC269_ASUS_EEEPC_P901),
Kailang Yang60db6b52008-08-26 13:13:00 +020012823 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
12824 ALC269_ASUS_EEEPC_P901),
Kailang Yang622e84c2009-04-21 07:39:04 +020012825 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_ASUS_EEEPC_P901),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012826 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
Tony Vroon64154832008-11-06 15:08:49 +000012827 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yangf6a92242007-12-13 16:52:54 +010012828 {}
12829};
12830
12831static struct alc_config_preset alc269_presets[] = {
12832 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012833 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010012834 .init_verbs = { alc269_init_verbs },
12835 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12836 .dac_nids = alc269_dac_nids,
12837 .hp_nid = 0x03,
12838 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12839 .channel_mode = alc269_modes,
12840 .input_mux = &alc269_capture_source,
12841 },
Kailang Yang60db6b52008-08-26 13:13:00 +020012842 [ALC269_QUANTA_FL1] = {
12843 .mixers = { alc269_quanta_fl1_mixer },
12844 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
12845 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12846 .dac_nids = alc269_dac_nids,
12847 .hp_nid = 0x03,
12848 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12849 .channel_mode = alc269_modes,
12850 .input_mux = &alc269_capture_source,
12851 .unsol_event = alc269_quanta_fl1_unsol_event,
12852 .init_hook = alc269_quanta_fl1_init_hook,
12853 },
Kailang Yangf53281e2008-07-18 12:36:43 +020012854 [ALC269_ASUS_EEEPC_P703] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012855 .mixers = { alc269_eeepc_mixer },
12856 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020012857 .init_verbs = { alc269_init_verbs,
12858 alc269_eeepc_amic_init_verbs },
12859 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12860 .dac_nids = alc269_dac_nids,
12861 .hp_nid = 0x03,
12862 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12863 .channel_mode = alc269_modes,
12864 .input_mux = &alc269_eeepc_amic_capture_source,
12865 .unsol_event = alc269_eeepc_amic_unsol_event,
12866 .init_hook = alc269_eeepc_amic_inithook,
12867 },
12868 [ALC269_ASUS_EEEPC_P901] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012869 .mixers = { alc269_eeepc_mixer },
12870 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020012871 .init_verbs = { alc269_init_verbs,
12872 alc269_eeepc_dmic_init_verbs },
12873 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12874 .dac_nids = alc269_dac_nids,
12875 .hp_nid = 0x03,
12876 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12877 .channel_mode = alc269_modes,
12878 .input_mux = &alc269_eeepc_dmic_capture_source,
12879 .unsol_event = alc269_eeepc_dmic_unsol_event,
12880 .init_hook = alc269_eeepc_dmic_inithook,
12881 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010012882 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010012883 .mixers = { alc269_fujitsu_mixer },
Takashi Iwai26f5df22008-11-03 17:39:46 +010012884 .cap_mixer = alc269_epc_capture_mixer,
12885 .init_verbs = { alc269_init_verbs,
12886 alc269_eeepc_dmic_init_verbs },
12887 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12888 .dac_nids = alc269_dac_nids,
12889 .hp_nid = 0x03,
12890 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12891 .channel_mode = alc269_modes,
12892 .input_mux = &alc269_eeepc_dmic_capture_source,
12893 .unsol_event = alc269_eeepc_dmic_unsol_event,
12894 .init_hook = alc269_eeepc_dmic_inithook,
12895 },
Tony Vroon64154832008-11-06 15:08:49 +000012896 [ALC269_LIFEBOOK] = {
12897 .mixers = { alc269_lifebook_mixer },
12898 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
12899 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12900 .dac_nids = alc269_dac_nids,
12901 .hp_nid = 0x03,
12902 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12903 .channel_mode = alc269_modes,
12904 .input_mux = &alc269_capture_source,
12905 .unsol_event = alc269_lifebook_unsol_event,
12906 .init_hook = alc269_lifebook_init_hook,
12907 },
Kailang Yangf6a92242007-12-13 16:52:54 +010012908};
12909
12910static int patch_alc269(struct hda_codec *codec)
12911{
12912 struct alc_spec *spec;
12913 int board_config;
12914 int err;
12915
12916 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
12917 if (spec == NULL)
12918 return -ENOMEM;
12919
12920 codec->spec = spec;
12921
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020012922 alc_fix_pll_init(codec, 0x20, 0x04, 15);
12923
Kailang Yangf6a92242007-12-13 16:52:54 +010012924 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
12925 alc269_models,
12926 alc269_cfg_tbl);
12927
12928 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020012929 printk(KERN_INFO "hda_codec: Unknown model for %s, "
12930 "trying auto-probe from BIOS...\n", codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010012931 board_config = ALC269_AUTO;
12932 }
12933
12934 if (board_config == ALC269_AUTO) {
12935 /* automatic parse from the BIOS config */
12936 err = alc269_parse_auto_config(codec);
12937 if (err < 0) {
12938 alc_free(codec);
12939 return err;
12940 } else if (!err) {
12941 printk(KERN_INFO
12942 "hda_codec: Cannot set up configuration "
12943 "from BIOS. Using base mode...\n");
12944 board_config = ALC269_BASIC;
12945 }
12946 }
12947
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090012948 err = snd_hda_attach_beep_device(codec, 0x1);
12949 if (err < 0) {
12950 alc_free(codec);
12951 return err;
12952 }
12953
Kailang Yangf6a92242007-12-13 16:52:54 +010012954 if (board_config != ALC269_AUTO)
12955 setup_preset(spec, &alc269_presets[board_config]);
12956
Takashi Iwaif03d3112009-03-05 14:18:16 +010012957 if (codec->subsystem_id == 0x17aa3bf8) {
12958 /* Due to a hardware problem on Lenovo Ideadpad, we need to
12959 * fix the sample rate of analog I/O to 44.1kHz
12960 */
12961 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
12962 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
12963 } else {
12964 spec->stream_analog_playback = &alc269_pcm_analog_playback;
12965 spec->stream_analog_capture = &alc269_pcm_analog_capture;
12966 }
Kailang Yangf6a92242007-12-13 16:52:54 +010012967 spec->stream_digital_playback = &alc269_pcm_digital_playback;
12968 spec->stream_digital_capture = &alc269_pcm_digital_capture;
12969
12970 spec->adc_nids = alc269_adc_nids;
12971 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
Takashi Iwaie01bf502008-08-21 16:25:07 +020012972 spec->capsrc_nids = alc269_capsrc_nids;
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012973 if (!spec->cap_mixer)
12974 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010012975 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010012976
12977 codec->patch_ops = alc_patch_ops;
12978 if (board_config == ALC269_AUTO)
12979 spec->init_hook = alc269_auto_init;
12980#ifdef CONFIG_SND_HDA_POWER_SAVE
12981 if (!spec->loopback.amplist)
12982 spec->loopback.amplist = alc269_loopbacks;
12983#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010012984 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010012985
12986 return 0;
12987}
12988
12989/*
Kailang Yangdf694da2005-12-05 19:42:22 +010012990 * ALC861 channel source setting (2/6 channel selection for 3-stack)
12991 */
12992
12993/*
12994 * set the path ways for 2 channel output
12995 * need to set the codec line out and mic 1 pin widgets to inputs
12996 */
12997static struct hda_verb alc861_threestack_ch2_init[] = {
12998 /* set pin widget 1Ah (line in) for input */
12999 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013000 /* set pin widget 18h (mic1/2) for input, for mic also enable
13001 * the vref
13002 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013003 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13004
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013005 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13006#if 0
13007 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13008 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13009#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013010 { } /* end */
13011};
13012/*
13013 * 6ch mode
13014 * need to set the codec line out and mic 1 pin widgets to outputs
13015 */
13016static struct hda_verb alc861_threestack_ch6_init[] = {
13017 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13018 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13019 /* set pin widget 18h (mic1) for output (CLFE)*/
13020 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13021
13022 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013023 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013024
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013025 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13026#if 0
13027 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13028 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13029#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013030 { } /* end */
13031};
13032
13033static struct hda_channel_mode alc861_threestack_modes[2] = {
13034 { 2, alc861_threestack_ch2_init },
13035 { 6, alc861_threestack_ch6_init },
13036};
Takashi Iwai22309c32006-08-09 16:57:28 +020013037/* Set mic1 as input and unmute the mixer */
13038static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
13039 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13040 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13041 { } /* end */
13042};
13043/* Set mic1 as output and mute mixer */
13044static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
13045 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13046 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13047 { } /* end */
13048};
13049
13050static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
13051 { 2, alc861_uniwill_m31_ch2_init },
13052 { 4, alc861_uniwill_m31_ch4_init },
13053};
Kailang Yangdf694da2005-12-05 19:42:22 +010013054
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013055/* Set mic1 and line-in as input and unmute the mixer */
13056static struct hda_verb alc861_asus_ch2_init[] = {
13057 /* set pin widget 1Ah (line in) for input */
13058 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013059 /* set pin widget 18h (mic1/2) for input, for mic also enable
13060 * the vref
13061 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013062 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13063
13064 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13065#if 0
13066 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13067 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13068#endif
13069 { } /* end */
13070};
13071/* Set mic1 nad line-in as output and mute mixer */
13072static struct hda_verb alc861_asus_ch6_init[] = {
13073 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13074 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13075 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13076 /* set pin widget 18h (mic1) for output (CLFE)*/
13077 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13078 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13079 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
13080 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
13081
13082 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13083#if 0
13084 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13085 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13086#endif
13087 { } /* end */
13088};
13089
13090static struct hda_channel_mode alc861_asus_modes[2] = {
13091 { 2, alc861_asus_ch2_init },
13092 { 6, alc861_asus_ch6_init },
13093};
13094
Kailang Yangdf694da2005-12-05 19:42:22 +010013095/* patch-ALC861 */
13096
13097static struct snd_kcontrol_new alc861_base_mixer[] = {
13098 /* output mixer control */
13099 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13100 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13101 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13102 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13103 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13104
13105 /*Input mixer control */
13106 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13107 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13108 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13109 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13110 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13111 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13112 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13113 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13114 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13115 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013116
Kailang Yangdf694da2005-12-05 19:42:22 +010013117 { } /* end */
13118};
13119
13120static struct snd_kcontrol_new alc861_3ST_mixer[] = {
13121 /* output mixer control */
13122 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13123 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13124 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13125 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13126 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13127
13128 /* Input mixer control */
13129 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13130 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13131 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13132 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13133 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13134 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13135 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13136 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13137 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13138 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013139
Kailang Yangdf694da2005-12-05 19:42:22 +010013140 {
13141 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13142 .name = "Channel Mode",
13143 .info = alc_ch_mode_info,
13144 .get = alc_ch_mode_get,
13145 .put = alc_ch_mode_put,
13146 .private_value = ARRAY_SIZE(alc861_threestack_modes),
13147 },
13148 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013149};
13150
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013151static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013152 /* output mixer control */
13153 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13154 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13155 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020013156
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013157 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013158};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013159
Takashi Iwai22309c32006-08-09 16:57:28 +020013160static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
13161 /* output mixer control */
13162 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13163 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13164 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13165 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13166 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13167
13168 /* Input mixer control */
13169 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13170 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13171 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13172 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13173 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13174 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13175 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13176 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13177 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13178 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013179
Takashi Iwai22309c32006-08-09 16:57:28 +020013180 {
13181 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13182 .name = "Channel Mode",
13183 .info = alc_ch_mode_info,
13184 .get = alc_ch_mode_get,
13185 .put = alc_ch_mode_put,
13186 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
13187 },
13188 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013189};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013190
13191static struct snd_kcontrol_new alc861_asus_mixer[] = {
13192 /* output mixer control */
13193 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13194 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13195 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13196 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13197 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13198
13199 /* Input mixer control */
13200 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13201 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13202 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13203 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13204 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13205 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13206 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13207 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13208 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013209 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
13210
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013211 {
13212 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13213 .name = "Channel Mode",
13214 .info = alc_ch_mode_info,
13215 .get = alc_ch_mode_get,
13216 .put = alc_ch_mode_put,
13217 .private_value = ARRAY_SIZE(alc861_asus_modes),
13218 },
13219 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013220};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013221
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013222/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013223static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013224 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13225 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013226 { }
13227};
13228
Kailang Yangdf694da2005-12-05 19:42:22 +010013229/*
13230 * generic initialization of ADC, input mixers and output mixers
13231 */
13232static struct hda_verb alc861_base_init_verbs[] = {
13233 /*
13234 * Unmute ADC0 and set the default input to mic-in
13235 */
13236 /* port-A for surround (rear panel) */
13237 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13238 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
13239 /* port-B for mic-in (rear panel) with vref */
13240 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13241 /* port-C for line-in (rear panel) */
13242 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13243 /* port-D for Front */
13244 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13245 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13246 /* port-E for HP out (front panel) */
13247 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13248 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013249 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013250 /* port-F for mic-in (front panel) with vref */
13251 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13252 /* port-G for CLFE (rear panel) */
13253 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13254 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13255 /* port-H for side (rear panel) */
13256 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13257 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
13258 /* CD-in */
13259 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13260 /* route front mic to ADC1*/
13261 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13262 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013263
Kailang Yangdf694da2005-12-05 19:42:22 +010013264 /* Unmute DAC0~3 & spdif out*/
13265 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13266 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13267 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13268 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13269 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013270
Kailang Yangdf694da2005-12-05 19:42:22 +010013271 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13272 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13273 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13274 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13275 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013276
Kailang Yangdf694da2005-12-05 19:42:22 +010013277 /* Unmute Stereo Mixer 15 */
13278 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13279 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13280 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013281 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013282
13283 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13284 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13285 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13286 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13287 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13288 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13289 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13290 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013291 /* hp used DAC 3 (Front) */
13292 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013293 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13294
13295 { }
13296};
13297
13298static struct hda_verb alc861_threestack_init_verbs[] = {
13299 /*
13300 * Unmute ADC0 and set the default input to mic-in
13301 */
13302 /* port-A for surround (rear panel) */
13303 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13304 /* port-B for mic-in (rear panel) with vref */
13305 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13306 /* port-C for line-in (rear panel) */
13307 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13308 /* port-D for Front */
13309 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13310 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13311 /* port-E for HP out (front panel) */
13312 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13313 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013314 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013315 /* port-F for mic-in (front panel) with vref */
13316 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13317 /* port-G for CLFE (rear panel) */
13318 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13319 /* port-H for side (rear panel) */
13320 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13321 /* CD-in */
13322 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13323 /* route front mic to ADC1*/
13324 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13325 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13326 /* Unmute DAC0~3 & spdif out*/
13327 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13328 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13329 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13330 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13331 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013332
Kailang Yangdf694da2005-12-05 19:42:22 +010013333 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13334 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13335 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13336 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13337 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013338
Kailang Yangdf694da2005-12-05 19:42:22 +010013339 /* Unmute Stereo Mixer 15 */
13340 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13341 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13342 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013343 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013344
13345 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13346 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13347 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13348 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13349 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13350 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13351 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13352 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013353 /* hp used DAC 3 (Front) */
13354 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013355 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13356 { }
13357};
Takashi Iwai22309c32006-08-09 16:57:28 +020013358
13359static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
13360 /*
13361 * Unmute ADC0 and set the default input to mic-in
13362 */
13363 /* port-A for surround (rear panel) */
13364 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13365 /* port-B for mic-in (rear panel) with vref */
13366 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13367 /* port-C for line-in (rear panel) */
13368 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13369 /* port-D for Front */
13370 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13371 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13372 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013373 /* this has to be set to VREF80 */
13374 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013375 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013376 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013377 /* port-F for mic-in (front panel) with vref */
13378 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13379 /* port-G for CLFE (rear panel) */
13380 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13381 /* port-H for side (rear panel) */
13382 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13383 /* CD-in */
13384 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13385 /* route front mic to ADC1*/
13386 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13387 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13388 /* Unmute DAC0~3 & spdif out*/
13389 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13390 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13391 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13392 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13393 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013394
Takashi Iwai22309c32006-08-09 16:57:28 +020013395 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13396 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13397 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13398 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13399 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013400
Takashi Iwai22309c32006-08-09 16:57:28 +020013401 /* Unmute Stereo Mixer 15 */
13402 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13403 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13404 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013405 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020013406
13407 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13408 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13409 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13410 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13411 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13412 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13413 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13414 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013415 /* hp used DAC 3 (Front) */
13416 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020013417 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13418 { }
13419};
13420
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013421static struct hda_verb alc861_asus_init_verbs[] = {
13422 /*
13423 * Unmute ADC0 and set the default input to mic-in
13424 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013425 /* port-A for surround (rear panel)
13426 * according to codec#0 this is the HP jack
13427 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013428 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
13429 /* route front PCM to HP */
13430 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
13431 /* port-B for mic-in (rear panel) with vref */
13432 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13433 /* port-C for line-in (rear panel) */
13434 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13435 /* port-D for Front */
13436 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13437 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13438 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013439 /* this has to be set to VREF80 */
13440 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013441 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013442 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013443 /* port-F for mic-in (front panel) with vref */
13444 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13445 /* port-G for CLFE (rear panel) */
13446 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13447 /* port-H for side (rear panel) */
13448 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13449 /* CD-in */
13450 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13451 /* route front mic to ADC1*/
13452 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13453 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13454 /* Unmute DAC0~3 & spdif out*/
13455 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13456 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13457 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13458 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13459 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13460 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13461 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13462 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13463 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13464 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013465
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013466 /* Unmute Stereo Mixer 15 */
13467 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13468 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13469 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013470 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013471
13472 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13473 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13474 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13475 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13476 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13477 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13478 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13479 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013480 /* hp used DAC 3 (Front) */
13481 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013482 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13483 { }
13484};
13485
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013486/* additional init verbs for ASUS laptops */
13487static struct hda_verb alc861_asus_laptop_init_verbs[] = {
13488 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
13489 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
13490 { }
13491};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013492
Kailang Yangdf694da2005-12-05 19:42:22 +010013493/*
13494 * generic initialization of ADC, input mixers and output mixers
13495 */
13496static struct hda_verb alc861_auto_init_verbs[] = {
13497 /*
13498 * Unmute ADC0 and set the default input to mic-in
13499 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013500 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010013501 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013502
Kailang Yangdf694da2005-12-05 19:42:22 +010013503 /* Unmute DAC0~3 & spdif out*/
13504 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13505 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13506 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13507 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13508 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013509
Kailang Yangdf694da2005-12-05 19:42:22 +010013510 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13511 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13512 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13513 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13514 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013515
Kailang Yangdf694da2005-12-05 19:42:22 +010013516 /* Unmute Stereo Mixer 15 */
13517 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13518 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13519 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13520 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
13521
13522 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13523 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13524 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13525 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13526 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13527 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13528 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13529 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13530
13531 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13532 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013533 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13534 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013535 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13536 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013537 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13538 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013539
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013540 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013541
13542 { }
13543};
13544
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013545static struct hda_verb alc861_toshiba_init_verbs[] = {
13546 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013547
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013548 { }
13549};
13550
13551/* toggle speaker-output according to the hp-jack state */
13552static void alc861_toshiba_automute(struct hda_codec *codec)
13553{
13554 unsigned int present;
13555
13556 present = snd_hda_codec_read(codec, 0x0f, 0,
13557 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013558 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
13559 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
13560 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
13561 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013562}
13563
13564static void alc861_toshiba_unsol_event(struct hda_codec *codec,
13565 unsigned int res)
13566{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013567 if ((res >> 26) == ALC880_HP_EVENT)
13568 alc861_toshiba_automute(codec);
13569}
13570
Kailang Yangdf694da2005-12-05 19:42:22 +010013571/* pcm configuration: identiacal with ALC880 */
13572#define alc861_pcm_analog_playback alc880_pcm_analog_playback
13573#define alc861_pcm_analog_capture alc880_pcm_analog_capture
13574#define alc861_pcm_digital_playback alc880_pcm_digital_playback
13575#define alc861_pcm_digital_capture alc880_pcm_digital_capture
13576
13577
13578#define ALC861_DIGOUT_NID 0x07
13579
13580static struct hda_channel_mode alc861_8ch_modes[1] = {
13581 { 8, NULL }
13582};
13583
13584static hda_nid_t alc861_dac_nids[4] = {
13585 /* front, surround, clfe, side */
13586 0x03, 0x06, 0x05, 0x04
13587};
13588
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013589static hda_nid_t alc660_dac_nids[3] = {
13590 /* front, clfe, surround */
13591 0x03, 0x05, 0x06
13592};
13593
Kailang Yangdf694da2005-12-05 19:42:22 +010013594static hda_nid_t alc861_adc_nids[1] = {
13595 /* ADC0-2 */
13596 0x08,
13597};
13598
13599static struct hda_input_mux alc861_capture_source = {
13600 .num_items = 5,
13601 .items = {
13602 { "Mic", 0x0 },
13603 { "Front Mic", 0x3 },
13604 { "Line", 0x1 },
13605 { "CD", 0x4 },
13606 { "Mixer", 0x5 },
13607 },
13608};
13609
13610/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013611static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
13612 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010013613{
13614 int i;
13615 hda_nid_t nid;
13616
13617 spec->multiout.dac_nids = spec->private_dac_nids;
13618 for (i = 0; i < cfg->line_outs; i++) {
13619 nid = cfg->line_out_pins[i];
13620 if (nid) {
13621 if (i >= ARRAY_SIZE(alc861_dac_nids))
13622 continue;
13623 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
13624 }
13625 }
13626 spec->multiout.num_dacs = cfg->line_outs;
13627 return 0;
13628}
13629
13630/* add playback controls from the parsed DAC table */
13631static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
13632 const struct auto_pin_cfg *cfg)
13633{
13634 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013635 static const char *chname[4] = {
13636 "Front", "Surround", NULL /*CLFE*/, "Side"
13637 };
Kailang Yangdf694da2005-12-05 19:42:22 +010013638 hda_nid_t nid;
13639 int i, idx, err;
13640
13641 for (i = 0; i < cfg->line_outs; i++) {
13642 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013643 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010013644 continue;
13645 if (nid == 0x05) {
13646 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013647 err = add_control(spec, ALC_CTL_BIND_MUTE,
13648 "Center Playback Switch",
13649 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
13650 HDA_OUTPUT));
13651 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013652 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013653 err = add_control(spec, ALC_CTL_BIND_MUTE,
13654 "LFE Playback Switch",
13655 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13656 HDA_OUTPUT));
13657 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013658 return err;
13659 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013660 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
13661 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +010013662 if (nid == alc861_dac_nids[idx])
13663 break;
13664 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013665 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
13666 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13667 HDA_OUTPUT));
13668 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013669 return err;
13670 }
13671 }
13672 return 0;
13673}
13674
13675static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
13676{
13677 int err;
13678 hda_nid_t nid;
13679
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013680 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010013681 return 0;
13682
13683 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
13684 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013685 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13686 "Headphone Playback Switch",
13687 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
13688 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013689 return err;
13690 spec->multiout.hp_nid = nid;
13691 }
13692 return 0;
13693}
13694
13695/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013696static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
13697 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010013698{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013699 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010013700 int i, err, idx, idx1;
13701
13702 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013703 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010013704 case 0x0c:
13705 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013706 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013707 break;
13708 case 0x0f:
13709 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013710 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013711 break;
13712 case 0x0d:
13713 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013714 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013715 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013716 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010013717 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013718 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013719 break;
13720 case 0x11:
13721 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013722 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010013723 break;
13724 default:
13725 continue;
13726 }
13727
Takashi Iwai4a471b72005-12-07 13:56:29 +010013728 err = new_analog_input(spec, cfg->input_pins[i],
13729 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010013730 if (err < 0)
13731 return err;
13732
Takashi Iwai4a471b72005-12-07 13:56:29 +010013733 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010013734 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013735 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010013736 }
13737 return 0;
13738}
13739
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013740static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
13741 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +010013742 int pin_type, int dac_idx)
13743{
Jacek Luczak564c5be2008-05-03 18:41:23 +020013744 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
13745 pin_type);
13746 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13747 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +010013748}
13749
13750static void alc861_auto_init_multi_out(struct hda_codec *codec)
13751{
13752 struct alc_spec *spec = codec->spec;
13753 int i;
13754
13755 for (i = 0; i < spec->autocfg.line_outs; i++) {
13756 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013757 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010013758 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013759 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013760 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010013761 }
13762}
13763
13764static void alc861_auto_init_hp_out(struct hda_codec *codec)
13765{
13766 struct alc_spec *spec = codec->spec;
13767 hda_nid_t pin;
13768
Takashi Iwaieb06ed82006-09-20 17:10:27 +020013769 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010013770 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013771 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
13772 spec->multiout.dac_nids[0]);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013773 pin = spec->autocfg.speaker_pins[0];
13774 if (pin)
13775 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010013776}
13777
13778static void alc861_auto_init_analog_input(struct hda_codec *codec)
13779{
13780 struct alc_spec *spec = codec->spec;
13781 int i;
13782
13783 for (i = 0; i < AUTO_PIN_LAST; i++) {
13784 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai23f0c042009-02-26 13:03:58 +010013785 if (nid >= 0x0c && nid <= 0x11)
13786 alc_set_input_pin(codec, nid, i);
Kailang Yangdf694da2005-12-05 19:42:22 +010013787 }
13788}
13789
13790/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013791/* return 1 if successful, 0 if the proper config is not found,
13792 * or a negative error code
13793 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013794static int alc861_parse_auto_config(struct hda_codec *codec)
13795{
13796 struct alc_spec *spec = codec->spec;
13797 int err;
13798 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
13799
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013800 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13801 alc861_ignore);
13802 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013803 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013804 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010013805 return 0; /* can't find valid BIOS pin config */
13806
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013807 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
13808 if (err < 0)
13809 return err;
13810 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
13811 if (err < 0)
13812 return err;
13813 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
13814 if (err < 0)
13815 return err;
13816 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
13817 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013818 return err;
13819
13820 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13821
Takashi Iwai0852d7a2009-02-11 11:35:15 +010013822 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010013823 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
13824
Takashi Iwai603c4012008-07-30 15:01:44 +020013825 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013826 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010013827
Takashi Iwaid88897e2008-10-31 15:01:37 +010013828 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010013829
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020013830 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013831 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010013832
13833 spec->adc_nids = alc861_adc_nids;
13834 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013835 set_capture_mixer(spec);
Kailang Yangdf694da2005-12-05 19:42:22 +010013836
Takashi Iwai4a79ba32009-04-22 16:31:35 +020013837 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b);
13838
Kailang Yangdf694da2005-12-05 19:42:22 +010013839 return 1;
13840}
13841
Takashi Iwaiae6b8132006-03-03 16:47:17 +010013842/* additional initialization for auto-configuration model */
13843static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010013844{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013845 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010013846 alc861_auto_init_multi_out(codec);
13847 alc861_auto_init_hp_out(codec);
13848 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013849 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013850 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010013851}
13852
Takashi Iwaicb53c622007-08-10 17:21:45 +020013853#ifdef CONFIG_SND_HDA_POWER_SAVE
13854static struct hda_amp_list alc861_loopbacks[] = {
13855 { 0x15, HDA_INPUT, 0 },
13856 { 0x15, HDA_INPUT, 1 },
13857 { 0x15, HDA_INPUT, 2 },
13858 { 0x15, HDA_INPUT, 3 },
13859 { } /* end */
13860};
13861#endif
13862
Kailang Yangdf694da2005-12-05 19:42:22 +010013863
13864/*
13865 * configuration and preset
13866 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013867static const char *alc861_models[ALC861_MODEL_LAST] = {
13868 [ALC861_3ST] = "3stack",
13869 [ALC660_3ST] = "3stack-660",
13870 [ALC861_3ST_DIG] = "3stack-dig",
13871 [ALC861_6ST_DIG] = "6stack-dig",
13872 [ALC861_UNIWILL_M31] = "uniwill-m31",
13873 [ALC861_TOSHIBA] = "toshiba",
13874 [ALC861_ASUS] = "asus",
13875 [ALC861_ASUS_LAPTOP] = "asus-laptop",
13876 [ALC861_AUTO] = "auto",
13877};
13878
13879static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010013880 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013881 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
13882 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
13883 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013884 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020013885 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010013886 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020013887 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
13888 * Any other models that need this preset?
13889 */
13890 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020013891 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
13892 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013893 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
13894 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
13895 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
13896 /* FIXME: the below seems conflict */
13897 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
13898 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
13899 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010013900 {}
13901};
13902
13903static struct alc_config_preset alc861_presets[] = {
13904 [ALC861_3ST] = {
13905 .mixers = { alc861_3ST_mixer },
13906 .init_verbs = { alc861_threestack_init_verbs },
13907 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13908 .dac_nids = alc861_dac_nids,
13909 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13910 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020013911 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010013912 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13913 .adc_nids = alc861_adc_nids,
13914 .input_mux = &alc861_capture_source,
13915 },
13916 [ALC861_3ST_DIG] = {
13917 .mixers = { alc861_base_mixer },
13918 .init_verbs = { alc861_threestack_init_verbs },
13919 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13920 .dac_nids = alc861_dac_nids,
13921 .dig_out_nid = ALC861_DIGOUT_NID,
13922 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13923 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020013924 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010013925 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13926 .adc_nids = alc861_adc_nids,
13927 .input_mux = &alc861_capture_source,
13928 },
13929 [ALC861_6ST_DIG] = {
13930 .mixers = { alc861_base_mixer },
13931 .init_verbs = { alc861_base_init_verbs },
13932 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13933 .dac_nids = alc861_dac_nids,
13934 .dig_out_nid = ALC861_DIGOUT_NID,
13935 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
13936 .channel_mode = alc861_8ch_modes,
13937 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13938 .adc_nids = alc861_adc_nids,
13939 .input_mux = &alc861_capture_source,
13940 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013941 [ALC660_3ST] = {
13942 .mixers = { alc861_3ST_mixer },
13943 .init_verbs = { alc861_threestack_init_verbs },
13944 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
13945 .dac_nids = alc660_dac_nids,
13946 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13947 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020013948 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013949 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13950 .adc_nids = alc861_adc_nids,
13951 .input_mux = &alc861_capture_source,
13952 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013953 [ALC861_UNIWILL_M31] = {
13954 .mixers = { alc861_uniwill_m31_mixer },
13955 .init_verbs = { alc861_uniwill_m31_init_verbs },
13956 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13957 .dac_nids = alc861_dac_nids,
13958 .dig_out_nid = ALC861_DIGOUT_NID,
13959 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
13960 .channel_mode = alc861_uniwill_m31_modes,
13961 .need_dac_fix = 1,
13962 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13963 .adc_nids = alc861_adc_nids,
13964 .input_mux = &alc861_capture_source,
13965 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013966 [ALC861_TOSHIBA] = {
13967 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013968 .init_verbs = { alc861_base_init_verbs,
13969 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013970 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13971 .dac_nids = alc861_dac_nids,
13972 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
13973 .channel_mode = alc883_3ST_2ch_modes,
13974 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13975 .adc_nids = alc861_adc_nids,
13976 .input_mux = &alc861_capture_source,
13977 .unsol_event = alc861_toshiba_unsol_event,
13978 .init_hook = alc861_toshiba_automute,
13979 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013980 [ALC861_ASUS] = {
13981 .mixers = { alc861_asus_mixer },
13982 .init_verbs = { alc861_asus_init_verbs },
13983 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13984 .dac_nids = alc861_dac_nids,
13985 .dig_out_nid = ALC861_DIGOUT_NID,
13986 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
13987 .channel_mode = alc861_asus_modes,
13988 .need_dac_fix = 1,
13989 .hp_nid = 0x06,
13990 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13991 .adc_nids = alc861_adc_nids,
13992 .input_mux = &alc861_capture_source,
13993 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013994 [ALC861_ASUS_LAPTOP] = {
13995 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
13996 .init_verbs = { alc861_asus_init_verbs,
13997 alc861_asus_laptop_init_verbs },
13998 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13999 .dac_nids = alc861_dac_nids,
14000 .dig_out_nid = ALC861_DIGOUT_NID,
14001 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14002 .channel_mode = alc883_3ST_2ch_modes,
14003 .need_dac_fix = 1,
14004 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14005 .adc_nids = alc861_adc_nids,
14006 .input_mux = &alc861_capture_source,
14007 },
14008};
Kailang Yangdf694da2005-12-05 19:42:22 +010014009
14010
14011static int patch_alc861(struct hda_codec *codec)
14012{
14013 struct alc_spec *spec;
14014 int board_config;
14015 int err;
14016
Robert P. J. Daydc041e02006-12-19 14:44:15 +010014017 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010014018 if (spec == NULL)
14019 return -ENOMEM;
14020
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014021 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014022
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014023 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
14024 alc861_models,
14025 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014026
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014027 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020014028 printk(KERN_INFO "hda_codec: Unknown model for %s, "
14029 "trying auto-probe from BIOS...\n", codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010014030 board_config = ALC861_AUTO;
14031 }
14032
14033 if (board_config == ALC861_AUTO) {
14034 /* automatic parse from the BIOS config */
14035 err = alc861_parse_auto_config(codec);
14036 if (err < 0) {
14037 alc_free(codec);
14038 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014039 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014040 printk(KERN_INFO
14041 "hda_codec: Cannot set up configuration "
14042 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010014043 board_config = ALC861_3ST_DIG;
14044 }
14045 }
14046
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014047 err = snd_hda_attach_beep_device(codec, 0x23);
14048 if (err < 0) {
14049 alc_free(codec);
14050 return err;
14051 }
14052
Kailang Yangdf694da2005-12-05 19:42:22 +010014053 if (board_config != ALC861_AUTO)
14054 setup_preset(spec, &alc861_presets[board_config]);
14055
Kailang Yangdf694da2005-12-05 19:42:22 +010014056 spec->stream_analog_playback = &alc861_pcm_analog_playback;
14057 spec->stream_analog_capture = &alc861_pcm_analog_capture;
14058
Kailang Yangdf694da2005-12-05 19:42:22 +010014059 spec->stream_digital_playback = &alc861_pcm_digital_playback;
14060 spec->stream_digital_capture = &alc861_pcm_digital_capture;
14061
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014062 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
14063
Takashi Iwai2134ea42008-01-10 16:53:55 +010014064 spec->vmaster_nid = 0x03;
14065
Kailang Yangdf694da2005-12-05 19:42:22 +010014066 codec->patch_ops = alc_patch_ops;
14067 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014068 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014069#ifdef CONFIG_SND_HDA_POWER_SAVE
14070 if (!spec->loopback.amplist)
14071 spec->loopback.amplist = alc861_loopbacks;
14072#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010014073 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020014074
Kailang Yangdf694da2005-12-05 19:42:22 +010014075 return 0;
14076}
14077
14078/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014079 * ALC861-VD support
14080 *
14081 * Based on ALC882
14082 *
14083 * In addition, an independent DAC
14084 */
14085#define ALC861VD_DIGOUT_NID 0x06
14086
14087static hda_nid_t alc861vd_dac_nids[4] = {
14088 /* front, surr, clfe, side surr */
14089 0x02, 0x03, 0x04, 0x05
14090};
14091
14092/* dac_nids for ALC660vd are in a different order - according to
14093 * Realtek's driver.
14094 * This should probably tesult in a different mixer for 6stack models
14095 * of ALC660vd codecs, but for now there is only 3stack mixer
14096 * - and it is the same as in 861vd.
14097 * adc_nids in ALC660vd are (is) the same as in 861vd
14098 */
14099static hda_nid_t alc660vd_dac_nids[3] = {
14100 /* front, rear, clfe, rear_surr */
14101 0x02, 0x04, 0x03
14102};
14103
14104static hda_nid_t alc861vd_adc_nids[1] = {
14105 /* ADC0 */
14106 0x09,
14107};
14108
Takashi Iwaie1406342008-02-11 18:32:32 +010014109static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
14110
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014111/* input MUX */
14112/* FIXME: should be a matrix-type input source selection */
14113static struct hda_input_mux alc861vd_capture_source = {
14114 .num_items = 4,
14115 .items = {
14116 { "Mic", 0x0 },
14117 { "Front Mic", 0x1 },
14118 { "Line", 0x2 },
14119 { "CD", 0x4 },
14120 },
14121};
14122
Kailang Yang272a5272007-05-14 11:00:38 +020014123static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010014124 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020014125 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010014126 { "Ext Mic", 0x0 },
14127 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020014128 },
14129};
14130
Kailang Yangd1a991a2007-08-15 16:21:59 +020014131static struct hda_input_mux alc861vd_hp_capture_source = {
14132 .num_items = 2,
14133 .items = {
14134 { "Front Mic", 0x0 },
14135 { "ATAPI Mic", 0x1 },
14136 },
14137};
14138
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014139/*
14140 * 2ch mode
14141 */
14142static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
14143 { 2, NULL }
14144};
14145
14146/*
14147 * 6ch mode
14148 */
14149static struct hda_verb alc861vd_6stack_ch6_init[] = {
14150 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14151 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14152 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14153 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14154 { } /* end */
14155};
14156
14157/*
14158 * 8ch mode
14159 */
14160static struct hda_verb alc861vd_6stack_ch8_init[] = {
14161 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14162 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14163 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14164 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14165 { } /* end */
14166};
14167
14168static struct hda_channel_mode alc861vd_6stack_modes[2] = {
14169 { 6, alc861vd_6stack_ch6_init },
14170 { 8, alc861vd_6stack_ch8_init },
14171};
14172
14173static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
14174 {
14175 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14176 .name = "Channel Mode",
14177 .info = alc_ch_mode_info,
14178 .get = alc_ch_mode_get,
14179 .put = alc_ch_mode_put,
14180 },
14181 { } /* end */
14182};
14183
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014184/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
14185 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
14186 */
14187static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
14188 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14189 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14190
14191 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14192 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
14193
14194 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
14195 HDA_OUTPUT),
14196 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
14197 HDA_OUTPUT),
14198 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
14199 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
14200
14201 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
14202 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
14203
14204 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14205
14206 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14207 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14208 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14209
14210 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14211 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14212 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14213
14214 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14215 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14216
14217 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14218 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14219
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014220 { } /* end */
14221};
14222
14223static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
14224 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14225 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 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
Kailang Yangbdd148a2007-05-08 15:19:08 +020014246static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
14247 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14248 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
14249 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14250
14251 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14252
14253 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14254 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14255 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14256
14257 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14258 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14259 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14260
14261 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14262 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14263
14264 { } /* end */
14265};
14266
Tobin Davisb419f342008-03-07 11:57:51 +010014267/* Pin assignment: Speaker=0x14, HP = 0x15,
14268 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020014269 */
14270static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010014271 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14272 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014273 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14274 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010014275 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
14276 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14277 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14278 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
14279 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14280 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014281 { } /* end */
14282};
14283
Kailang Yangd1a991a2007-08-15 16:21:59 +020014284/* Pin assignment: Speaker=0x14, Line-out = 0x15,
14285 * Front Mic=0x18, ATAPI Mic = 0x19,
14286 */
14287static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
14288 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14289 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14290 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14291 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
14292 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14293 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14294 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14295 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020014296
Kailang Yangd1a991a2007-08-15 16:21:59 +020014297 { } /* end */
14298};
14299
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014300/*
14301 * generic initialization of ADC, input mixers and output mixers
14302 */
14303static struct hda_verb alc861vd_volume_init_verbs[] = {
14304 /*
14305 * Unmute ADC0 and set the default input to mic-in
14306 */
14307 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14308 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14309
14310 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
14311 * the analog-loopback mixer widget
14312 */
14313 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020014314 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14315 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14316 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14317 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14318 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014319
14320 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020014321 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14322 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14323 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014324 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014325
14326 /*
14327 * Set up output mixers (0x02 - 0x05)
14328 */
14329 /* set vol=0 to output mixers */
14330 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14331 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14332 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14333 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14334
14335 /* set up input amps for analog loopback */
14336 /* Amp Indices: DAC = 0, mixer = 1 */
14337 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14338 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14339 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14340 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14341 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14342 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14343 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14344 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14345
14346 { }
14347};
14348
14349/*
14350 * 3-stack pin configuration:
14351 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
14352 */
14353static struct hda_verb alc861vd_3stack_init_verbs[] = {
14354 /*
14355 * Set pin mode and muting
14356 */
14357 /* set front pin widgets 0x14 for output */
14358 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14359 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14360 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14361
14362 /* Mic (rear) pin: input vref at 80% */
14363 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14364 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14365 /* Front Mic pin: input vref at 80% */
14366 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14367 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14368 /* Line In pin: input */
14369 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14370 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14371 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14372 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14373 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14374 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14375 /* CD pin widget for input */
14376 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14377
14378 { }
14379};
14380
14381/*
14382 * 6-stack pin configuration:
14383 */
14384static struct hda_verb alc861vd_6stack_init_verbs[] = {
14385 /*
14386 * Set pin mode and muting
14387 */
14388 /* set front pin widgets 0x14 for output */
14389 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14390 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14391 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14392
14393 /* Rear Pin: output 1 (0x0d) */
14394 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14395 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14396 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14397 /* CLFE Pin: output 2 (0x0e) */
14398 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14399 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14400 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
14401 /* Side Pin: output 3 (0x0f) */
14402 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14403 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14404 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
14405
14406 /* Mic (rear) pin: input vref at 80% */
14407 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14408 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14409 /* Front Mic pin: input vref at 80% */
14410 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14411 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14412 /* Line In pin: input */
14413 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14414 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14415 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14416 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14417 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14418 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14419 /* CD pin widget for input */
14420 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14421
14422 { }
14423};
14424
Kailang Yangbdd148a2007-05-08 15:19:08 +020014425static struct hda_verb alc861vd_eapd_verbs[] = {
14426 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14427 { }
14428};
14429
Kailang Yangf9423e72008-05-27 12:32:25 +020014430static struct hda_verb alc660vd_eapd_verbs[] = {
14431 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14432 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
14433 { }
14434};
14435
Kailang Yangbdd148a2007-05-08 15:19:08 +020014436static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
14437 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14438 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14439 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
14440 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020014441 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020014442 {}
14443};
14444
Kailang Yangbdd148a2007-05-08 15:19:08 +020014445static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
14446{
14447 unsigned int present;
14448 unsigned char bits;
14449
14450 present = snd_hda_codec_read(codec, 0x18, 0,
14451 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014452 bits = present ? HDA_AMP_MUTE : 0;
14453 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
14454 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014455}
14456
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014457static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020014458{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014459 struct alc_spec *spec = codec->spec;
14460
14461 spec->autocfg.hp_pins[0] = 0x1b;
14462 spec->autocfg.speaker_pins[0] = 0x14;
14463 alc_automute_amp(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014464 alc861vd_lenovo_mic_automute(codec);
14465}
14466
14467static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
14468 unsigned int res)
14469{
14470 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020014471 case ALC880_MIC_EVENT:
14472 alc861vd_lenovo_mic_automute(codec);
14473 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014474 default:
14475 alc_automute_amp_unsol_event(codec, res);
14476 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020014477 }
14478}
14479
Kailang Yang272a5272007-05-14 11:00:38 +020014480static struct hda_verb alc861vd_dallas_verbs[] = {
14481 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14482 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14483 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14484 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14485
14486 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14487 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14488 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14489 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14490 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14491 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14492 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14493 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014494
Kailang Yang272a5272007-05-14 11:00:38 +020014495 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14496 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14497 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14498 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14499 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14500 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14501 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14502 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14503
14504 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14505 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14506 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14507 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14508 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14509 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14510 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14511 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14512
14513 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14514 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14515 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14516 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
14517
14518 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014519 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020014520 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14521
14522 { } /* end */
14523};
14524
14525/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014526static void alc861vd_dallas_init_hook(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020014527{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014528 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020014529
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014530 spec->autocfg.hp_pins[0] = 0x15;
14531 spec->autocfg.speaker_pins[0] = 0x14;
14532 alc_automute_amp(codec);
Kailang Yang272a5272007-05-14 11:00:38 +020014533}
14534
Takashi Iwaicb53c622007-08-10 17:21:45 +020014535#ifdef CONFIG_SND_HDA_POWER_SAVE
14536#define alc861vd_loopbacks alc880_loopbacks
14537#endif
14538
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014539/* pcm configuration: identiacal with ALC880 */
14540#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
14541#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
14542#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
14543#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
14544
14545/*
14546 * configuration and preset
14547 */
14548static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
14549 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020014550 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010014551 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014552 [ALC861VD_3ST] = "3stack",
14553 [ALC861VD_3ST_DIG] = "3stack-digout",
14554 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020014555 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020014556 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020014557 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014558 [ALC861VD_AUTO] = "auto",
14559};
14560
14561static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014562 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
14563 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010014564 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014565 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Takashi Iwai13c94742008-11-05 08:06:08 +010014566 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020014567 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014568 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014569 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020014570 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Kailang Yang272a5272007-05-14 11:00:38 +020014571 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Takashi Iwai542d7c62007-08-16 18:57:30 +020014572 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010014573 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020014574 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010014575 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020014576 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014577 {}
14578};
14579
14580static struct alc_config_preset alc861vd_presets[] = {
14581 [ALC660VD_3ST] = {
14582 .mixers = { alc861vd_3st_mixer },
14583 .init_verbs = { alc861vd_volume_init_verbs,
14584 alc861vd_3stack_init_verbs },
14585 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14586 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014587 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14588 .channel_mode = alc861vd_3stack_2ch_modes,
14589 .input_mux = &alc861vd_capture_source,
14590 },
Mike Crash6963f842007-06-25 12:12:51 +020014591 [ALC660VD_3ST_DIG] = {
14592 .mixers = { alc861vd_3st_mixer },
14593 .init_verbs = { alc861vd_volume_init_verbs,
14594 alc861vd_3stack_init_verbs },
14595 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14596 .dac_nids = alc660vd_dac_nids,
14597 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020014598 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14599 .channel_mode = alc861vd_3stack_2ch_modes,
14600 .input_mux = &alc861vd_capture_source,
14601 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014602 [ALC861VD_3ST] = {
14603 .mixers = { alc861vd_3st_mixer },
14604 .init_verbs = { alc861vd_volume_init_verbs,
14605 alc861vd_3stack_init_verbs },
14606 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14607 .dac_nids = alc861vd_dac_nids,
14608 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14609 .channel_mode = alc861vd_3stack_2ch_modes,
14610 .input_mux = &alc861vd_capture_source,
14611 },
14612 [ALC861VD_3ST_DIG] = {
14613 .mixers = { alc861vd_3st_mixer },
14614 .init_verbs = { alc861vd_volume_init_verbs,
14615 alc861vd_3stack_init_verbs },
14616 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14617 .dac_nids = alc861vd_dac_nids,
14618 .dig_out_nid = ALC861VD_DIGOUT_NID,
14619 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14620 .channel_mode = alc861vd_3stack_2ch_modes,
14621 .input_mux = &alc861vd_capture_source,
14622 },
14623 [ALC861VD_6ST_DIG] = {
14624 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
14625 .init_verbs = { alc861vd_volume_init_verbs,
14626 alc861vd_6stack_init_verbs },
14627 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14628 .dac_nids = alc861vd_dac_nids,
14629 .dig_out_nid = ALC861VD_DIGOUT_NID,
14630 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
14631 .channel_mode = alc861vd_6stack_modes,
14632 .input_mux = &alc861vd_capture_source,
14633 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020014634 [ALC861VD_LENOVO] = {
14635 .mixers = { alc861vd_lenovo_mixer },
14636 .init_verbs = { alc861vd_volume_init_verbs,
14637 alc861vd_3stack_init_verbs,
14638 alc861vd_eapd_verbs,
14639 alc861vd_lenovo_unsol_verbs },
14640 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14641 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020014642 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14643 .channel_mode = alc861vd_3stack_2ch_modes,
14644 .input_mux = &alc861vd_capture_source,
14645 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014646 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020014647 },
Kailang Yang272a5272007-05-14 11:00:38 +020014648 [ALC861VD_DALLAS] = {
14649 .mixers = { alc861vd_dallas_mixer },
14650 .init_verbs = { alc861vd_dallas_verbs },
14651 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14652 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020014653 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14654 .channel_mode = alc861vd_3stack_2ch_modes,
14655 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014656 .unsol_event = alc_automute_amp_unsol_event,
14657 .init_hook = alc861vd_dallas_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014658 },
14659 [ALC861VD_HP] = {
14660 .mixers = { alc861vd_hp_mixer },
14661 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
14662 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14663 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014664 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014665 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14666 .channel_mode = alc861vd_3stack_2ch_modes,
14667 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014668 .unsol_event = alc_automute_amp_unsol_event,
14669 .init_hook = alc861vd_dallas_init_hook,
Kailang Yangea1fb292008-08-26 12:58:38 +020014670 },
Takashi Iwai13c94742008-11-05 08:06:08 +010014671 [ALC660VD_ASUS_V1S] = {
14672 .mixers = { alc861vd_lenovo_mixer },
14673 .init_verbs = { alc861vd_volume_init_verbs,
14674 alc861vd_3stack_init_verbs,
14675 alc861vd_eapd_verbs,
14676 alc861vd_lenovo_unsol_verbs },
14677 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14678 .dac_nids = alc660vd_dac_nids,
14679 .dig_out_nid = ALC861VD_DIGOUT_NID,
14680 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14681 .channel_mode = alc861vd_3stack_2ch_modes,
14682 .input_mux = &alc861vd_capture_source,
14683 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014684 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010014685 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014686};
14687
14688/*
14689 * BIOS auto configuration
14690 */
14691static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
14692 hda_nid_t nid, int pin_type, int dac_idx)
14693{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014694 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014695}
14696
14697static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
14698{
14699 struct alc_spec *spec = codec->spec;
14700 int i;
14701
14702 for (i = 0; i <= HDA_SIDE; i++) {
14703 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014704 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014705 if (nid)
14706 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014707 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014708 }
14709}
14710
14711
14712static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
14713{
14714 struct alc_spec *spec = codec->spec;
14715 hda_nid_t pin;
14716
14717 pin = spec->autocfg.hp_pins[0];
14718 if (pin) /* connect to front and use dac 0 */
14719 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014720 pin = spec->autocfg.speaker_pins[0];
14721 if (pin)
14722 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014723}
14724
14725#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
14726#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
14727
14728static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
14729{
14730 struct alc_spec *spec = codec->spec;
14731 int i;
14732
14733 for (i = 0; i < AUTO_PIN_LAST; i++) {
14734 hda_nid_t nid = spec->autocfg.input_pins[i];
14735 if (alc861vd_is_input_pin(nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010014736 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +010014737 if (nid != ALC861VD_PIN_CD_NID &&
14738 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014739 snd_hda_codec_write(codec, nid, 0,
14740 AC_VERB_SET_AMP_GAIN_MUTE,
14741 AMP_OUT_MUTE);
14742 }
14743 }
14744}
14745
Takashi Iwaif511b012008-08-15 16:46:42 +020014746#define alc861vd_auto_init_input_src alc882_auto_init_input_src
14747
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014748#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
14749#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
14750
14751/* add playback controls from the parsed DAC table */
14752/* Based on ALC880 version. But ALC861VD has separate,
14753 * different NIDs for mute/unmute switch and volume control */
14754static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
14755 const struct auto_pin_cfg *cfg)
14756{
14757 char name[32];
14758 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
14759 hda_nid_t nid_v, nid_s;
14760 int i, err;
14761
14762 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014763 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014764 continue;
14765 nid_v = alc861vd_idx_to_mixer_vol(
14766 alc880_dac_to_idx(
14767 spec->multiout.dac_nids[i]));
14768 nid_s = alc861vd_idx_to_mixer_switch(
14769 alc880_dac_to_idx(
14770 spec->multiout.dac_nids[i]));
14771
14772 if (i == 2) {
14773 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014774 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14775 "Center Playback Volume",
14776 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
14777 HDA_OUTPUT));
14778 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014779 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014780 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14781 "LFE Playback Volume",
14782 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
14783 HDA_OUTPUT));
14784 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014785 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014786 err = add_control(spec, ALC_CTL_BIND_MUTE,
14787 "Center Playback Switch",
14788 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
14789 HDA_INPUT));
14790 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014791 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014792 err = add_control(spec, ALC_CTL_BIND_MUTE,
14793 "LFE Playback Switch",
14794 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
14795 HDA_INPUT));
14796 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014797 return err;
14798 } else {
14799 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014800 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
14801 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
14802 HDA_OUTPUT));
14803 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014804 return err;
14805 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014806 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020014807 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014808 HDA_INPUT));
14809 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014810 return err;
14811 }
14812 }
14813 return 0;
14814}
14815
14816/* add playback controls for speaker and HP outputs */
14817/* Based on ALC880 version. But ALC861VD has separate,
14818 * different NIDs for mute/unmute switch and volume control */
14819static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
14820 hda_nid_t pin, const char *pfx)
14821{
14822 hda_nid_t nid_v, nid_s;
14823 int err;
14824 char name[32];
14825
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014826 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014827 return 0;
14828
14829 if (alc880_is_fixed_pin(pin)) {
14830 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
14831 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014832 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014833 spec->multiout.hp_nid = nid_v;
14834 else
14835 spec->multiout.extra_out_nid[0] = nid_v;
14836 /* control HP volume/switch on the output mixer amp */
14837 nid_v = alc861vd_idx_to_mixer_vol(
14838 alc880_fixed_pin_idx(pin));
14839 nid_s = alc861vd_idx_to_mixer_switch(
14840 alc880_fixed_pin_idx(pin));
14841
14842 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014843 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
14844 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
14845 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014846 return err;
14847 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014848 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
14849 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
14850 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014851 return err;
14852 } else if (alc880_is_multi_pin(pin)) {
14853 /* set manual connection */
14854 /* we have only a switch on HP-out PIN */
14855 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014856 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
14857 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
14858 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014859 return err;
14860 }
14861 return 0;
14862}
14863
14864/* parse the BIOS configuration and set up the alc_spec
14865 * return 1 if successful, 0 if the proper config is not found,
14866 * or a negative error code
14867 * Based on ALC880 version - had to change it to override
14868 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
14869static int alc861vd_parse_auto_config(struct hda_codec *codec)
14870{
14871 struct alc_spec *spec = codec->spec;
14872 int err;
14873 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
14874
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014875 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14876 alc861vd_ignore);
14877 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014878 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014879 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014880 return 0; /* can't find valid BIOS pin config */
14881
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014882 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
14883 if (err < 0)
14884 return err;
14885 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
14886 if (err < 0)
14887 return err;
14888 err = alc861vd_auto_create_extra_out(spec,
14889 spec->autocfg.speaker_pins[0],
14890 "Speaker");
14891 if (err < 0)
14892 return err;
14893 err = alc861vd_auto_create_extra_out(spec,
14894 spec->autocfg.hp_pins[0],
14895 "Headphone");
14896 if (err < 0)
14897 return err;
14898 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
14899 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014900 return err;
14901
14902 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14903
Takashi Iwai0852d7a2009-02-11 11:35:15 +010014904 if (spec->autocfg.dig_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014905 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
14906
Takashi Iwai603c4012008-07-30 15:01:44 +020014907 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014908 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014909
Takashi Iwaid88897e2008-10-31 15:01:37 +010014910 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014911
14912 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014913 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014914
Takashi Iwai776e1842007-08-29 15:07:11 +020014915 err = alc_auto_add_mic_boost(codec);
14916 if (err < 0)
14917 return err;
14918
Takashi Iwai4a79ba32009-04-22 16:31:35 +020014919 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
14920
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014921 return 1;
14922}
14923
14924/* additional initialization for auto-configuration model */
14925static void alc861vd_auto_init(struct hda_codec *codec)
14926{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014927 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014928 alc861vd_auto_init_multi_out(codec);
14929 alc861vd_auto_init_hp_out(codec);
14930 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020014931 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014932 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014933 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014934}
14935
14936static int patch_alc861vd(struct hda_codec *codec)
14937{
14938 struct alc_spec *spec;
14939 int err, board_config;
14940
14941 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
14942 if (spec == NULL)
14943 return -ENOMEM;
14944
14945 codec->spec = spec;
14946
14947 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
14948 alc861vd_models,
14949 alc861vd_cfg_tbl);
14950
14951 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020014952 printk(KERN_INFO "hda_codec: Unknown model for %s, "
14953 "trying auto-probe from BIOS...\n", codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014954 board_config = ALC861VD_AUTO;
14955 }
14956
14957 if (board_config == ALC861VD_AUTO) {
14958 /* automatic parse from the BIOS config */
14959 err = alc861vd_parse_auto_config(codec);
14960 if (err < 0) {
14961 alc_free(codec);
14962 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014963 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014964 printk(KERN_INFO
14965 "hda_codec: Cannot set up configuration "
14966 "from BIOS. Using base mode...\n");
14967 board_config = ALC861VD_3ST;
14968 }
14969 }
14970
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014971 err = snd_hda_attach_beep_device(codec, 0x23);
14972 if (err < 0) {
14973 alc_free(codec);
14974 return err;
14975 }
14976
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014977 if (board_config != ALC861VD_AUTO)
14978 setup_preset(spec, &alc861vd_presets[board_config]);
14979
Kailang Yang2f893282008-05-27 12:14:47 +020014980 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020014981 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010014982 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020014983 }
14984
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014985 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
14986 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
14987
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014988 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
14989 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
14990
14991 spec->adc_nids = alc861vd_adc_nids;
14992 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +010014993 spec->capsrc_nids = alc861vd_capsrc_nids;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014994 spec->capture_style = CAPT_MIX;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014995
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014996 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014997 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014998
Takashi Iwai2134ea42008-01-10 16:53:55 +010014999 spec->vmaster_nid = 0x02;
15000
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015001 codec->patch_ops = alc_patch_ops;
15002
15003 if (board_config == ALC861VD_AUTO)
15004 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015005#ifdef CONFIG_SND_HDA_POWER_SAVE
15006 if (!spec->loopback.amplist)
15007 spec->loopback.amplist = alc861vd_loopbacks;
15008#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010015009 codec->proc_widget_hook = print_realtek_coef;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015010
15011 return 0;
15012}
15013
15014/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015015 * ALC662 support
15016 *
15017 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
15018 * configuration. Each pin widget can choose any input DACs and a mixer.
15019 * Each ADC is connected from a mixer of all inputs. This makes possible
15020 * 6-channel independent captures.
15021 *
15022 * In addition, an independent DAC for the multi-playback (not used in this
15023 * driver yet).
15024 */
15025#define ALC662_DIGOUT_NID 0x06
15026#define ALC662_DIGIN_NID 0x0a
15027
15028static hda_nid_t alc662_dac_nids[4] = {
15029 /* front, rear, clfe, rear_surr */
15030 0x02, 0x03, 0x04
15031};
15032
Kailang Yang622e84c2009-04-21 07:39:04 +020015033static hda_nid_t alc272_dac_nids[2] = {
15034 0x02, 0x03
15035};
15036
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015037static hda_nid_t alc662_adc_nids[1] = {
15038 /* ADC1-2 */
15039 0x09,
15040};
Takashi Iwaie1406342008-02-11 18:32:32 +010015041
Kailang Yang622e84c2009-04-21 07:39:04 +020015042static hda_nid_t alc272_adc_nids[1] = {
15043 /* ADC1-2 */
15044 0x08,
15045};
15046
Kailang Yang77a261b2008-02-19 11:38:05 +010015047static hda_nid_t alc662_capsrc_nids[1] = { 0x22 };
Kailang Yang622e84c2009-04-21 07:39:04 +020015048static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
15049
Takashi Iwaie1406342008-02-11 18:32:32 +010015050
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015051/* input MUX */
15052/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015053static struct hda_input_mux alc662_capture_source = {
15054 .num_items = 4,
15055 .items = {
15056 { "Mic", 0x0 },
15057 { "Front Mic", 0x1 },
15058 { "Line", 0x2 },
15059 { "CD", 0x4 },
15060 },
15061};
15062
15063static struct hda_input_mux alc662_lenovo_101e_capture_source = {
15064 .num_items = 2,
15065 .items = {
15066 { "Mic", 0x1 },
15067 { "Line", 0x2 },
15068 },
15069};
Kailang Yang291702f2007-10-16 14:28:03 +020015070
15071static struct hda_input_mux alc662_eeepc_capture_source = {
15072 .num_items = 2,
15073 .items = {
15074 { "i-Mic", 0x1 },
15075 { "e-Mic", 0x0 },
15076 },
15077};
15078
Kailang Yang6dda9f42008-05-27 12:05:31 +020015079static struct hda_input_mux alc663_capture_source = {
15080 .num_items = 3,
15081 .items = {
15082 { "Mic", 0x0 },
15083 { "Front Mic", 0x1 },
15084 { "Line", 0x2 },
15085 },
15086};
15087
15088static struct hda_input_mux alc663_m51va_capture_source = {
15089 .num_items = 2,
15090 .items = {
15091 { "Ext-Mic", 0x0 },
15092 { "D-Mic", 0x9 },
15093 },
15094};
15095
Chris Pockelé9541ba12009-05-12 08:08:53 +020015096#if 1 /* set to 0 for testing other input sources below */
15097static struct hda_input_mux alc272_nc10_capture_source = {
15098 .num_items = 2,
15099 .items = {
15100 { "Autoselect Mic", 0x0 },
15101 { "Internal Mic", 0x1 },
15102 },
15103};
15104#else
15105static struct hda_input_mux alc272_nc10_capture_source = {
15106 .num_items = 16,
15107 .items = {
15108 { "Autoselect Mic", 0x0 },
15109 { "Internal Mic", 0x1 },
15110 { "In-0x02", 0x2 },
15111 { "In-0x03", 0x3 },
15112 { "In-0x04", 0x4 },
15113 { "In-0x05", 0x5 },
15114 { "In-0x06", 0x6 },
15115 { "In-0x07", 0x7 },
15116 { "In-0x08", 0x8 },
15117 { "In-0x09", 0x9 },
15118 { "In-0x0a", 0x0a },
15119 { "In-0x0b", 0x0b },
15120 { "In-0x0c", 0x0c },
15121 { "In-0x0d", 0x0d },
15122 { "In-0x0e", 0x0e },
15123 { "In-0x0f", 0x0f },
15124 },
15125};
15126#endif
15127
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015128/*
15129 * 2ch mode
15130 */
15131static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
15132 { 2, NULL }
15133};
15134
15135/*
15136 * 2ch mode
15137 */
15138static struct hda_verb alc662_3ST_ch2_init[] = {
15139 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
15140 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15141 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
15142 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15143 { } /* end */
15144};
15145
15146/*
15147 * 6ch mode
15148 */
15149static struct hda_verb alc662_3ST_ch6_init[] = {
15150 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15151 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15152 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
15153 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15154 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15155 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
15156 { } /* end */
15157};
15158
15159static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
15160 { 2, alc662_3ST_ch2_init },
15161 { 6, alc662_3ST_ch6_init },
15162};
15163
15164/*
15165 * 2ch mode
15166 */
15167static struct hda_verb alc662_sixstack_ch6_init[] = {
15168 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15169 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15170 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15171 { } /* end */
15172};
15173
15174/*
15175 * 6ch mode
15176 */
15177static struct hda_verb alc662_sixstack_ch8_init[] = {
15178 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15179 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15180 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15181 { } /* end */
15182};
15183
15184static struct hda_channel_mode alc662_5stack_modes[2] = {
15185 { 2, alc662_sixstack_ch6_init },
15186 { 6, alc662_sixstack_ch8_init },
15187};
15188
15189/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15190 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15191 */
15192
15193static struct snd_kcontrol_new alc662_base_mixer[] = {
15194 /* output mixer control */
15195 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015196 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015197 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015198 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015199 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15200 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015201 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15202 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015203 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15204
15205 /*Input mixer control */
15206 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
15207 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
15208 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
15209 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
15210 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
15211 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
15212 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
15213 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015214 { } /* end */
15215};
15216
15217static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
15218 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015219 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015220 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15221 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15222 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15223 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15224 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15225 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15226 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15227 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15228 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015229 { } /* end */
15230};
15231
15232static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
15233 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015234 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015235 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015236 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015237 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15238 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015239 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15240 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015241 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15242 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15243 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15244 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15245 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15246 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15247 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15248 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15249 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015250 { } /* end */
15251};
15252
15253static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
15254 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15255 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010015256 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15257 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015258 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15259 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15260 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15261 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15262 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015263 { } /* end */
15264};
15265
Kailang Yang291702f2007-10-16 14:28:03 +020015266static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020015267 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15268 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020015269
15270 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
15271 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15272 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15273
15274 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
15275 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15276 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15277 { } /* end */
15278};
15279
Kailang Yang8c427222008-01-10 13:03:59 +010015280static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020015281 ALC262_HIPPO_MASTER_SWITCH,
15282 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015283 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015284 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15285 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015286 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
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, 0x0, HDA_INPUT),
15290 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15291 { } /* end */
15292};
15293
Kailang Yangf1d4e282008-08-26 14:03:29 +020015294static struct hda_bind_ctls alc663_asus_bind_master_vol = {
15295 .ops = &snd_hda_bind_vol,
15296 .values = {
15297 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15298 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
15299 0
15300 },
15301};
15302
15303static struct hda_bind_ctls alc663_asus_one_bind_switch = {
15304 .ops = &snd_hda_bind_sw,
15305 .values = {
15306 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15307 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15308 0
15309 },
15310};
15311
Kailang Yang6dda9f42008-05-27 12:05:31 +020015312static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015313 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15314 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
15315 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15316 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15317 { } /* end */
15318};
15319
15320static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
15321 .ops = &snd_hda_bind_sw,
15322 .values = {
15323 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15324 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15325 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15326 0
15327 },
15328};
15329
15330static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
15331 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15332 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
15333 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15334 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15335 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15336 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15337
15338 { } /* end */
15339};
15340
15341static struct hda_bind_ctls alc663_asus_four_bind_switch = {
15342 .ops = &snd_hda_bind_sw,
15343 .values = {
15344 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15345 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15346 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
15347 0
15348 },
15349};
15350
15351static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
15352 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15353 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
15354 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15355 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15356 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15357 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15358 { } /* end */
15359};
15360
15361static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020015362 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15363 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015364 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15365 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15366 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15367 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15368 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15369 { } /* end */
15370};
15371
15372static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
15373 .ops = &snd_hda_bind_vol,
15374 .values = {
15375 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15376 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
15377 0
15378 },
15379};
15380
15381static struct hda_bind_ctls alc663_asus_two_bind_switch = {
15382 .ops = &snd_hda_bind_sw,
15383 .values = {
15384 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15385 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
15386 0
15387 },
15388};
15389
15390static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
15391 HDA_BIND_VOL("Master Playback Volume",
15392 &alc663_asus_two_bind_master_vol),
15393 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15394 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015395 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15396 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15397 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015398 { } /* end */
15399};
15400
15401static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
15402 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15403 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15404 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15405 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15406 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15407 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015408 { } /* end */
15409};
15410
15411static struct snd_kcontrol_new alc663_g71v_mixer[] = {
15412 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15413 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15414 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15415 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15416 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15417
15418 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15419 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15420 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15421 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15422 { } /* end */
15423};
15424
15425static struct snd_kcontrol_new alc663_g50v_mixer[] = {
15426 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15427 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15428 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15429
15430 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15431 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15432 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15433 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15434 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15435 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15436 { } /* end */
15437};
15438
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015439static struct snd_kcontrol_new alc662_chmode_mixer[] = {
15440 {
15441 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15442 .name = "Channel Mode",
15443 .info = alc_ch_mode_info,
15444 .get = alc_ch_mode_get,
15445 .put = alc_ch_mode_put,
15446 },
15447 { } /* end */
15448};
15449
15450static struct hda_verb alc662_init_verbs[] = {
15451 /* ADC: mute amp left and right */
15452 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15453 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15454 /* Front mixer: unmute input/output amp left and right (volume = 0) */
15455
Takashi Iwaicb53c622007-08-10 17:21:45 +020015456 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15457 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15458 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15459 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15460 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015461
Kailang Yangb60dd392007-09-20 12:50:29 +020015462 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15463 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15464 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15465 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15466 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15467 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015468
15469 /* Front Pin: output 0 (0x0c) */
15470 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15471 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15472
15473 /* Rear Pin: output 1 (0x0d) */
15474 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15475 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15476
15477 /* CLFE Pin: output 2 (0x0e) */
15478 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15479 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15480
15481 /* Mic (rear) pin: input vref at 80% */
15482 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15483 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15484 /* Front Mic pin: input vref at 80% */
15485 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15486 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15487 /* Line In pin: input */
15488 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15489 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15490 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15491 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15492 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15493 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15494 /* CD pin widget for input */
15495 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15496
15497 /* FIXME: use matrix-type input source selection */
15498 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15499 /* Input mixer */
15500 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020015501 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015502
15503 /* always trun on EAPD */
15504 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15505 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
15506
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015507 { }
15508};
15509
15510static struct hda_verb alc662_sue_init_verbs[] = {
15511 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15512 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020015513 {}
15514};
15515
15516static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
15517 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15518 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15519 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015520};
15521
Kailang Yang8c427222008-01-10 13:03:59 +010015522/* Set Unsolicited Event*/
15523static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
15524 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15525 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15526 {}
15527};
15528
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015529/*
15530 * generic initialization of ADC, input mixers and output mixers
15531 */
15532static struct hda_verb alc662_auto_init_verbs[] = {
15533 /*
15534 * Unmute ADC and set the default input to mic-in
15535 */
15536 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15537 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15538
15539 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
15540 * mixer widget
15541 * Note: PASD motherboards uses the Line In 2 as the input for front
15542 * panel mic (mic 2)
15543 */
15544 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020015545 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15546 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15547 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15548 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15549 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015550
15551 /*
15552 * Set up output mixers (0x0c - 0x0f)
15553 */
15554 /* set vol=0 to output mixers */
15555 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15556 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15557 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15558
15559 /* set up input amps for analog loopback */
15560 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020015561 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15562 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15563 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15564 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15565 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15566 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015567
15568
15569 /* FIXME: use matrix-type input source selection */
15570 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15571 /* Input mixer */
15572 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020015573 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015574 { }
15575};
15576
Takashi Iwai24fb9172008-09-02 14:48:20 +020015577/* additional verbs for ALC663 */
15578static struct hda_verb alc663_auto_init_verbs[] = {
15579 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15580 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15581 { }
15582};
15583
Kailang Yang6dda9f42008-05-27 12:05:31 +020015584static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015585 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15586 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015587 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15588 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020015589 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15590 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15591 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015592 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15593 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15594 {}
15595};
15596
Kailang Yangf1d4e282008-08-26 14:03:29 +020015597static struct hda_verb alc663_21jd_amic_init_verbs[] = {
15598 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15599 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15600 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15601 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15602 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15603 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15604 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15605 {}
15606};
15607
15608static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
15609 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15610 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15611 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15612 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15613 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15614 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15615 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15616 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15617 {}
15618};
15619
15620static struct hda_verb alc663_15jd_amic_init_verbs[] = {
15621 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15622 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15623 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15624 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15625 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15626 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15627 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15628 {}
15629};
15630
15631static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
15632 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15633 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15634 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15635 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15636 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15637 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15638 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15639 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15640 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15641 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15642 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15643 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15644 {}
15645};
15646
15647static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
15648 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15649 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15650 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15651 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15652 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15653 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15654 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15655 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15656 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15657 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15658 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15659 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15660 {}
15661};
15662
Kailang Yang6dda9f42008-05-27 12:05:31 +020015663static struct hda_verb alc663_g71v_init_verbs[] = {
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, 0x01}, */ /* Headphone */
15667
15668 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15669 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15670 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15671
15672 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15673 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
15674 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
15675 {}
15676};
15677
15678static struct hda_verb alc663_g50v_init_verbs[] = {
15679 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15680 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15681 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15682
15683 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15684 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15685 {}
15686};
15687
Kailang Yangf1d4e282008-08-26 14:03:29 +020015688static struct hda_verb alc662_ecs_init_verbs[] = {
15689 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
15690 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15691 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15692 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15693 {}
15694};
15695
Kailang Yang622e84c2009-04-21 07:39:04 +020015696static struct hda_verb alc272_dell_zm1_init_verbs[] = {
15697 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15698 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15699 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15700 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15701 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15702 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15703 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15704 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15705 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
15706 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15707 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15708 {}
15709};
15710
15711static struct hda_verb alc272_dell_init_verbs[] = {
15712 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15713 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15714 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15715 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15716 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15717 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15718 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15719 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15720 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
15721 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15722 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15723 {}
15724};
15725
Kailang Yangf1d4e282008-08-26 14:03:29 +020015726static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
15727 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
15728 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
15729 { } /* end */
15730};
15731
Kailang Yang622e84c2009-04-21 07:39:04 +020015732static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
15733 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
15734 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
15735 { } /* end */
15736};
15737
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015738static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
15739{
15740 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015741 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015742
15743 present = snd_hda_codec_read(codec, 0x14, 0,
15744 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020015745 bits = present ? HDA_AMP_MUTE : 0;
15746 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15747 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015748}
15749
15750static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
15751{
15752 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015753 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015754
15755 present = snd_hda_codec_read(codec, 0x1b, 0,
15756 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020015757 bits = present ? HDA_AMP_MUTE : 0;
15758 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15759 HDA_AMP_MUTE, bits);
15760 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
15761 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015762}
15763
15764static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
15765 unsigned int res)
15766{
15767 if ((res >> 26) == ALC880_HP_EVENT)
15768 alc662_lenovo_101e_all_automute(codec);
15769 if ((res >> 26) == ALC880_FRONT_EVENT)
15770 alc662_lenovo_101e_ispeaker_automute(codec);
15771}
15772
Kailang Yang291702f2007-10-16 14:28:03 +020015773static void alc662_eeepc_mic_automute(struct hda_codec *codec)
15774{
15775 unsigned int present;
15776
15777 present = snd_hda_codec_read(codec, 0x18, 0,
15778 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
15779 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15780 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
15781 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15782 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
15783 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15784 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
15785 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15786 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
15787}
15788
15789/* unsolicited event for HP jack sensing */
15790static void alc662_eeepc_unsol_event(struct hda_codec *codec,
15791 unsigned int res)
15792{
Kailang Yang291702f2007-10-16 14:28:03 +020015793 if ((res >> 26) == ALC880_MIC_EVENT)
15794 alc662_eeepc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020015795 else
15796 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020015797}
15798
15799static void alc662_eeepc_inithook(struct hda_codec *codec)
15800{
Takashi Iwai42171c12009-05-08 14:11:43 +020015801 alc262_hippo1_init_hook(codec);
Kailang Yang291702f2007-10-16 14:28:03 +020015802 alc662_eeepc_mic_automute(codec);
15803}
15804
Kailang Yang8c427222008-01-10 13:03:59 +010015805static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
15806{
Takashi Iwai42171c12009-05-08 14:11:43 +020015807 struct alc_spec *spec = codec->spec;
15808
15809 spec->autocfg.hp_pins[0] = 0x14;
15810 spec->autocfg.speaker_pins[0] = 0x1b;
15811 alc262_hippo_master_update(codec);
Kailang Yang8c427222008-01-10 13:03:59 +010015812}
15813
Kailang Yang6dda9f42008-05-27 12:05:31 +020015814static void alc663_m51va_speaker_automute(struct hda_codec *codec)
15815{
15816 unsigned int present;
15817 unsigned char bits;
15818
15819 present = snd_hda_codec_read(codec, 0x21, 0,
Kailang Yangf1d4e282008-08-26 14:03:29 +020015820 AC_VERB_GET_PIN_SENSE, 0)
15821 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020015822 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020015823 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15824 AMP_IN_MUTE(0), bits);
15825 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15826 AMP_IN_MUTE(0), bits);
15827}
15828
15829static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
15830{
15831 unsigned int present;
15832 unsigned char bits;
15833
15834 present = snd_hda_codec_read(codec, 0x21, 0,
15835 AC_VERB_GET_PIN_SENSE, 0)
15836 & AC_PINSENSE_PRESENCE;
15837 bits = present ? HDA_AMP_MUTE : 0;
15838 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15839 AMP_IN_MUTE(0), bits);
15840 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15841 AMP_IN_MUTE(0), bits);
15842 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
15843 AMP_IN_MUTE(0), bits);
15844 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
15845 AMP_IN_MUTE(0), bits);
15846}
15847
15848static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
15849{
15850 unsigned int present;
15851 unsigned char bits;
15852
15853 present = snd_hda_codec_read(codec, 0x15, 0,
15854 AC_VERB_GET_PIN_SENSE, 0)
15855 & AC_PINSENSE_PRESENCE;
15856 bits = present ? HDA_AMP_MUTE : 0;
15857 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15858 AMP_IN_MUTE(0), bits);
15859 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15860 AMP_IN_MUTE(0), bits);
15861 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
15862 AMP_IN_MUTE(0), bits);
15863 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
15864 AMP_IN_MUTE(0), bits);
15865}
15866
15867static void alc662_f5z_speaker_automute(struct hda_codec *codec)
15868{
15869 unsigned int present;
15870 unsigned char bits;
15871
15872 present = snd_hda_codec_read(codec, 0x1b, 0,
15873 AC_VERB_GET_PIN_SENSE, 0)
15874 & AC_PINSENSE_PRESENCE;
15875 bits = present ? 0 : PIN_OUT;
15876 snd_hda_codec_write(codec, 0x14, 0,
15877 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
15878}
15879
15880static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
15881{
15882 unsigned int present1, present2;
15883
15884 present1 = snd_hda_codec_read(codec, 0x21, 0,
15885 AC_VERB_GET_PIN_SENSE, 0)
15886 & AC_PINSENSE_PRESENCE;
15887 present2 = snd_hda_codec_read(codec, 0x15, 0,
15888 AC_VERB_GET_PIN_SENSE, 0)
15889 & AC_PINSENSE_PRESENCE;
15890
15891 if (present1 || present2) {
15892 snd_hda_codec_write_cache(codec, 0x14, 0,
15893 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
15894 } else {
15895 snd_hda_codec_write_cache(codec, 0x14, 0,
15896 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
15897 }
15898}
15899
15900static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
15901{
15902 unsigned int present1, present2;
15903
15904 present1 = snd_hda_codec_read(codec, 0x1b, 0,
15905 AC_VERB_GET_PIN_SENSE, 0)
15906 & AC_PINSENSE_PRESENCE;
15907 present2 = snd_hda_codec_read(codec, 0x15, 0,
15908 AC_VERB_GET_PIN_SENSE, 0)
15909 & AC_PINSENSE_PRESENCE;
15910
15911 if (present1 || present2) {
15912 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15913 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
15914 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15915 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
15916 } else {
15917 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15918 AMP_IN_MUTE(0), 0);
15919 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15920 AMP_IN_MUTE(0), 0);
15921 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020015922}
15923
15924static void alc663_m51va_mic_automute(struct hda_codec *codec)
15925{
15926 unsigned int present;
15927
15928 present = snd_hda_codec_read(codec, 0x18, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020015929 AC_VERB_GET_PIN_SENSE, 0)
15930 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020015931 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015932 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015933 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015934 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015935 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015936 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015937 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015938 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015939}
15940
15941static void alc663_m51va_unsol_event(struct hda_codec *codec,
15942 unsigned int res)
15943{
15944 switch (res >> 26) {
15945 case ALC880_HP_EVENT:
15946 alc663_m51va_speaker_automute(codec);
15947 break;
15948 case ALC880_MIC_EVENT:
15949 alc663_m51va_mic_automute(codec);
15950 break;
15951 }
15952}
15953
15954static void alc663_m51va_inithook(struct hda_codec *codec)
15955{
15956 alc663_m51va_speaker_automute(codec);
15957 alc663_m51va_mic_automute(codec);
15958}
15959
Kailang Yangf1d4e282008-08-26 14:03:29 +020015960/* ***************** Mode1 ******************************/
15961static void alc663_mode1_unsol_event(struct hda_codec *codec,
15962 unsigned int res)
15963{
15964 switch (res >> 26) {
15965 case ALC880_HP_EVENT:
15966 alc663_m51va_speaker_automute(codec);
15967 break;
15968 case ALC880_MIC_EVENT:
15969 alc662_eeepc_mic_automute(codec);
15970 break;
15971 }
15972}
15973
15974static void alc663_mode1_inithook(struct hda_codec *codec)
15975{
15976 alc663_m51va_speaker_automute(codec);
15977 alc662_eeepc_mic_automute(codec);
15978}
15979/* ***************** Mode2 ******************************/
15980static void alc662_mode2_unsol_event(struct hda_codec *codec,
15981 unsigned int res)
15982{
15983 switch (res >> 26) {
15984 case ALC880_HP_EVENT:
15985 alc662_f5z_speaker_automute(codec);
15986 break;
15987 case ALC880_MIC_EVENT:
15988 alc662_eeepc_mic_automute(codec);
15989 break;
15990 }
15991}
15992
15993static void alc662_mode2_inithook(struct hda_codec *codec)
15994{
15995 alc662_f5z_speaker_automute(codec);
15996 alc662_eeepc_mic_automute(codec);
15997}
15998/* ***************** Mode3 ******************************/
15999static void alc663_mode3_unsol_event(struct hda_codec *codec,
16000 unsigned int res)
16001{
16002 switch (res >> 26) {
16003 case ALC880_HP_EVENT:
16004 alc663_two_hp_m1_speaker_automute(codec);
16005 break;
16006 case ALC880_MIC_EVENT:
16007 alc662_eeepc_mic_automute(codec);
16008 break;
16009 }
16010}
16011
16012static void alc663_mode3_inithook(struct hda_codec *codec)
16013{
16014 alc663_two_hp_m1_speaker_automute(codec);
16015 alc662_eeepc_mic_automute(codec);
16016}
16017/* ***************** Mode4 ******************************/
16018static void alc663_mode4_unsol_event(struct hda_codec *codec,
16019 unsigned int res)
16020{
16021 switch (res >> 26) {
16022 case ALC880_HP_EVENT:
16023 alc663_21jd_two_speaker_automute(codec);
16024 break;
16025 case ALC880_MIC_EVENT:
16026 alc662_eeepc_mic_automute(codec);
16027 break;
16028 }
16029}
16030
16031static void alc663_mode4_inithook(struct hda_codec *codec)
16032{
16033 alc663_21jd_two_speaker_automute(codec);
16034 alc662_eeepc_mic_automute(codec);
16035}
16036/* ***************** Mode5 ******************************/
16037static void alc663_mode5_unsol_event(struct hda_codec *codec,
16038 unsigned int res)
16039{
16040 switch (res >> 26) {
16041 case ALC880_HP_EVENT:
16042 alc663_15jd_two_speaker_automute(codec);
16043 break;
16044 case ALC880_MIC_EVENT:
16045 alc662_eeepc_mic_automute(codec);
16046 break;
16047 }
16048}
16049
16050static void alc663_mode5_inithook(struct hda_codec *codec)
16051{
16052 alc663_15jd_two_speaker_automute(codec);
16053 alc662_eeepc_mic_automute(codec);
16054}
16055/* ***************** Mode6 ******************************/
16056static void alc663_mode6_unsol_event(struct hda_codec *codec,
16057 unsigned int res)
16058{
16059 switch (res >> 26) {
16060 case ALC880_HP_EVENT:
16061 alc663_two_hp_m2_speaker_automute(codec);
16062 break;
16063 case ALC880_MIC_EVENT:
16064 alc662_eeepc_mic_automute(codec);
16065 break;
16066 }
16067}
16068
16069static void alc663_mode6_inithook(struct hda_codec *codec)
16070{
16071 alc663_two_hp_m2_speaker_automute(codec);
16072 alc662_eeepc_mic_automute(codec);
16073}
16074
Kailang Yang6dda9f42008-05-27 12:05:31 +020016075static void alc663_g71v_hp_automute(struct hda_codec *codec)
16076{
16077 unsigned int present;
16078 unsigned char bits;
16079
16080 present = snd_hda_codec_read(codec, 0x21, 0,
16081 AC_VERB_GET_PIN_SENSE, 0)
16082 & AC_PINSENSE_PRESENCE;
16083 bits = present ? HDA_AMP_MUTE : 0;
16084 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16085 HDA_AMP_MUTE, bits);
16086 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16087 HDA_AMP_MUTE, bits);
16088}
16089
16090static void alc663_g71v_front_automute(struct hda_codec *codec)
16091{
16092 unsigned int present;
16093 unsigned char bits;
16094
16095 present = snd_hda_codec_read(codec, 0x15, 0,
16096 AC_VERB_GET_PIN_SENSE, 0)
16097 & AC_PINSENSE_PRESENCE;
16098 bits = present ? HDA_AMP_MUTE : 0;
16099 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16100 HDA_AMP_MUTE, bits);
16101}
16102
16103static void alc663_g71v_unsol_event(struct hda_codec *codec,
16104 unsigned int res)
16105{
16106 switch (res >> 26) {
16107 case ALC880_HP_EVENT:
16108 alc663_g71v_hp_automute(codec);
16109 break;
16110 case ALC880_FRONT_EVENT:
16111 alc663_g71v_front_automute(codec);
16112 break;
16113 case ALC880_MIC_EVENT:
16114 alc662_eeepc_mic_automute(codec);
16115 break;
16116 }
16117}
16118
16119static void alc663_g71v_inithook(struct hda_codec *codec)
16120{
16121 alc663_g71v_front_automute(codec);
16122 alc663_g71v_hp_automute(codec);
16123 alc662_eeepc_mic_automute(codec);
16124}
16125
16126static void alc663_g50v_unsol_event(struct hda_codec *codec,
16127 unsigned int res)
16128{
16129 switch (res >> 26) {
16130 case ALC880_HP_EVENT:
16131 alc663_m51va_speaker_automute(codec);
16132 break;
16133 case ALC880_MIC_EVENT:
16134 alc662_eeepc_mic_automute(codec);
16135 break;
16136 }
16137}
16138
16139static void alc663_g50v_inithook(struct hda_codec *codec)
16140{
16141 alc663_m51va_speaker_automute(codec);
16142 alc662_eeepc_mic_automute(codec);
16143}
16144
Kailang Yangf1d4e282008-08-26 14:03:29 +020016145static struct snd_kcontrol_new alc662_ecs_mixer[] = {
16146 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020016147 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016148
16149 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
16150 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
16151 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
16152
16153 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16154 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16155 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16156 { } /* end */
16157};
16158
Chris Pockelé9541ba12009-05-12 08:08:53 +020016159static struct snd_kcontrol_new alc272_nc10_mixer[] = {
16160 /* Master Playback automatically created from Speaker and Headphone */
16161 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16162 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16163 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16164 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16165
16166 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16167 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16168 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
16169
16170 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16171 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16172 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
16173 { } /* end */
16174};
16175
Takashi Iwaicb53c622007-08-10 17:21:45 +020016176#ifdef CONFIG_SND_HDA_POWER_SAVE
16177#define alc662_loopbacks alc880_loopbacks
16178#endif
16179
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016180
16181/* pcm configuration: identiacal with ALC880 */
16182#define alc662_pcm_analog_playback alc880_pcm_analog_playback
16183#define alc662_pcm_analog_capture alc880_pcm_analog_capture
16184#define alc662_pcm_digital_playback alc880_pcm_digital_playback
16185#define alc662_pcm_digital_capture alc880_pcm_digital_capture
16186
16187/*
16188 * configuration and preset
16189 */
16190static const char *alc662_models[ALC662_MODEL_LAST] = {
16191 [ALC662_3ST_2ch_DIG] = "3stack-dig",
16192 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
16193 [ALC662_3ST_6ch] = "3stack-6ch",
16194 [ALC662_5ST_DIG] = "6stack-dig",
16195 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020016196 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010016197 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016198 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020016199 [ALC663_ASUS_M51VA] = "m51va",
16200 [ALC663_ASUS_G71V] = "g71v",
16201 [ALC663_ASUS_H13] = "h13",
16202 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016203 [ALC663_ASUS_MODE1] = "asus-mode1",
16204 [ALC662_ASUS_MODE2] = "asus-mode2",
16205 [ALC663_ASUS_MODE3] = "asus-mode3",
16206 [ALC663_ASUS_MODE4] = "asus-mode4",
16207 [ALC663_ASUS_MODE5] = "asus-mode5",
16208 [ALC663_ASUS_MODE6] = "asus-mode6",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020016209 [ALC272_DELL] = "dell",
16210 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020016211 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016212 [ALC662_AUTO] = "auto",
16213};
16214
16215static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010016216 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020016217 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
16218 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016219 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
16220 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
16221 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
16222 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
16223 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
16224 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
16225 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
16226 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
16227 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
16228 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
16229 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
16230 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016231 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
16232 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
16233 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016234 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
16235 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
16236 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
16237 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016238 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016239 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
16240 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016241 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016242 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
16243 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
16244 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020016245 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
16246 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
16247 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016248 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
16249 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
16250 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016251 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016252 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
16253 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020016254 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016255 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020016256 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016257 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
16258 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
16259 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016260 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016261 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
16262 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010016263 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020016264 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010016265 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016266 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030016267 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
16268 ALC662_3ST_6ch_DIG),
Chris Pockelé9541ba12009-05-12 08:08:53 +020016269 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030016270 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
16271 ALC662_3ST_6ch_DIG),
Vedran Miletic19c009a2008-09-29 20:29:25 +020016272 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020016273 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016274 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020016275 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020016276 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016277 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
16278 ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016279 {}
16280};
16281
16282static struct alc_config_preset alc662_presets[] = {
16283 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016284 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016285 .init_verbs = { alc662_init_verbs },
16286 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16287 .dac_nids = alc662_dac_nids,
16288 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016289 .dig_in_nid = ALC662_DIGIN_NID,
16290 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16291 .channel_mode = alc662_3ST_2ch_modes,
16292 .input_mux = &alc662_capture_source,
16293 },
16294 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016295 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016296 .init_verbs = { alc662_init_verbs },
16297 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16298 .dac_nids = alc662_dac_nids,
16299 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016300 .dig_in_nid = ALC662_DIGIN_NID,
16301 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16302 .channel_mode = alc662_3ST_6ch_modes,
16303 .need_dac_fix = 1,
16304 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016305 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016306 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016307 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016308 .init_verbs = { alc662_init_verbs },
16309 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16310 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016311 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16312 .channel_mode = alc662_3ST_6ch_modes,
16313 .need_dac_fix = 1,
16314 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016315 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016316 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016317 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016318 .init_verbs = { alc662_init_verbs },
16319 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16320 .dac_nids = alc662_dac_nids,
16321 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016322 .dig_in_nid = ALC662_DIGIN_NID,
16323 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
16324 .channel_mode = alc662_5stack_modes,
16325 .input_mux = &alc662_capture_source,
16326 },
16327 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016328 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016329 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
16330 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16331 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016332 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16333 .channel_mode = alc662_3ST_2ch_modes,
16334 .input_mux = &alc662_lenovo_101e_capture_source,
16335 .unsol_event = alc662_lenovo_101e_unsol_event,
16336 .init_hook = alc662_lenovo_101e_all_automute,
16337 },
Kailang Yang291702f2007-10-16 14:28:03 +020016338 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016339 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020016340 .init_verbs = { alc662_init_verbs,
16341 alc662_eeepc_sue_init_verbs },
16342 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16343 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020016344 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16345 .channel_mode = alc662_3ST_2ch_modes,
16346 .input_mux = &alc662_eeepc_capture_source,
16347 .unsol_event = alc662_eeepc_unsol_event,
16348 .init_hook = alc662_eeepc_inithook,
16349 },
Kailang Yang8c427222008-01-10 13:03:59 +010016350 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016351 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010016352 alc662_chmode_mixer },
16353 .init_verbs = { alc662_init_verbs,
16354 alc662_eeepc_ep20_sue_init_verbs },
16355 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16356 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010016357 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16358 .channel_mode = alc662_3ST_6ch_modes,
16359 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020016360 .unsol_event = alc662_eeepc_unsol_event,
Kailang Yang8c427222008-01-10 13:03:59 +010016361 .init_hook = alc662_eeepc_ep20_inithook,
16362 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016363 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016364 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016365 .init_verbs = { alc662_init_verbs,
16366 alc662_ecs_init_verbs },
16367 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16368 .dac_nids = alc662_dac_nids,
16369 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16370 .channel_mode = alc662_3ST_2ch_modes,
16371 .input_mux = &alc662_eeepc_capture_source,
16372 .unsol_event = alc662_eeepc_unsol_event,
16373 .init_hook = alc662_eeepc_inithook,
16374 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016375 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016376 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016377 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16378 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16379 .dac_nids = alc662_dac_nids,
16380 .dig_out_nid = ALC662_DIGOUT_NID,
16381 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16382 .channel_mode = alc662_3ST_2ch_modes,
16383 .input_mux = &alc663_m51va_capture_source,
16384 .unsol_event = alc663_m51va_unsol_event,
16385 .init_hook = alc663_m51va_inithook,
16386 },
16387 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016388 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016389 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
16390 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16391 .dac_nids = alc662_dac_nids,
16392 .dig_out_nid = ALC662_DIGOUT_NID,
16393 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16394 .channel_mode = alc662_3ST_2ch_modes,
16395 .input_mux = &alc662_eeepc_capture_source,
16396 .unsol_event = alc663_g71v_unsol_event,
16397 .init_hook = alc663_g71v_inithook,
16398 },
16399 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016400 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016401 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16402 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16403 .dac_nids = alc662_dac_nids,
16404 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16405 .channel_mode = alc662_3ST_2ch_modes,
16406 .input_mux = &alc663_m51va_capture_source,
16407 .unsol_event = alc663_m51va_unsol_event,
16408 .init_hook = alc663_m51va_inithook,
16409 },
16410 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016411 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016412 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
16413 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16414 .dac_nids = alc662_dac_nids,
16415 .dig_out_nid = ALC662_DIGOUT_NID,
16416 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16417 .channel_mode = alc662_3ST_6ch_modes,
16418 .input_mux = &alc663_capture_source,
16419 .unsol_event = alc663_g50v_unsol_event,
16420 .init_hook = alc663_g50v_inithook,
16421 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016422 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016423 .mixers = { alc663_m51va_mixer },
16424 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016425 .init_verbs = { alc662_init_verbs,
16426 alc663_21jd_amic_init_verbs },
16427 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16428 .hp_nid = 0x03,
16429 .dac_nids = alc662_dac_nids,
16430 .dig_out_nid = ALC662_DIGOUT_NID,
16431 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16432 .channel_mode = alc662_3ST_2ch_modes,
16433 .input_mux = &alc662_eeepc_capture_source,
16434 .unsol_event = alc663_mode1_unsol_event,
16435 .init_hook = alc663_mode1_inithook,
16436 },
16437 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016438 .mixers = { alc662_1bjd_mixer },
16439 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016440 .init_verbs = { alc662_init_verbs,
16441 alc662_1bjd_amic_init_verbs },
16442 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16443 .dac_nids = alc662_dac_nids,
16444 .dig_out_nid = ALC662_DIGOUT_NID,
16445 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16446 .channel_mode = alc662_3ST_2ch_modes,
16447 .input_mux = &alc662_eeepc_capture_source,
16448 .unsol_event = alc662_mode2_unsol_event,
16449 .init_hook = alc662_mode2_inithook,
16450 },
16451 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016452 .mixers = { alc663_two_hp_m1_mixer },
16453 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016454 .init_verbs = { alc662_init_verbs,
16455 alc663_two_hp_amic_m1_init_verbs },
16456 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16457 .hp_nid = 0x03,
16458 .dac_nids = alc662_dac_nids,
16459 .dig_out_nid = ALC662_DIGOUT_NID,
16460 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16461 .channel_mode = alc662_3ST_2ch_modes,
16462 .input_mux = &alc662_eeepc_capture_source,
16463 .unsol_event = alc663_mode3_unsol_event,
16464 .init_hook = alc663_mode3_inithook,
16465 },
16466 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016467 .mixers = { alc663_asus_21jd_clfe_mixer },
16468 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016469 .init_verbs = { alc662_init_verbs,
16470 alc663_21jd_amic_init_verbs},
16471 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16472 .hp_nid = 0x03,
16473 .dac_nids = alc662_dac_nids,
16474 .dig_out_nid = ALC662_DIGOUT_NID,
16475 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16476 .channel_mode = alc662_3ST_2ch_modes,
16477 .input_mux = &alc662_eeepc_capture_source,
16478 .unsol_event = alc663_mode4_unsol_event,
16479 .init_hook = alc663_mode4_inithook,
16480 },
16481 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016482 .mixers = { alc663_asus_15jd_clfe_mixer },
16483 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016484 .init_verbs = { alc662_init_verbs,
16485 alc663_15jd_amic_init_verbs },
16486 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16487 .hp_nid = 0x03,
16488 .dac_nids = alc662_dac_nids,
16489 .dig_out_nid = ALC662_DIGOUT_NID,
16490 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16491 .channel_mode = alc662_3ST_2ch_modes,
16492 .input_mux = &alc662_eeepc_capture_source,
16493 .unsol_event = alc663_mode5_unsol_event,
16494 .init_hook = alc663_mode5_inithook,
16495 },
16496 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016497 .mixers = { alc663_two_hp_m2_mixer },
16498 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016499 .init_verbs = { alc662_init_verbs,
16500 alc663_two_hp_amic_m2_init_verbs },
16501 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16502 .hp_nid = 0x03,
16503 .dac_nids = alc662_dac_nids,
16504 .dig_out_nid = ALC662_DIGOUT_NID,
16505 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16506 .channel_mode = alc662_3ST_2ch_modes,
16507 .input_mux = &alc662_eeepc_capture_source,
16508 .unsol_event = alc663_mode6_unsol_event,
16509 .init_hook = alc663_mode6_inithook,
16510 },
Kailang Yang622e84c2009-04-21 07:39:04 +020016511 [ALC272_DELL] = {
16512 .mixers = { alc663_m51va_mixer },
16513 .cap_mixer = alc272_auto_capture_mixer,
16514 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
16515 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
16516 .dac_nids = alc662_dac_nids,
16517 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16518 .adc_nids = alc272_adc_nids,
16519 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
16520 .capsrc_nids = alc272_capsrc_nids,
16521 .channel_mode = alc662_3ST_2ch_modes,
16522 .input_mux = &alc663_m51va_capture_source,
16523 .unsol_event = alc663_m51va_unsol_event,
16524 .init_hook = alc663_m51va_inithook,
16525 },
16526 [ALC272_DELL_ZM1] = {
16527 .mixers = { alc663_m51va_mixer },
16528 .cap_mixer = alc662_auto_capture_mixer,
16529 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
16530 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
16531 .dac_nids = alc662_dac_nids,
16532 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16533 .adc_nids = alc662_adc_nids,
16534 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
16535 .capsrc_nids = alc662_capsrc_nids,
16536 .channel_mode = alc662_3ST_2ch_modes,
16537 .input_mux = &alc663_m51va_capture_source,
16538 .unsol_event = alc663_m51va_unsol_event,
16539 .init_hook = alc663_m51va_inithook,
16540 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020016541 [ALC272_SAMSUNG_NC10] = {
16542 .mixers = { alc272_nc10_mixer },
16543 .init_verbs = { alc662_init_verbs,
16544 alc663_21jd_amic_init_verbs },
16545 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
16546 .dac_nids = alc272_dac_nids,
16547 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16548 .channel_mode = alc662_3ST_2ch_modes,
16549 .input_mux = &alc272_nc10_capture_source,
16550 .unsol_event = alc663_mode4_unsol_event,
16551 .init_hook = alc663_mode4_inithook,
16552 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016553};
16554
16555
16556/*
16557 * BIOS auto configuration
16558 */
16559
16560/* add playback controls from the parsed DAC table */
16561static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
16562 const struct auto_pin_cfg *cfg)
16563{
16564 char name[32];
16565 static const char *chname[4] = {
16566 "Front", "Surround", NULL /*CLFE*/, "Side"
16567 };
16568 hda_nid_t nid;
16569 int i, err;
16570
16571 for (i = 0; i < cfg->line_outs; i++) {
16572 if (!spec->multiout.dac_nids[i])
16573 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020016574 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016575 if (i == 2) {
16576 /* Center/LFE */
16577 err = add_control(spec, ALC_CTL_WIDGET_VOL,
16578 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016579 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
16580 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016581 if (err < 0)
16582 return err;
16583 err = add_control(spec, ALC_CTL_WIDGET_VOL,
16584 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016585 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
16586 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016587 if (err < 0)
16588 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016589 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016590 "Center Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016591 HDA_COMPOSE_AMP_VAL(0x0e, 1, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016592 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016593 if (err < 0)
16594 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016595 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016596 "LFE Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016597 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016598 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016599 if (err < 0)
16600 return err;
16601 } else {
16602 sprintf(name, "%s Playback Volume", chname[i]);
16603 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016604 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
16605 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016606 if (err < 0)
16607 return err;
16608 sprintf(name, "%s Playback Switch", chname[i]);
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016609 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16610 HDA_COMPOSE_AMP_VAL(alc880_idx_to_mixer(i),
16611 3, 0, HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016612 if (err < 0)
16613 return err;
16614 }
16615 }
16616 return 0;
16617}
16618
16619/* add playback controls for speaker and HP outputs */
16620static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
16621 const char *pfx)
16622{
16623 hda_nid_t nid;
16624 int err;
16625 char name[32];
16626
16627 if (!pin)
16628 return 0;
16629
Takashi Iwai24fb9172008-09-02 14:48:20 +020016630 if (pin == 0x17) {
16631 /* ALC663 has a mono output pin on 0x17 */
16632 sprintf(name, "%s Playback Switch", pfx);
16633 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16634 HDA_COMPOSE_AMP_VAL(pin, 2, 0, HDA_OUTPUT));
16635 return err;
16636 }
16637
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016638 if (alc880_is_fixed_pin(pin)) {
16639 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai939778a2009-02-05 15:57:55 +010016640 /* printk(KERN_DEBUG "DAC nid=%x\n",nid); */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016641 /* specify the DAC as the extra output */
16642 if (!spec->multiout.hp_nid)
16643 spec->multiout.hp_nid = nid;
16644 else
16645 spec->multiout.extra_out_nid[0] = nid;
16646 /* control HP volume/switch on the output mixer amp */
16647 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16648 sprintf(name, "%s Playback Volume", pfx);
16649 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
16650 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
16651 if (err < 0)
16652 return err;
16653 sprintf(name, "%s Playback Switch", pfx);
16654 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
16655 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
16656 if (err < 0)
16657 return err;
16658 } else if (alc880_is_multi_pin(pin)) {
16659 /* set manual connection */
16660 /* we have only a switch on HP-out PIN */
16661 sprintf(name, "%s Playback Switch", pfx);
16662 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16663 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
16664 if (err < 0)
16665 return err;
16666 }
16667 return 0;
16668}
16669
Takashi Iwai2d864c42009-03-20 12:52:47 +010016670/* return the index of the src widget from the connection list of the nid.
16671 * return -1 if not found
16672 */
16673static int alc662_input_pin_idx(struct hda_codec *codec, hda_nid_t nid,
16674 hda_nid_t src)
16675{
16676 hda_nid_t conn_list[HDA_MAX_CONNECTIONS];
16677 int i, conns;
16678
16679 conns = snd_hda_get_connections(codec, nid, conn_list,
16680 ARRAY_SIZE(conn_list));
16681 if (conns < 0)
16682 return -1;
16683 for (i = 0; i < conns; i++)
16684 if (conn_list[i] == src)
16685 return i;
16686 return -1;
16687}
16688
16689static int alc662_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
16690{
Takashi Iwai1327a322009-03-23 13:07:47 +010016691 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai2d864c42009-03-20 12:52:47 +010016692 return (pincap & AC_PINCAP_IN) != 0;
16693}
16694
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016695/* create playback/capture controls for input pins */
Takashi Iwai2d864c42009-03-20 12:52:47 +010016696static int alc662_auto_create_analog_input_ctls(struct hda_codec *codec,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016697 const struct auto_pin_cfg *cfg)
16698{
Takashi Iwai2d864c42009-03-20 12:52:47 +010016699 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016700 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016701 int i, err, idx;
16702
16703 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai2d864c42009-03-20 12:52:47 +010016704 if (alc662_is_input_pin(codec, cfg->input_pins[i])) {
16705 idx = alc662_input_pin_idx(codec, 0x0b,
16706 cfg->input_pins[i]);
16707 if (idx >= 0) {
16708 err = new_analog_input(spec, cfg->input_pins[i],
16709 auto_pin_cfg_labels[i],
16710 idx, 0x0b);
16711 if (err < 0)
16712 return err;
16713 }
16714 idx = alc662_input_pin_idx(codec, 0x22,
16715 cfg->input_pins[i]);
16716 if (idx >= 0) {
16717 imux->items[imux->num_items].label =
16718 auto_pin_cfg_labels[i];
16719 imux->items[imux->num_items].index = idx;
16720 imux->num_items++;
16721 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016722 }
16723 }
16724 return 0;
16725}
16726
16727static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
16728 hda_nid_t nid, int pin_type,
16729 int dac_idx)
16730{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016731 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016732 /* need the manual connection? */
16733 if (alc880_is_multi_pin(nid)) {
16734 struct alc_spec *spec = codec->spec;
16735 int idx = alc880_multi_pin_idx(nid);
16736 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
16737 AC_VERB_SET_CONNECT_SEL,
16738 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
16739 }
16740}
16741
16742static void alc662_auto_init_multi_out(struct hda_codec *codec)
16743{
16744 struct alc_spec *spec = codec->spec;
16745 int i;
16746
16747 for (i = 0; i <= HDA_SIDE; i++) {
16748 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016749 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016750 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016751 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016752 i);
16753 }
16754}
16755
16756static void alc662_auto_init_hp_out(struct hda_codec *codec)
16757{
16758 struct alc_spec *spec = codec->spec;
16759 hda_nid_t pin;
16760
16761 pin = spec->autocfg.hp_pins[0];
16762 if (pin) /* connect to front */
16763 /* use dac 0 */
16764 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016765 pin = spec->autocfg.speaker_pins[0];
16766 if (pin)
16767 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016768}
16769
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016770#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
16771
16772static void alc662_auto_init_analog_input(struct hda_codec *codec)
16773{
16774 struct alc_spec *spec = codec->spec;
16775 int i;
16776
16777 for (i = 0; i < AUTO_PIN_LAST; i++) {
16778 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai2d864c42009-03-20 12:52:47 +010016779 if (alc662_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010016780 alc_set_input_pin(codec, nid, i);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010016781 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010016782 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016783 snd_hda_codec_write(codec, nid, 0,
16784 AC_VERB_SET_AMP_GAIN_MUTE,
16785 AMP_OUT_MUTE);
16786 }
16787 }
16788}
16789
Takashi Iwaif511b012008-08-15 16:46:42 +020016790#define alc662_auto_init_input_src alc882_auto_init_input_src
16791
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016792static int alc662_parse_auto_config(struct hda_codec *codec)
16793{
16794 struct alc_spec *spec = codec->spec;
16795 int err;
16796 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
16797
16798 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
16799 alc662_ignore);
16800 if (err < 0)
16801 return err;
16802 if (!spec->autocfg.line_outs)
16803 return 0; /* can't find valid BIOS pin config */
16804
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016805 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
16806 if (err < 0)
16807 return err;
16808 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
16809 if (err < 0)
16810 return err;
16811 err = alc662_auto_create_extra_out(spec,
16812 spec->autocfg.speaker_pins[0],
16813 "Speaker");
16814 if (err < 0)
16815 return err;
16816 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
16817 "Headphone");
16818 if (err < 0)
16819 return err;
Takashi Iwai2d864c42009-03-20 12:52:47 +010016820 err = alc662_auto_create_analog_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016821 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016822 return err;
16823
16824 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
16825
Takashi Iwai0852d7a2009-02-11 11:35:15 +010016826 if (spec->autocfg.dig_outs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016827 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
16828
Takashi Iwai603c4012008-07-30 15:01:44 +020016829 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016830 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016831
16832 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016833 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020016834
Takashi Iwaid88897e2008-10-31 15:01:37 +010016835 add_verb(spec, alc662_auto_init_verbs);
Takashi Iwai24fb9172008-09-02 14:48:20 +020016836 if (codec->vendor_id == 0x10ec0663)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016837 add_verb(spec, alc663_auto_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020016838
16839 err = alc_auto_add_mic_boost(codec);
16840 if (err < 0)
16841 return err;
16842
Takashi Iwai4a79ba32009-04-22 16:31:35 +020016843 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
16844
Takashi Iwai8c87286f2007-06-19 12:11:16 +020016845 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016846}
16847
16848/* additional initialization for auto-configuration model */
16849static void alc662_auto_init(struct hda_codec *codec)
16850{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016851 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016852 alc662_auto_init_multi_out(codec);
16853 alc662_auto_init_hp_out(codec);
16854 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020016855 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016856 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020016857 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016858}
16859
16860static int patch_alc662(struct hda_codec *codec)
16861{
16862 struct alc_spec *spec;
16863 int err, board_config;
16864
16865 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
16866 if (!spec)
16867 return -ENOMEM;
16868
16869 codec->spec = spec;
16870
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020016871 alc_fix_pll_init(codec, 0x20, 0x04, 15);
16872
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016873 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
16874 alc662_models,
16875 alc662_cfg_tbl);
16876 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020016877 printk(KERN_INFO "hda_codec: Unknown model for %s, "
16878 "trying auto-probe from BIOS...\n", codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016879 board_config = ALC662_AUTO;
16880 }
16881
16882 if (board_config == ALC662_AUTO) {
16883 /* automatic parse from the BIOS config */
16884 err = alc662_parse_auto_config(codec);
16885 if (err < 0) {
16886 alc_free(codec);
16887 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020016888 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016889 printk(KERN_INFO
16890 "hda_codec: Cannot set up configuration "
16891 "from BIOS. Using base mode...\n");
16892 board_config = ALC662_3ST_2ch_DIG;
16893 }
16894 }
16895
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090016896 err = snd_hda_attach_beep_device(codec, 0x1);
16897 if (err < 0) {
16898 alc_free(codec);
16899 return err;
16900 }
16901
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016902 if (board_config != ALC662_AUTO)
16903 setup_preset(spec, &alc662_presets[board_config]);
16904
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016905 spec->stream_analog_playback = &alc662_pcm_analog_playback;
16906 spec->stream_analog_capture = &alc662_pcm_analog_capture;
16907
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016908 spec->stream_digital_playback = &alc662_pcm_digital_playback;
16909 spec->stream_digital_capture = &alc662_pcm_digital_capture;
16910
Takashi Iwaie1406342008-02-11 18:32:32 +010016911 spec->adc_nids = alc662_adc_nids;
16912 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
16913 spec->capsrc_nids = alc662_capsrc_nids;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016914 spec->capture_style = CAPT_MIX;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016915
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016916 if (!spec->cap_mixer)
16917 set_capture_mixer(spec);
Takashi Iwaib9591442009-03-16 15:25:00 +010016918 if (codec->vendor_id == 0x10ec0662)
16919 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
16920 else
16921 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016922
Takashi Iwai2134ea42008-01-10 16:53:55 +010016923 spec->vmaster_nid = 0x02;
16924
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016925 codec->patch_ops = alc_patch_ops;
16926 if (board_config == ALC662_AUTO)
16927 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020016928#ifdef CONFIG_SND_HDA_POWER_SAVE
16929 if (!spec->loopback.amplist)
16930 spec->loopback.amplist = alc662_loopbacks;
16931#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010016932 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016933
16934 return 0;
16935}
16936
16937/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070016938 * patch entries
16939 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010016940static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070016941 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010016942 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016943 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020016944 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016945 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020016946 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016947 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016948 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016949 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
16950 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
16951 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016952 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
16953 .patch = patch_alc883 },
16954 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
16955 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016956 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016957 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070016958 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016959 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Clive Messer669faba2008-09-30 15:49:13 +020016960 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
16961 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Takashi Iwaicb308f92008-04-16 14:13:29 +020016962 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai7943a8a2008-04-16 17:29:09 +020016963 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Kailang Yangdf694da2005-12-05 19:42:22 +010016964 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Kailang Yanga385a522008-10-15 11:20:21 +020016965 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc883 },
Kailang Yang44426082008-10-15 11:18:05 +020016966 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
16967 .patch = patch_alc883 },
Wu Fengguang3fea2cb2008-12-26 12:20:43 +080016968 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016969 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070016970 {} /* terminator */
16971};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010016972
16973MODULE_ALIAS("snd-hda-codec-id:10ec*");
16974
16975MODULE_LICENSE("GPL");
16976MODULE_DESCRIPTION("Realtek HD-audio codec");
16977
16978static struct hda_codec_preset_list realtek_list = {
16979 .preset = snd_hda_preset_realtek,
16980 .owner = THIS_MODULE,
16981};
16982
16983static int __init patch_realtek_init(void)
16984{
16985 return snd_hda_add_codec_preset(&realtek_list);
16986}
16987
16988static void __exit patch_realtek_exit(void)
16989{
16990 snd_hda_delete_codec_preset(&realtek_list);
16991}
16992
16993module_init(patch_realtek_init)
16994module_exit(patch_realtek_exit)