blob: 4bc3e7e535554fa967205c524feb3bf4e3e6168b [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 Iwai9c7f8522006-06-28 15:08:22 +02004413 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
4414 "trying auto-probe from BIOS...\n");
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 Iwai9c7f8522006-06-28 15:08:22 +02006057 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
6058 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006059 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02006060 }
6061
Kailang Yangdf694da2005-12-05 19:42:22 +01006062 if (board_config == ALC260_AUTO) {
6063 /* automatic parse from the BIOS config */
6064 err = alc260_parse_auto_config(codec);
6065 if (err < 0) {
6066 alc_free(codec);
6067 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006068 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006069 printk(KERN_INFO
6070 "hda_codec: Cannot set up configuration "
6071 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006072 board_config = ALC260_BASIC;
6073 }
Takashi Iwai16ded522005-06-10 19:58:24 +02006074 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006075
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09006076 err = snd_hda_attach_beep_device(codec, 0x1);
6077 if (err < 0) {
6078 alc_free(codec);
6079 return err;
6080 }
6081
Kailang Yangdf694da2005-12-05 19:42:22 +01006082 if (board_config != ALC260_AUTO)
6083 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006084
Linus Torvalds1da177e2005-04-16 15:20:36 -07006085 spec->stream_analog_playback = &alc260_pcm_analog_playback;
6086 spec->stream_analog_capture = &alc260_pcm_analog_capture;
6087
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006088 spec->stream_digital_playback = &alc260_pcm_digital_playback;
6089 spec->stream_digital_capture = &alc260_pcm_digital_capture;
6090
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006091 if (!spec->adc_nids && spec->input_mux) {
6092 /* check whether NID 0x04 is valid */
6093 unsigned int wcap = get_wcaps(codec, 0x04);
6094 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
6095 /* get type */
6096 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
6097 spec->adc_nids = alc260_adc_nids_alt;
6098 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
6099 } else {
6100 spec->adc_nids = alc260_adc_nids;
6101 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
6102 }
6103 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006104 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006105 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006106
Takashi Iwai2134ea42008-01-10 16:53:55 +01006107 spec->vmaster_nid = 0x08;
6108
Linus Torvalds1da177e2005-04-16 15:20:36 -07006109 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006110 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006111 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006112#ifdef CONFIG_SND_HDA_POWER_SAVE
6113 if (!spec->loopback.amplist)
6114 spec->loopback.amplist = alc260_loopbacks;
6115#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01006116 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006117
6118 return 0;
6119}
6120
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006121
Linus Torvalds1da177e2005-04-16 15:20:36 -07006122/*
6123 * ALC882 support
6124 *
6125 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
6126 * configuration. Each pin widget can choose any input DACs and a mixer.
6127 * Each ADC is connected from a mixer of all inputs. This makes possible
6128 * 6-channel independent captures.
6129 *
6130 * In addition, an independent DAC for the multi-playback (not used in this
6131 * driver yet).
6132 */
Kailang Yangdf694da2005-12-05 19:42:22 +01006133#define ALC882_DIGOUT_NID 0x06
6134#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07006135
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01006136static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07006137 { 8, NULL }
6138};
6139
6140static hda_nid_t alc882_dac_nids[4] = {
6141 /* front, rear, clfe, rear_surr */
6142 0x02, 0x03, 0x04, 0x05
6143};
6144
Kailang Yangdf694da2005-12-05 19:42:22 +01006145/* identical with ALC880 */
6146#define alc882_adc_nids alc880_adc_nids
6147#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07006148
Takashi Iwaie1406342008-02-11 18:32:32 +01006149static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
6150static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
6151
Linus Torvalds1da177e2005-04-16 15:20:36 -07006152/* input MUX */
6153/* FIXME: should be a matrix-type input source selection */
6154
6155static struct hda_input_mux alc882_capture_source = {
6156 .num_items = 4,
6157 .items = {
6158 { "Mic", 0x0 },
6159 { "Front Mic", 0x1 },
6160 { "Line", 0x2 },
6161 { "CD", 0x4 },
6162 },
6163};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006164
6165static struct hda_input_mux mb5_capture_source = {
6166 .num_items = 3,
6167 .items = {
6168 { "Mic", 0x1 },
6169 { "Line", 0x2 },
6170 { "CD", 0x4 },
6171 },
6172};
6173
Kailang Yangdf694da2005-12-05 19:42:22 +01006174/*
Kailang Yang272a5272007-05-14 11:00:38 +02006175 * 2ch mode
6176 */
6177static struct hda_verb alc882_3ST_ch2_init[] = {
6178 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6179 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6180 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6181 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6182 { } /* end */
6183};
6184
6185/*
6186 * 6ch mode
6187 */
6188static struct hda_verb alc882_3ST_ch6_init[] = {
6189 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6190 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6191 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6192 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6193 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6194 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6195 { } /* end */
6196};
6197
6198static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
6199 { 2, alc882_3ST_ch2_init },
6200 { 6, alc882_3ST_ch6_init },
6201};
6202
6203/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006204 * 6ch mode
6205 */
6206static struct hda_verb alc882_sixstack_ch6_init[] = {
6207 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6208 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6209 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6210 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6211 { } /* end */
6212};
6213
6214/*
6215 * 8ch mode
6216 */
6217static struct hda_verb alc882_sixstack_ch8_init[] = {
6218 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6219 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6220 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6221 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6222 { } /* end */
6223};
6224
6225static struct hda_channel_mode alc882_sixstack_modes[2] = {
6226 { 6, alc882_sixstack_ch6_init },
6227 { 8, alc882_sixstack_ch8_init },
6228};
6229
Takashi Iwai87350ad2007-08-16 18:19:38 +02006230/*
6231 * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
6232 */
6233
6234/*
6235 * 2ch mode
6236 */
6237static struct hda_verb alc885_mbp_ch2_init[] = {
6238 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6239 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6240 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6241 { } /* end */
6242};
6243
6244/*
6245 * 6ch mode
6246 */
6247static struct hda_verb alc885_mbp_ch6_init[] = {
6248 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6249 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6250 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6251 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6252 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6253 { } /* end */
6254};
6255
6256static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
6257 { 2, alc885_mbp_ch2_init },
6258 { 6, alc885_mbp_ch6_init },
6259};
6260
6261
Linus Torvalds1da177e2005-04-16 15:20:36 -07006262/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6263 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6264 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01006265static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02006266 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006267 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006268 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006269 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006270 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6271 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006272 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6273 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006274 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006275 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006276 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6277 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6278 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6279 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6280 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6281 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006282 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006283 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6284 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006285 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006286 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006287 { } /* end */
6288};
6289
Takashi Iwai87350ad2007-08-16 18:19:38 +02006290static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01006291 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6292 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
6293 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
6294 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
6295 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6296 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006297 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
6298 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01006299 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006300 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
6301 { } /* end */
6302};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006303
6304static struct snd_kcontrol_new alc885_mb5_mixer[] = {
6305 HDA_CODEC_VOLUME("Front Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
6306 HDA_BIND_MUTE ("Front Playback Switch", 0x0d, 0x02, HDA_INPUT),
6307 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6308 HDA_BIND_MUTE ("Line-Out Playback Switch", 0x0c, 0x02, HDA_INPUT),
6309 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6310 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6311 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
6312 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
6313 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
6314 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0x00, HDA_INPUT),
6315 { } /* end */
6316};
Kailang Yangbdd148a2007-05-08 15:19:08 +02006317static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
6318 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6319 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6320 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6321 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6322 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6323 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6324 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6325 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6326 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02006327 { } /* end */
6328};
6329
Kailang Yang272a5272007-05-14 11:00:38 +02006330static struct snd_kcontrol_new alc882_targa_mixer[] = {
6331 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6332 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6333 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6334 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6335 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6336 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6337 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6338 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6339 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006340 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006341 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6342 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006343 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006344 { } /* end */
6345};
6346
6347/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
6348 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
6349 */
6350static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
6351 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6352 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6353 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6354 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
6355 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6356 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6357 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6358 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6359 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
6360 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
6361 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6362 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006363 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006364 { } /* end */
6365};
6366
Takashi Iwai914759b2007-09-06 14:52:04 +02006367static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
6368 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6369 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6370 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6371 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6372 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6373 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6374 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6375 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6376 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6377 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02006378 { } /* end */
6379};
6380
Kailang Yangdf694da2005-12-05 19:42:22 +01006381static struct snd_kcontrol_new alc882_chmode_mixer[] = {
6382 {
6383 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6384 .name = "Channel Mode",
6385 .info = alc_ch_mode_info,
6386 .get = alc_ch_mode_get,
6387 .put = alc_ch_mode_put,
6388 },
6389 { } /* end */
6390};
6391
Linus Torvalds1da177e2005-04-16 15:20:36 -07006392static struct hda_verb alc882_init_verbs[] = {
6393 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006394 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6395 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6396 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006397 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006398 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6399 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6400 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006401 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006402 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6403 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6404 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006405 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006406 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6407 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6408 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006409
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006410 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006411 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006412 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006413 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006414 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006415 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006416 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006417 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006418 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006419 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006420 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006421 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006422 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006423 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006424 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006425 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006426 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006427 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006428 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6429 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006430 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006431 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6432 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006433 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006434 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6435 /* Line-2 In: Headphone output (output 0 - 0x0c) */
6436 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6437 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6438 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006439 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006440 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006441
6442 /* FIXME: use matrix-type input source selection */
6443 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6444 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02006445 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6446 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6447 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6448 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006449 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006450 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6451 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6452 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6453 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006454 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006455 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6456 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6457 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6458 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6459 /* ADC1: mute amp left and right */
6460 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006461 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02006462 /* ADC2: mute amp left and right */
6463 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006464 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02006465 /* ADC3: mute amp left and right */
6466 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006467 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006468
6469 { }
6470};
6471
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006472static struct hda_verb alc882_eapd_verbs[] = {
6473 /* change to EAPD mode */
6474 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006475 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006476 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006477};
6478
Tobin Davis9102cd12006-12-15 10:02:12 +01006479/* Mac Pro test */
6480static struct snd_kcontrol_new alc882_macpro_mixer[] = {
6481 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6482 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6483 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
6484 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
6485 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006486 /* FIXME: this looks suspicious...
Tobin Davis9102cd12006-12-15 10:02:12 +01006487 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
6488 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006489 */
Tobin Davis9102cd12006-12-15 10:02:12 +01006490 { } /* end */
6491};
6492
6493static struct hda_verb alc882_macpro_init_verbs[] = {
6494 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6495 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6496 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6497 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6498 /* Front Pin: output 0 (0x0c) */
6499 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6500 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6501 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6502 /* Front Mic pin: input vref at 80% */
6503 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6504 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6505 /* Speaker: output */
6506 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6507 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6508 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
6509 /* Headphone output (output 0 - 0x0c) */
6510 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6511 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6512 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6513
6514 /* FIXME: use matrix-type input source selection */
6515 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6516 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6517 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6518 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6519 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6520 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6521 /* Input mixer2 */
6522 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6523 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6524 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6525 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6526 /* Input mixer3 */
6527 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6528 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6529 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6530 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6531 /* ADC1: mute amp left and right */
6532 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6533 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6534 /* ADC2: mute amp left and right */
6535 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6536 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6537 /* ADC3: mute amp left and right */
6538 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6539 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6540
6541 { }
6542};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006543
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006544/* Macbook 5,1 */
6545static struct hda_verb alc885_mb5_init_verbs[] = {
6546 /* Front mixer */
6547 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6548 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6549 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6550 /* LineOut mixer */
6551 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6552 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6553 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6554 /* Front Pin: output 0 (0x0d) */
6555 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
6556 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6557 {0x18, AC_VERB_SET_CONNECT_SEL, 0x01},
6558 /* HP Pin: output 0 (0x0c) */
6559 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6560 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6561 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6562 /* Front Mic pin: input vref at 80% */
6563 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6564 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6565 /* Line In pin */
6566 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6567 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6568
6569 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6570 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6571 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6572 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6573 { }
6574};
6575
Takashi Iwai87350ad2007-08-16 18:19:38 +02006576/* Macbook Pro rev3 */
6577static struct hda_verb alc885_mbp3_init_verbs[] = {
6578 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6579 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6580 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6581 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6582 /* Rear mixer */
6583 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6584 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6585 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6586 /* Front Pin: output 0 (0x0c) */
6587 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6588 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6589 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6590 /* HP Pin: output 0 (0x0d) */
6591 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
6592 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6593 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6594 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6595 /* Mic (rear) pin: input vref at 80% */
6596 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6597 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6598 /* Front Mic pin: input vref at 80% */
6599 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6600 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6601 /* Line In pin: use output 1 when in LineOut mode */
6602 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6603 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6604 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
6605
6606 /* FIXME: use matrix-type input source selection */
6607 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6608 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6609 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6610 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6611 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6612 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6613 /* Input mixer2 */
6614 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6615 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6616 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6617 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6618 /* Input mixer3 */
6619 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6620 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6621 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6622 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6623 /* ADC1: mute amp left and right */
6624 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6625 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6626 /* ADC2: mute amp left and right */
6627 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6628 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6629 /* ADC3: mute amp left and right */
6630 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6631 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6632
6633 { }
6634};
6635
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006636/* iMac 24 mixer. */
6637static struct snd_kcontrol_new alc885_imac24_mixer[] = {
6638 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6639 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
6640 { } /* end */
6641};
6642
6643/* iMac 24 init verbs. */
6644static struct hda_verb alc885_imac24_init_verbs[] = {
6645 /* Internal speakers: output 0 (0x0c) */
6646 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6647 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6648 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6649 /* Internal speakers: output 0 (0x0c) */
6650 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6651 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6652 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
6653 /* Headphone: output 0 (0x0c) */
6654 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6655 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6656 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6657 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6658 /* Front Mic: input vref at 80% */
6659 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6660 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6661 { }
6662};
6663
6664/* Toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006665static void alc885_imac24_automute_init_hook(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006666{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006667 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006668
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006669 spec->autocfg.hp_pins[0] = 0x14;
6670 spec->autocfg.speaker_pins[0] = 0x18;
6671 spec->autocfg.speaker_pins[1] = 0x1a;
6672 alc_automute_amp(codec);
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006673}
6674
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006675static void alc885_mbp3_init_hook(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006676{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006677 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006678
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006679 spec->autocfg.hp_pins[0] = 0x15;
6680 spec->autocfg.speaker_pins[0] = 0x14;
6681 alc_automute_amp(codec);
Takashi Iwai87350ad2007-08-16 18:19:38 +02006682}
6683
6684
Kailang Yang272a5272007-05-14 11:00:38 +02006685static struct hda_verb alc882_targa_verbs[] = {
6686 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6687 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6688
6689 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6690 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006691
Kailang Yang272a5272007-05-14 11:00:38 +02006692 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6693 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6694 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6695
6696 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6697 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
6698 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
6699 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
6700 { } /* end */
6701};
6702
6703/* toggle speaker-output according to the hp-jack state */
6704static void alc882_targa_automute(struct hda_codec *codec)
6705{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006706 struct alc_spec *spec = codec->spec;
6707 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006708 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006709 spec->jack_present ? 1 : 3);
6710}
6711
6712static void alc882_targa_init_hook(struct hda_codec *codec)
6713{
6714 struct alc_spec *spec = codec->spec;
6715
6716 spec->autocfg.hp_pins[0] = 0x14;
6717 spec->autocfg.speaker_pins[0] = 0x1b;
6718 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02006719}
6720
6721static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
6722{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006723 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02006724 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02006725}
6726
6727static struct hda_verb alc882_asus_a7j_verbs[] = {
6728 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6729 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6730
6731 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6732 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6733 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006734
Kailang Yang272a5272007-05-14 11:00:38 +02006735 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6736 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6737 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6738
6739 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6740 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6741 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6742 { } /* end */
6743};
6744
Takashi Iwai914759b2007-09-06 14:52:04 +02006745static struct hda_verb alc882_asus_a7m_verbs[] = {
6746 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6747 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6748
6749 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6750 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6751 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006752
Takashi Iwai914759b2007-09-06 14:52:04 +02006753 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6754 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6755 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6756
6757 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6758 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6759 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6760 { } /* end */
6761};
6762
Tobin Davis9102cd12006-12-15 10:02:12 +01006763static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
6764{
6765 unsigned int gpiostate, gpiomask, gpiodir;
6766
6767 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
6768 AC_VERB_GET_GPIO_DATA, 0);
6769
6770 if (!muted)
6771 gpiostate |= (1 << pin);
6772 else
6773 gpiostate &= ~(1 << pin);
6774
6775 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
6776 AC_VERB_GET_GPIO_MASK, 0);
6777 gpiomask |= (1 << pin);
6778
6779 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
6780 AC_VERB_GET_GPIO_DIRECTION, 0);
6781 gpiodir |= (1 << pin);
6782
6783
6784 snd_hda_codec_write(codec, codec->afg, 0,
6785 AC_VERB_SET_GPIO_MASK, gpiomask);
6786 snd_hda_codec_write(codec, codec->afg, 0,
6787 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
6788
6789 msleep(1);
6790
6791 snd_hda_codec_write(codec, codec->afg, 0,
6792 AC_VERB_SET_GPIO_DATA, gpiostate);
6793}
6794
Takashi Iwai7debbe52007-08-16 15:01:03 +02006795/* set up GPIO at initialization */
6796static void alc885_macpro_init_hook(struct hda_codec *codec)
6797{
6798 alc882_gpio_mute(codec, 0, 0);
6799 alc882_gpio_mute(codec, 1, 0);
6800}
6801
6802/* set up GPIO and update auto-muting at initialization */
6803static void alc885_imac24_init_hook(struct hda_codec *codec)
6804{
6805 alc885_macpro_init_hook(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006806 alc885_imac24_automute_init_hook(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02006807}
6808
Kailang Yangdf694da2005-12-05 19:42:22 +01006809/*
6810 * generic initialization of ADC, input mixers and output mixers
6811 */
6812static struct hda_verb alc882_auto_init_verbs[] = {
6813 /*
6814 * Unmute ADC0-2 and set the default input to mic-in
6815 */
6816 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6817 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6818 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6819 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6820 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6821 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6822
Takashi Iwaicb53c622007-08-10 17:21:45 +02006823 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01006824 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006825 * Note: PASD motherboards uses the Line In 2 as the input for
6826 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006827 */
6828 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006829 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6830 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6831 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6832 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6833 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006834
6835 /*
6836 * Set up output mixers (0x0c - 0x0f)
6837 */
6838 /* set vol=0 to output mixers */
6839 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6840 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6841 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6842 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6843 /* set up input amps for analog loopback */
6844 /* Amp Indices: DAC = 0, mixer = 1 */
6845 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6846 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6847 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6848 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6849 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6850 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6851 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6852 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6853 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6854 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6855
6856 /* FIXME: use matrix-type input source selection */
6857 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6858 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6859 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6860 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6861 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6862 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6863 /* Input mixer2 */
6864 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6865 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6866 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6867 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6868 /* Input mixer3 */
6869 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6870 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6871 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6872 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6873
6874 { }
6875};
6876
Takashi Iwaicb53c622007-08-10 17:21:45 +02006877#ifdef CONFIG_SND_HDA_POWER_SAVE
6878#define alc882_loopbacks alc880_loopbacks
6879#endif
6880
Kailang Yangdf694da2005-12-05 19:42:22 +01006881/* pcm configuration: identiacal with ALC880 */
6882#define alc882_pcm_analog_playback alc880_pcm_analog_playback
6883#define alc882_pcm_analog_capture alc880_pcm_analog_capture
6884#define alc882_pcm_digital_playback alc880_pcm_digital_playback
6885#define alc882_pcm_digital_capture alc880_pcm_digital_capture
6886
6887/*
6888 * configuration and preset
6889 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006890static const char *alc882_models[ALC882_MODEL_LAST] = {
6891 [ALC882_3ST_DIG] = "3stack-dig",
6892 [ALC882_6ST_DIG] = "6stack-dig",
6893 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02006894 [ALC882_W2JC] = "w2jc",
Takashi Iwai0438a002007-09-06 14:54:11 +02006895 [ALC882_TARGA] = "targa",
6896 [ALC882_ASUS_A7J] = "asus-a7j",
6897 [ALC882_ASUS_A7M] = "asus-a7m",
Tobin Davis9102cd12006-12-15 10:02:12 +01006898 [ALC885_MACPRO] = "macpro",
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006899 [ALC885_MB5] = "mb5",
Takashi Iwai87350ad2007-08-16 18:19:38 +02006900 [ALC885_MBP3] = "mbp3",
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006901 [ALC885_IMAC24] = "imac24",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006902 [ALC882_AUTO] = "auto",
6903};
6904
6905static struct snd_pci_quirk alc882_cfg_tbl[] = {
6906 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02006907 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Kailang Yangac8842a2007-09-20 12:51:39 +02006908 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
Takashi Iwai914759b2007-09-06 14:52:04 +02006909 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006910 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Claudio Matsuokac5d9f1c2007-07-19 23:18:32 +02006911 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
Tobin Davis7b9470d2006-12-28 13:56:48 +01006912 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006913 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Jiang zhe44447042008-01-28 12:28:24 +01006914 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006915 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
6916 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
6917 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yangdf694da2005-12-05 19:42:22 +01006918 {}
6919};
6920
6921static struct alc_config_preset alc882_presets[] = {
6922 [ALC882_3ST_DIG] = {
6923 .mixers = { alc882_base_mixer },
6924 .init_verbs = { alc882_init_verbs },
6925 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6926 .dac_nids = alc882_dac_nids,
6927 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006928 .dig_in_nid = ALC882_DIGIN_NID,
6929 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6930 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006931 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01006932 .input_mux = &alc882_capture_source,
6933 },
6934 [ALC882_6ST_DIG] = {
6935 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6936 .init_verbs = { alc882_init_verbs },
6937 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6938 .dac_nids = alc882_dac_nids,
6939 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006940 .dig_in_nid = ALC882_DIGIN_NID,
6941 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6942 .channel_mode = alc882_sixstack_modes,
6943 .input_mux = &alc882_capture_source,
6944 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006945 [ALC882_ARIMA] = {
6946 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6947 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
6948 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6949 .dac_nids = alc882_dac_nids,
6950 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6951 .channel_mode = alc882_sixstack_modes,
6952 .input_mux = &alc882_capture_source,
6953 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02006954 [ALC882_W2JC] = {
6955 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
6956 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6957 alc880_gpio1_init_verbs },
6958 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6959 .dac_nids = alc882_dac_nids,
6960 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6961 .channel_mode = alc880_threestack_modes,
6962 .need_dac_fix = 1,
6963 .input_mux = &alc882_capture_source,
6964 .dig_out_nid = ALC882_DIGOUT_NID,
6965 },
Takashi Iwai87350ad2007-08-16 18:19:38 +02006966 [ALC885_MBP3] = {
6967 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
6968 .init_verbs = { alc885_mbp3_init_verbs,
6969 alc880_gpio1_init_verbs },
6970 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6971 .dac_nids = alc882_dac_nids,
6972 .channel_mode = alc885_mbp_6ch_modes,
6973 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
6974 .input_mux = &alc882_capture_source,
6975 .dig_out_nid = ALC882_DIGOUT_NID,
6976 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006977 .unsol_event = alc_automute_amp_unsol_event,
6978 .init_hook = alc885_mbp3_init_hook,
Takashi Iwai87350ad2007-08-16 18:19:38 +02006979 },
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006980 [ALC885_MB5] = {
6981 .mixers = { alc885_mb5_mixer },
6982 .init_verbs = { alc885_mb5_init_verbs,
6983 alc880_gpio1_init_verbs },
6984 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6985 .dac_nids = alc882_dac_nids,
6986 .channel_mode = alc885_mbp_6ch_modes,
6987 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
6988 .input_mux = &mb5_capture_source,
6989 .dig_out_nid = ALC882_DIGOUT_NID,
6990 .dig_in_nid = ALC882_DIGIN_NID,
6991 },
Tobin Davis9102cd12006-12-15 10:02:12 +01006992 [ALC885_MACPRO] = {
6993 .mixers = { alc882_macpro_mixer },
6994 .init_verbs = { alc882_macpro_init_verbs },
6995 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6996 .dac_nids = alc882_dac_nids,
6997 .dig_out_nid = ALC882_DIGOUT_NID,
6998 .dig_in_nid = ALC882_DIGIN_NID,
6999 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
7000 .channel_mode = alc882_ch_modes,
7001 .input_mux = &alc882_capture_source,
Takashi Iwai7debbe52007-08-16 15:01:03 +02007002 .init_hook = alc885_macpro_init_hook,
Tobin Davis9102cd12006-12-15 10:02:12 +01007003 },
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007004 [ALC885_IMAC24] = {
7005 .mixers = { alc885_imac24_mixer },
7006 .init_verbs = { alc885_imac24_init_verbs },
7007 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7008 .dac_nids = alc882_dac_nids,
7009 .dig_out_nid = ALC882_DIGOUT_NID,
7010 .dig_in_nid = ALC882_DIGIN_NID,
7011 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
7012 .channel_mode = alc882_ch_modes,
7013 .input_mux = &alc882_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007014 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai7debbe52007-08-16 15:01:03 +02007015 .init_hook = alc885_imac24_init_hook,
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007016 },
Kailang Yang272a5272007-05-14 11:00:38 +02007017 [ALC882_TARGA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007018 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Kailang Yang272a5272007-05-14 11:00:38 +02007019 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
7020 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7021 .dac_nids = alc882_dac_nids,
7022 .dig_out_nid = ALC882_DIGOUT_NID,
7023 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
7024 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01007025 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02007026 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
7027 .channel_mode = alc882_3ST_6ch_modes,
7028 .need_dac_fix = 1,
7029 .input_mux = &alc882_capture_source,
7030 .unsol_event = alc882_targa_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007031 .init_hook = alc882_targa_init_hook,
Kailang Yang272a5272007-05-14 11:00:38 +02007032 },
7033 [ALC882_ASUS_A7J] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007034 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Kailang Yang272a5272007-05-14 11:00:38 +02007035 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
7036 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7037 .dac_nids = alc882_dac_nids,
7038 .dig_out_nid = ALC882_DIGOUT_NID,
7039 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
7040 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01007041 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02007042 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
7043 .channel_mode = alc882_3ST_6ch_modes,
7044 .need_dac_fix = 1,
7045 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02007046 },
Takashi Iwai914759b2007-09-06 14:52:04 +02007047 [ALC882_ASUS_A7M] = {
7048 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
7049 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
7050 alc880_gpio1_init_verbs,
7051 alc882_asus_a7m_verbs },
7052 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7053 .dac_nids = alc882_dac_nids,
7054 .dig_out_nid = ALC882_DIGOUT_NID,
7055 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
7056 .channel_mode = alc880_threestack_modes,
7057 .need_dac_fix = 1,
7058 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02007059 },
Kailang Yangdf694da2005-12-05 19:42:22 +01007060};
7061
7062
7063/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02007064 * Pin config fixes
7065 */
Kailang Yangea1fb292008-08-26 12:58:38 +02007066enum {
Takashi Iwaif95474e2007-07-10 00:47:43 +02007067 PINFIX_ABIT_AW9D_MAX
7068};
7069
7070static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
7071 { 0x15, 0x01080104 }, /* side */
7072 { 0x16, 0x01011012 }, /* rear */
7073 { 0x17, 0x01016011 }, /* clfe */
7074 { }
7075};
7076
7077static const struct alc_pincfg *alc882_pin_fixes[] = {
7078 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
7079};
7080
7081static struct snd_pci_quirk alc882_pinfix_tbl[] = {
7082 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
7083 {}
7084};
7085
7086/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007087 * BIOS auto configuration
7088 */
7089static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
7090 hda_nid_t nid, int pin_type,
7091 int dac_idx)
7092{
7093 /* set as output */
7094 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007095 int idx;
7096
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007097 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01007098 if (spec->multiout.dac_nids[dac_idx] == 0x25)
7099 idx = 4;
7100 else
7101 idx = spec->multiout.dac_nids[dac_idx] - 2;
Kailang Yangdf694da2005-12-05 19:42:22 +01007102 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
7103
7104}
7105
7106static void alc882_auto_init_multi_out(struct hda_codec *codec)
7107{
7108 struct alc_spec *spec = codec->spec;
7109 int i;
7110
7111 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007112 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007113 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01007114 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007115 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007116 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01007117 }
7118}
7119
7120static void alc882_auto_init_hp_out(struct hda_codec *codec)
7121{
7122 struct alc_spec *spec = codec->spec;
7123 hda_nid_t pin;
7124
Takashi Iwaieb06ed82006-09-20 17:10:27 +02007125 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007126 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007127 /* use dac 0 */
7128 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007129 pin = spec->autocfg.speaker_pins[0];
7130 if (pin)
7131 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01007132}
7133
7134#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
7135#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
7136
7137static void alc882_auto_init_analog_input(struct hda_codec *codec)
7138{
7139 struct alc_spec *spec = codec->spec;
7140 int i;
7141
7142 for (i = 0; i < AUTO_PIN_LAST; i++) {
7143 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai7194cae2008-03-06 16:58:17 +01007144 if (!nid)
7145 continue;
Takashi Iwai23f0c042009-02-26 13:03:58 +01007146 alc_set_input_pin(codec, nid, AUTO_PIN_FRONT_MIC /*i*/);
Takashi Iwai7194cae2008-03-06 16:58:17 +01007147 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
7148 snd_hda_codec_write(codec, nid, 0,
7149 AC_VERB_SET_AMP_GAIN_MUTE,
7150 AMP_OUT_MUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01007151 }
7152}
7153
Takashi Iwaif511b012008-08-15 16:46:42 +02007154static void alc882_auto_init_input_src(struct hda_codec *codec)
7155{
7156 struct alc_spec *spec = codec->spec;
Takashi Iwaif511b012008-08-15 16:46:42 +02007157 int c;
7158
7159 for (c = 0; c < spec->num_adc_nids; c++) {
7160 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
7161 hda_nid_t nid = spec->capsrc_nids[c];
Herton Ronaldo Krzesinskib98b7b32009-01-29 13:18:31 -02007162 unsigned int mux_idx;
7163 const struct hda_input_mux *imux;
Takashi Iwaif511b012008-08-15 16:46:42 +02007164 int conns, mute, idx, item;
7165
7166 conns = snd_hda_get_connections(codec, nid, conn_list,
7167 ARRAY_SIZE(conn_list));
7168 if (conns < 0)
7169 continue;
Herton Ronaldo Krzesinskib98b7b32009-01-29 13:18:31 -02007170 mux_idx = c >= spec->num_mux_defs ? 0 : c;
7171 imux = &spec->input_mux[mux_idx];
Takashi Iwaif511b012008-08-15 16:46:42 +02007172 for (idx = 0; idx < conns; idx++) {
7173 /* if the current connection is the selected one,
7174 * unmute it as default - otherwise mute it
7175 */
7176 mute = AMP_IN_MUTE(idx);
7177 for (item = 0; item < imux->num_items; item++) {
7178 if (imux->items[item].index == idx) {
7179 if (spec->cur_mux[c] == item)
7180 mute = AMP_IN_UNMUTE(idx);
7181 break;
7182 }
7183 }
Herton Ronaldo Krzesinskib98b7b32009-01-29 13:18:31 -02007184 /* check if we have a selector or mixer
7185 * we could check for the widget type instead, but
7186 * just check for Amp-In presence (in case of mixer
7187 * without amp-in there is something wrong, this
7188 * function shouldn't be used or capsrc nid is wrong)
7189 */
7190 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
7191 snd_hda_codec_write(codec, nid, 0,
7192 AC_VERB_SET_AMP_GAIN_MUTE,
7193 mute);
7194 else if (mute != AMP_IN_MUTE(idx))
7195 snd_hda_codec_write(codec, nid, 0,
7196 AC_VERB_SET_CONNECT_SEL,
7197 idx);
Takashi Iwaif511b012008-08-15 16:46:42 +02007198 }
7199 }
7200}
7201
Takashi Iwai776e1842007-08-29 15:07:11 +02007202/* add mic boosts if needed */
7203static int alc_auto_add_mic_boost(struct hda_codec *codec)
7204{
7205 struct alc_spec *spec = codec->spec;
7206 int err;
7207 hda_nid_t nid;
7208
7209 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01007210 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02007211 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7212 "Mic Boost",
7213 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
7214 if (err < 0)
7215 return err;
7216 }
7217 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01007218 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02007219 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7220 "Front Mic Boost",
7221 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
7222 if (err < 0)
7223 return err;
7224 }
7225 return 0;
7226}
7227
Kailang Yangdf694da2005-12-05 19:42:22 +01007228/* almost identical with ALC880 parser... */
7229static int alc882_parse_auto_config(struct hda_codec *codec)
7230{
7231 struct alc_spec *spec = codec->spec;
7232 int err = alc880_parse_auto_config(codec);
7233
7234 if (err < 0)
7235 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02007236 else if (!err)
7237 return 0; /* no config found */
7238
7239 err = alc_auto_add_mic_boost(codec);
7240 if (err < 0)
7241 return err;
7242
7243 /* hack - override the init verbs */
7244 spec->init_verbs[0] = alc882_auto_init_verbs;
7245
7246 return 1; /* config found */
Kailang Yangdf694da2005-12-05 19:42:22 +01007247}
7248
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007249/* additional initialization for auto-configuration model */
7250static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01007251{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007252 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007253 alc882_auto_init_multi_out(codec);
7254 alc882_auto_init_hp_out(codec);
7255 alc882_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02007256 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007257 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02007258 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01007259}
7260
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007261static int patch_alc883(struct hda_codec *codec); /* called in patch_alc882() */
7262
Linus Torvalds1da177e2005-04-16 15:20:36 -07007263static int patch_alc882(struct hda_codec *codec)
7264{
7265 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007266 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007267
Takashi Iwaie560d8d2005-09-09 14:21:46 +02007268 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007269 if (spec == NULL)
7270 return -ENOMEM;
7271
Linus Torvalds1da177e2005-04-16 15:20:36 -07007272 codec->spec = spec;
7273
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007274 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
7275 alc882_models,
7276 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007277
Kailang Yangdf694da2005-12-05 19:42:22 +01007278 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01007279 /* Pick up systems that don't supply PCI SSID */
7280 switch (codec->subsystem_id) {
7281 case 0x106b0c00: /* Mac Pro */
7282 board_config = ALC885_MACPRO;
7283 break;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007284 case 0x106b1000: /* iMac 24 */
Peter Korsgaardf3911c52008-09-27 09:13:45 +02007285 case 0x106b2800: /* AppleTV */
Mark Eggleston3077e442009-01-31 17:57:54 +01007286 case 0x106b3e00: /* iMac 24 Aluminium */
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007287 board_config = ALC885_IMAC24;
7288 break;
Luke Yelavich2d466382009-02-23 13:00:33 +11007289 case 0x106b00a0: /* MacBookPro3,1 - Another revision */
Takashi Iwaic7e07572008-06-26 14:42:51 +02007290 case 0x106b00a1: /* Macbook (might be wrong - PCI SSID?) */
David Woodhouse9c95c432008-09-18 13:37:13 -07007291 case 0x106b00a4: /* MacbookPro4,1 */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007292 case 0x106b2c00: /* Macbook Pro rev3 */
Takashi Iwaic7e07572008-06-26 14:42:51 +02007293 case 0x106b3600: /* Macbook 3.1 */
Luke Yelavich2a884642009-01-28 15:58:38 +11007294 case 0x106b3800: /* MacbookPro4,1 - latter revision */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007295 board_config = ALC885_MBP3;
7296 break;
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007297 case 0x106b3f00: /* Macbook 5,1 */
Takashi Iwai7442f9d2009-05-14 18:20:33 +02007298 case 0x106b4000: /* Macbook Pro 5,1 - FIXME: HP jack sense
7299 * seems not working, so apparently
7300 * no perfect solution yet
7301 */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007302 board_config = ALC885_MB5;
7303 break;
Tobin Davis081d17c2007-02-15 17:46:18 +01007304 default:
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007305 /* ALC889A is handled better as ALC888-compatible */
Clive Messer669faba2008-09-30 15:49:13 +02007306 if (codec->revision_id == 0x100101 ||
7307 codec->revision_id == 0x100103) {
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007308 alc_free(codec);
7309 return patch_alc883(codec);
7310 }
Tobin Davis081d17c2007-02-15 17:46:18 +01007311 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
7312 "trying auto-probe from BIOS...\n");
7313 board_config = ALC882_AUTO;
7314 }
Kailang Yangdf694da2005-12-05 19:42:22 +01007315 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007316
Takashi Iwaif95474e2007-07-10 00:47:43 +02007317 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
7318
Kailang Yangdf694da2005-12-05 19:42:22 +01007319 if (board_config == ALC882_AUTO) {
7320 /* automatic parse from the BIOS config */
7321 err = alc882_parse_auto_config(codec);
7322 if (err < 0) {
7323 alc_free(codec);
7324 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007325 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007326 printk(KERN_INFO
7327 "hda_codec: Cannot set up configuration "
7328 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007329 board_config = ALC882_3ST_DIG;
7330 }
7331 }
7332
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09007333 err = snd_hda_attach_beep_device(codec, 0x1);
7334 if (err < 0) {
7335 alc_free(codec);
7336 return err;
7337 }
7338
Kailang Yangdf694da2005-12-05 19:42:22 +01007339 if (board_config != ALC882_AUTO)
7340 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007341
Kailang Yangdf694da2005-12-05 19:42:22 +01007342 spec->stream_analog_playback = &alc882_pcm_analog_playback;
7343 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01007344 /* FIXME: setup DAC5 */
7345 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
7346 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007347
Kailang Yangdf694da2005-12-05 19:42:22 +01007348 spec->stream_digital_playback = &alc882_pcm_digital_playback;
7349 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007350
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007351 spec->capture_style = CAPT_MIX; /* matrix-style capture */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007352 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01007353 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01007354 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007355 /* get type */
7356 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01007357 if (wcap != AC_WID_AUD_IN) {
7358 spec->adc_nids = alc882_adc_nids_alt;
7359 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
Takashi Iwaie1406342008-02-11 18:32:32 +01007360 spec->capsrc_nids = alc882_capsrc_nids_alt;
Kailang Yangdf694da2005-12-05 19:42:22 +01007361 } else {
7362 spec->adc_nids = alc882_adc_nids;
7363 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +01007364 spec->capsrc_nids = alc882_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +01007365 }
7366 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007367 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007368 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007369
Takashi Iwai2134ea42008-01-10 16:53:55 +01007370 spec->vmaster_nid = 0x0c;
7371
Linus Torvalds1da177e2005-04-16 15:20:36 -07007372 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01007373 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007374 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02007375#ifdef CONFIG_SND_HDA_POWER_SAVE
7376 if (!spec->loopback.amplist)
7377 spec->loopback.amplist = alc882_loopbacks;
7378#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01007379 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007380
7381 return 0;
7382}
7383
7384/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007385 * ALC883 support
7386 *
7387 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
7388 * configuration. Each pin widget can choose any input DACs and a mixer.
7389 * Each ADC is connected from a mixer of all inputs. This makes possible
7390 * 6-channel independent captures.
7391 *
7392 * In addition, an independent DAC for the multi-playback (not used in this
7393 * driver yet).
7394 */
7395#define ALC883_DIGOUT_NID 0x06
7396#define ALC883_DIGIN_NID 0x0a
7397
Wu Fengguang3ab90932008-11-17 09:51:09 +01007398#define ALC1200_DIGOUT_NID 0x10
7399
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007400static hda_nid_t alc883_dac_nids[4] = {
7401 /* front, rear, clfe, rear_surr */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01007402 0x02, 0x03, 0x04, 0x05
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007403};
7404
7405static hda_nid_t alc883_adc_nids[2] = {
7406 /* ADC1-2 */
7407 0x08, 0x09,
7408};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007409
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007410static hda_nid_t alc883_adc_nids_alt[1] = {
7411 /* ADC1 */
7412 0x08,
7413};
7414
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08007415static hda_nid_t alc883_adc_nids_rev[2] = {
7416 /* ADC2-1 */
7417 0x09, 0x08
7418};
7419
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007420#define alc889_adc_nids alc880_adc_nids
7421
Takashi Iwaie1406342008-02-11 18:32:32 +01007422static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 };
7423
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08007424static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
7425
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007426#define alc889_capsrc_nids alc882_capsrc_nids
7427
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007428/* input MUX */
7429/* FIXME: should be a matrix-type input source selection */
7430
7431static struct hda_input_mux alc883_capture_source = {
7432 .num_items = 4,
7433 .items = {
7434 { "Mic", 0x0 },
7435 { "Front Mic", 0x1 },
7436 { "Line", 0x2 },
7437 { "CD", 0x4 },
7438 },
7439};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007440
Jiang zhe17bba1b2008-06-04 12:11:07 +02007441static struct hda_input_mux alc883_3stack_6ch_intel = {
7442 .num_items = 4,
7443 .items = {
7444 { "Mic", 0x1 },
7445 { "Front Mic", 0x0 },
7446 { "Line", 0x2 },
7447 { "CD", 0x4 },
7448 },
7449};
7450
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007451static struct hda_input_mux alc883_lenovo_101e_capture_source = {
7452 .num_items = 2,
7453 .items = {
7454 { "Mic", 0x1 },
7455 { "Line", 0x2 },
7456 },
7457};
7458
Kailang Yang272a5272007-05-14 11:00:38 +02007459static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
7460 .num_items = 4,
7461 .items = {
7462 { "Mic", 0x0 },
7463 { "iMic", 0x1 },
7464 { "Line", 0x2 },
7465 { "CD", 0x4 },
7466 },
7467};
7468
Jiang zhefb97dc62008-03-06 11:07:11 +01007469static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
7470 .num_items = 2,
7471 .items = {
7472 { "Mic", 0x0 },
7473 { "Int Mic", 0x1 },
7474 },
7475};
7476
Kailang Yange2757d52008-08-26 13:17:46 +02007477static struct hda_input_mux alc883_lenovo_sky_capture_source = {
7478 .num_items = 3,
7479 .items = {
7480 { "Mic", 0x0 },
7481 { "Front Mic", 0x1 },
7482 { "Line", 0x4 },
7483 },
7484};
7485
7486static struct hda_input_mux alc883_asus_eee1601_capture_source = {
7487 .num_items = 2,
7488 .items = {
7489 { "Mic", 0x0 },
7490 { "Line", 0x2 },
7491 },
7492};
7493
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007494/*
7495 * 2ch mode
7496 */
7497static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
7498 { 2, NULL }
7499};
7500
7501/*
7502 * 2ch mode
7503 */
7504static struct hda_verb alc883_3ST_ch2_init[] = {
7505 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7506 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7507 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7508 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7509 { } /* end */
7510};
7511
7512/*
Tobin Davisb2011312007-09-17 12:45:11 +02007513 * 4ch mode
7514 */
7515static struct hda_verb alc883_3ST_ch4_init[] = {
7516 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7517 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7518 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7519 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7520 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7521 { } /* end */
7522};
7523
7524/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007525 * 6ch mode
7526 */
7527static struct hda_verb alc883_3ST_ch6_init[] = {
7528 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7529 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7530 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7531 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7532 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7533 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7534 { } /* end */
7535};
7536
Tobin Davisb2011312007-09-17 12:45:11 +02007537static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007538 { 2, alc883_3ST_ch2_init },
Tobin Davisb2011312007-09-17 12:45:11 +02007539 { 4, alc883_3ST_ch4_init },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007540 { 6, alc883_3ST_ch6_init },
7541};
7542
7543/*
Jiang zhe17bba1b2008-06-04 12:11:07 +02007544 * 2ch mode
7545 */
7546static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7547 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7548 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7549 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7550 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7551 { } /* end */
7552};
7553
7554/*
7555 * 4ch mode
7556 */
7557static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7558 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7559 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7560 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7561 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7562 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7563 { } /* end */
7564};
7565
7566/*
7567 * 6ch mode
7568 */
7569static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7570 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7571 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7572 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7573 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7574 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7575 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7576 { } /* end */
7577};
7578
7579static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7580 { 2, alc883_3ST_ch2_intel_init },
7581 { 4, alc883_3ST_ch4_intel_init },
7582 { 6, alc883_3ST_ch6_intel_init },
7583};
7584
7585/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007586 * 6ch mode
7587 */
7588static struct hda_verb alc883_sixstack_ch6_init[] = {
7589 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7590 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7591 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7592 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7593 { } /* end */
7594};
7595
7596/*
7597 * 8ch mode
7598 */
7599static struct hda_verb alc883_sixstack_ch8_init[] = {
7600 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7601 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7602 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7603 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7604 { } /* end */
7605};
7606
7607static struct hda_channel_mode alc883_sixstack_modes[2] = {
7608 { 6, alc883_sixstack_ch6_init },
7609 { 8, alc883_sixstack_ch8_init },
7610};
7611
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007612static struct hda_verb alc883_medion_eapd_verbs[] = {
7613 /* eanable EAPD on medion laptop */
7614 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7615 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7616 { }
7617};
7618
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007619/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7620 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7621 */
7622
7623static struct snd_kcontrol_new alc883_base_mixer[] = {
7624 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7625 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7626 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7627 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7628 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7629 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7630 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7631 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7632 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7633 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7634 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7635 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7636 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7637 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7638 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7639 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007640 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007641 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7642 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007643 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007644 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007645 { } /* end */
7646};
7647
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007648static struct snd_kcontrol_new alc883_mitac_mixer[] = {
7649 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7650 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7651 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7652 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7653 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7654 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7655 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7656 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7657 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7658 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7659 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7660 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7661 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007662 { } /* end */
7663};
7664
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007665static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007666 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7667 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7668 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7669 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7670 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7671 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7672 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7673 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7674 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7675 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01007676 { } /* end */
7677};
7678
Jiang zhefb97dc62008-03-06 11:07:11 +01007679static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
7680 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7681 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7682 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7683 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7684 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7685 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7686 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7687 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7688 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7689 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01007690 { } /* end */
7691};
7692
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007693static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
7694 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7695 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7696 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7697 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7698 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7699 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7700 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7701 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007702 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007703 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7704 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007705 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007706 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007707 { } /* end */
7708};
7709
7710static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
7711 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7712 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7713 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7714 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7715 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7716 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7717 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7718 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7719 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7720 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7721 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7722 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7723 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7724 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007725 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007726 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7727 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007728 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007729 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007730 { } /* end */
7731};
7732
Jiang zhe17bba1b2008-06-04 12:11:07 +02007733static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
7734 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7735 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7736 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7737 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7738 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7739 HDA_OUTPUT),
7740 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7741 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7742 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7743 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7744 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7745 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7746 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7747 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7748 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7749 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
7750 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7751 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7752 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7753 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02007754 { } /* end */
7755};
7756
Takashi Iwaid1d985f2006-11-23 19:27:12 +01007757static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02007758 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007759 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007760 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007761 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007762 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7763 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007764 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7765 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007766 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7767 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7768 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7769 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7770 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7771 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007772 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007773 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7774 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007775 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007776 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007777 { } /* end */
7778};
7779
Kailang Yangccc656c2006-10-17 12:32:26 +02007780static struct snd_kcontrol_new alc883_tagra_mixer[] = {
7781 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7782 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7783 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7784 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7785 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7786 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7787 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7788 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7789 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7790 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7791 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7792 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7793 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7794 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007795 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007796 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007797 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007798};
Kailang Yangccc656c2006-10-17 12:32:26 +02007799
7800static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
7801 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7802 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7803 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7804 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7805 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7806 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007807 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007808 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02007809 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7810 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7811 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007812 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007813};
Kailang Yangccc656c2006-10-17 12:32:26 +02007814
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007815static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
7816 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7817 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01007818 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7819 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007820 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7821 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7822 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7823 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007824 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007825};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007826
Kailang Yang272a5272007-05-14 11:00:38 +02007827static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
7828 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7829 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
7830 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7831 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7832 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7833 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7834 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7835 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7836 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007837 { } /* end */
7838};
7839
7840static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
7841 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7842 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7843 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7844 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7845 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7846 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7847 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7848 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7849 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007850 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02007851};
Kailang Yang272a5272007-05-14 11:00:38 +02007852
Tobin Davis2880a862007-08-07 11:50:26 +02007853static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02007854 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7855 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007856 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007857 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7858 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02007859 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7860 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7861 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007862 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02007863};
Tobin Davis2880a862007-08-07 11:50:26 +02007864
Kailang Yange2757d52008-08-26 13:17:46 +02007865static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
7866 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7867 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7868 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
7869 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
7870 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
7871 0x0d, 1, 0x0, HDA_OUTPUT),
7872 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
7873 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
7874 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
7875 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7876 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02007877 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7878 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7879 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7880 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7881 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7882 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7883 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7884 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7885 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7886 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02007887 { } /* end */
7888};
7889
7890static struct hda_bind_ctls alc883_bind_cap_vol = {
7891 .ops = &snd_hda_bind_vol,
7892 .values = {
7893 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
7894 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7895 0
7896 },
7897};
7898
7899static struct hda_bind_ctls alc883_bind_cap_switch = {
7900 .ops = &snd_hda_bind_sw,
7901 .values = {
7902 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
7903 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7904 0
7905 },
7906};
7907
7908static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
7909 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7910 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7911 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7912 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7913 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7914 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7915 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7916 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007917 { } /* end */
7918};
7919
7920static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02007921 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
7922 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
7923 {
7924 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7925 /* .name = "Capture Source", */
7926 .name = "Input Source",
7927 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01007928 .info = alc_mux_enum_info,
7929 .get = alc_mux_enum_get,
7930 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02007931 },
7932 { } /* end */
7933};
7934
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007935static struct snd_kcontrol_new alc883_chmode_mixer[] = {
7936 {
7937 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7938 .name = "Channel Mode",
7939 .info = alc_ch_mode_info,
7940 .get = alc_ch_mode_get,
7941 .put = alc_ch_mode_put,
7942 },
7943 { } /* end */
7944};
7945
7946static struct hda_verb alc883_init_verbs[] = {
7947 /* ADC1: mute amp left and right */
Kailang Yange2757d52008-08-26 13:17:46 +02007948 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007949 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7950 /* ADC2: mute amp left and right */
7951 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7952 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7953 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7954 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7955 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7956 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7957 /* Rear mixer */
7958 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7959 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7960 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7961 /* CLFE mixer */
7962 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7963 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7964 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7965 /* Side mixer */
7966 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7967 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7968 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7969
Takashi Iwaicb53c622007-08-10 17:21:45 +02007970 /* mute analog input loopbacks */
7971 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7972 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7973 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7974 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7975 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007976
7977 /* Front Pin: output 0 (0x0c) */
7978 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7979 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7980 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7981 /* Rear Pin: output 1 (0x0d) */
7982 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7983 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7984 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7985 /* CLFE Pin: output 2 (0x0e) */
7986 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7987 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7988 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7989 /* Side Pin: output 3 (0x0f) */
7990 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7991 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7992 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7993 /* Mic (rear) pin: input vref at 80% */
7994 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7995 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7996 /* Front Mic pin: input vref at 80% */
7997 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7998 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7999 /* Line In pin: input */
8000 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8001 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8002 /* Line-2 In: Headphone output (output 0 - 0x0c) */
8003 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8004 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8005 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8006 /* CD pin widget for input */
8007 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8008
8009 /* FIXME: use matrix-type input source selection */
8010 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8011 /* Input mixer2 */
8012 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yange2757d52008-08-26 13:17:46 +02008013 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8014 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8015 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008016 /* Input mixer3 */
8017 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yange2757d52008-08-26 13:17:46 +02008018 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8019 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8020 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008021 { }
8022};
8023
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008024/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008025static void alc883_mitac_init_hook(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008026{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008027 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008028
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008029 spec->autocfg.hp_pins[0] = 0x15;
8030 spec->autocfg.speaker_pins[0] = 0x14;
8031 spec->autocfg.speaker_pins[1] = 0x17;
8032 alc_automute_amp(codec);
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008033}
8034
8035/* auto-toggle front mic */
8036/*
8037static void alc883_mitac_mic_automute(struct hda_codec *codec)
8038{
8039 unsigned int present;
8040 unsigned char bits;
8041
8042 present = snd_hda_codec_read(codec, 0x18, 0,
8043 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8044 bits = present ? HDA_AMP_MUTE : 0;
8045 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
8046}
8047*/
8048
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008049static struct hda_verb alc883_mitac_verbs[] = {
8050 /* HP */
8051 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8052 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8053 /* Subwoofer */
8054 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8055 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8056
8057 /* enable unsolicited event */
8058 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8059 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
8060
8061 { } /* end */
8062};
8063
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008064static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008065 /* HP */
8066 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8067 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8068 /* Int speaker */
8069 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
8070 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8071
8072 /* enable unsolicited event */
8073 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008074 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01008075
8076 { } /* end */
8077};
8078
Jiang zhefb97dc62008-03-06 11:07:11 +01008079static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
8080 /* HP */
8081 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8082 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8083 /* Subwoofer */
8084 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8085 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8086
8087 /* enable unsolicited event */
8088 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8089
8090 { } /* end */
8091};
8092
Kailang Yangccc656c2006-10-17 12:32:26 +02008093static struct hda_verb alc883_tagra_verbs[] = {
8094 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8095 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8096
8097 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8098 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008099
Kailang Yangccc656c2006-10-17 12:32:26 +02008100 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8101 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8102 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8103
8104 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008105 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
8106 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
8107 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
Kailang Yangccc656c2006-10-17 12:32:26 +02008108
8109 { } /* end */
8110};
8111
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008112static struct hda_verb alc883_lenovo_101e_verbs[] = {
8113 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8114 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
8115 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
8116 { } /* end */
8117};
8118
Kailang Yang272a5272007-05-14 11:00:38 +02008119static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
8120 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8121 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8122 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8123 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8124 { } /* end */
8125};
8126
8127static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
8128 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8129 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8130 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8131 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
8132 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8133 { } /* end */
8134};
8135
Kailang Yang189609a2007-08-20 11:31:23 +02008136static struct hda_verb alc883_haier_w66_verbs[] = {
8137 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8138 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8139
8140 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8141
8142 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8143 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8144 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8145 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8146 { } /* end */
8147};
8148
Kailang Yange2757d52008-08-26 13:17:46 +02008149static struct hda_verb alc888_lenovo_sky_verbs[] = {
8150 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8151 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8152 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8153 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8154 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8155 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8156 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8157 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8158 { } /* end */
8159};
8160
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008161static struct hda_verb alc888_6st_dell_verbs[] = {
8162 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8163 { }
8164};
8165
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008166static void alc888_3st_hp_init_hook(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008167{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008168 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008169
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008170 spec->autocfg.hp_pins[0] = 0x1b;
8171 spec->autocfg.speaker_pins[0] = 0x14;
8172 spec->autocfg.speaker_pins[1] = 0x16;
8173 spec->autocfg.speaker_pins[2] = 0x18;
8174 alc_automute_amp(codec);
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008175}
8176
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008177static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008178 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01008179 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
8180 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008181 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008182 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008183};
8184
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008185/*
8186 * 2ch mode
8187 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008188static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008189 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8190 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8191 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
8192 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008193 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008194};
8195
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008196/*
8197 * 4ch mode
8198 */
8199static struct hda_verb alc888_3st_hp_4ch_init[] = {
8200 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8201 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8202 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8203 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8204 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8205 { } /* end */
8206};
8207
8208/*
8209 * 6ch mode
8210 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008211static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008212 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8213 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008214 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008215 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8216 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008217 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8218 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008219};
8220
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008221static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008222 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008223 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008224 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008225};
8226
Kailang Yang272a5272007-05-14 11:00:38 +02008227/* toggle front-jack and RCA according to the hp-jack state */
8228static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
8229{
8230 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008231
Kailang Yang272a5272007-05-14 11:00:38 +02008232 present = snd_hda_codec_read(codec, 0x1b, 0,
8233 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008234 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8235 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8236 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8237 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008238}
8239
8240/* toggle RCA according to the front-jack state */
8241static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
8242{
8243 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008244
Kailang Yang272a5272007-05-14 11:00:38 +02008245 present = snd_hda_codec_read(codec, 0x14, 0,
8246 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008247 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8248 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008249}
Takashi Iwai47fd8302007-08-10 17:11:07 +02008250
Kailang Yang272a5272007-05-14 11:00:38 +02008251static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
8252 unsigned int res)
8253{
8254 if ((res >> 26) == ALC880_HP_EVENT)
8255 alc888_lenovo_ms7195_front_automute(codec);
8256 if ((res >> 26) == ALC880_FRONT_EVENT)
8257 alc888_lenovo_ms7195_rca_automute(codec);
8258}
8259
8260static struct hda_verb alc883_medion_md2_verbs[] = {
8261 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8262 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8263
8264 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8265
8266 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8267 { } /* end */
8268};
8269
8270/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008271static void alc883_medion_md2_init_hook(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02008272{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008273 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008274
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008275 spec->autocfg.hp_pins[0] = 0x14;
8276 spec->autocfg.speaker_pins[0] = 0x15;
8277 alc_automute_amp(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02008278}
8279
Kailang Yangccc656c2006-10-17 12:32:26 +02008280/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008281#define alc883_tagra_init_hook alc882_targa_init_hook
8282#define alc883_tagra_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01008283
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008284static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
8285{
8286 unsigned int present;
8287
8288 present = snd_hda_codec_read(codec, 0x18, 0,
8289 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8290 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
8291 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8292}
8293
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008294static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008295{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008296 struct alc_spec *spec = codec->spec;
8297
8298 spec->autocfg.hp_pins[0] = 0x15;
8299 spec->autocfg.speaker_pins[0] = 0x14;
8300 alc_automute_amp(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008301 alc883_clevo_m720_mic_automute(codec);
8302}
8303
8304static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01008305 unsigned int res)
8306{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008307 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008308 case ALC880_MIC_EVENT:
8309 alc883_clevo_m720_mic_automute(codec);
8310 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008311 default:
8312 alc_automute_amp_unsol_event(codec, res);
8313 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008314 }
Jiang zhe368c7a92008-03-04 11:20:33 +01008315}
8316
Jiang zhefb97dc62008-03-06 11:07:11 +01008317/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008318static void alc883_2ch_fujitsu_pi2515_init_hook(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008319{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008320 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008321
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008322 spec->autocfg.hp_pins[0] = 0x14;
8323 spec->autocfg.speaker_pins[0] = 0x15;
8324 alc_automute_amp(codec);
Jiang zhefb97dc62008-03-06 11:07:11 +01008325}
8326
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008327static void alc883_haier_w66_init_hook(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008328{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008329 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008330
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008331 spec->autocfg.hp_pins[0] = 0x1b;
8332 spec->autocfg.speaker_pins[0] = 0x14;
8333 alc_automute_amp(codec);
Kailang Yang189609a2007-08-20 11:31:23 +02008334}
8335
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008336static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
8337{
8338 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008339 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008340
8341 present = snd_hda_codec_read(codec, 0x14, 0,
8342 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008343 bits = present ? HDA_AMP_MUTE : 0;
8344 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8345 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008346}
8347
8348static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
8349{
8350 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008351 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008352
8353 present = snd_hda_codec_read(codec, 0x1b, 0,
8354 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008355 bits = present ? HDA_AMP_MUTE : 0;
8356 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8357 HDA_AMP_MUTE, bits);
8358 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8359 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008360}
8361
8362static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
8363 unsigned int res)
8364{
8365 if ((res >> 26) == ALC880_HP_EVENT)
8366 alc883_lenovo_101e_all_automute(codec);
8367 if ((res >> 26) == ALC880_FRONT_EVENT)
8368 alc883_lenovo_101e_ispeaker_automute(codec);
8369}
8370
Takashi Iwai676a9b52007-08-16 15:23:35 +02008371/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008372static void alc883_acer_aspire_init_hook(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02008373{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008374 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008375
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008376 spec->autocfg.hp_pins[0] = 0x14;
8377 spec->autocfg.speaker_pins[0] = 0x15;
8378 spec->autocfg.speaker_pins[1] = 0x16;
8379 alc_automute_amp(codec);
Takashi Iwai676a9b52007-08-16 15:23:35 +02008380}
8381
Kailang Yangd1a991a2007-08-15 16:21:59 +02008382static struct hda_verb alc883_acer_eapd_verbs[] = {
8383 /* HP Pin: output 0 (0x0c) */
8384 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8385 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8386 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8387 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02008388 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8389 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008390 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008391 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
8392 /* eanable EAPD on medion laptop */
8393 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8394 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02008395 /* enable unsolicited event */
8396 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008397 { }
8398};
8399
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008400static void alc888_6st_dell_init_hook(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008401{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008402 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008403
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008404 spec->autocfg.hp_pins[0] = 0x1b;
8405 spec->autocfg.speaker_pins[0] = 0x14;
8406 spec->autocfg.speaker_pins[1] = 0x15;
8407 spec->autocfg.speaker_pins[2] = 0x16;
8408 spec->autocfg.speaker_pins[3] = 0x17;
8409 alc_automute_amp(codec);
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008410}
8411
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008412static void alc888_lenovo_sky_init_hook(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008413{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008414 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008415
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008416 spec->autocfg.hp_pins[0] = 0x1b;
8417 spec->autocfg.speaker_pins[0] = 0x14;
8418 spec->autocfg.speaker_pins[1] = 0x15;
8419 spec->autocfg.speaker_pins[2] = 0x16;
8420 spec->autocfg.speaker_pins[3] = 0x17;
8421 spec->autocfg.speaker_pins[4] = 0x1a;
8422 alc_automute_amp(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008423}
8424
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008425/*
8426 * generic initialization of ADC, input mixers and output mixers
8427 */
8428static struct hda_verb alc883_auto_init_verbs[] = {
8429 /*
8430 * Unmute ADC0-2 and set the default input to mic-in
8431 */
8432 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8433 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8434 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8435 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8436
Takashi Iwaicb53c622007-08-10 17:21:45 +02008437 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008438 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008439 * Note: PASD motherboards uses the Line In 2 as the input for
8440 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008441 */
8442 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008443 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8444 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8445 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8446 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8447 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008448
8449 /*
8450 * Set up output mixers (0x0c - 0x0f)
8451 */
8452 /* set vol=0 to output mixers */
8453 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8454 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8455 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8456 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8457 /* set up input amps for analog loopback */
8458 /* Amp Indices: DAC = 0, mixer = 1 */
8459 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8460 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8461 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8462 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8463 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8464 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8465 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8466 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8467 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8468 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8469
8470 /* FIXME: use matrix-type input source selection */
8471 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8472 /* Input mixer1 */
8473 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8474 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8475 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008476 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008477 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
8478 /* Input mixer2 */
8479 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8480 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8481 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008482 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Andy Shevchenkoe3cde642007-12-03 16:50:58 +01008483 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008484
8485 { }
8486};
8487
Kailang Yange2757d52008-08-26 13:17:46 +02008488static struct hda_verb alc888_asus_m90v_verbs[] = {
8489 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8490 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8491 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8492 /* enable unsolicited event */
8493 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8494 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8495 { } /* end */
8496};
8497
8498static void alc883_nb_mic_automute(struct hda_codec *codec)
8499{
8500 unsigned int present;
8501
8502 present = snd_hda_codec_read(codec, 0x18, 0,
8503 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8504 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8505 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
8506 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8507 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
8508}
8509
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008510static void alc883_M90V_init_hook(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02008511{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008512 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02008513
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008514 spec->autocfg.hp_pins[0] = 0x1b;
8515 spec->autocfg.speaker_pins[0] = 0x14;
8516 spec->autocfg.speaker_pins[1] = 0x15;
8517 spec->autocfg.speaker_pins[2] = 0x16;
8518 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008519}
8520
8521static void alc883_mode2_unsol_event(struct hda_codec *codec,
8522 unsigned int res)
8523{
8524 switch (res >> 26) {
Kailang Yange2757d52008-08-26 13:17:46 +02008525 case ALC880_MIC_EVENT:
8526 alc883_nb_mic_automute(codec);
8527 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008528 default:
8529 alc_sku_unsol_event(codec, res);
8530 break;
Kailang Yange2757d52008-08-26 13:17:46 +02008531 }
8532}
8533
8534static void alc883_mode2_inithook(struct hda_codec *codec)
8535{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008536 alc883_M90V_init_hook(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008537 alc883_nb_mic_automute(codec);
8538}
8539
8540static struct hda_verb alc888_asus_eee1601_verbs[] = {
8541 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8542 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8543 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8544 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8545 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8546 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
8547 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
8548 /* enable unsolicited event */
8549 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8550 { } /* end */
8551};
8552
Kailang Yange2757d52008-08-26 13:17:46 +02008553static void alc883_eee1601_inithook(struct hda_codec *codec)
8554{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008555 struct alc_spec *spec = codec->spec;
8556
8557 spec->autocfg.hp_pins[0] = 0x14;
8558 spec->autocfg.speaker_pins[0] = 0x1b;
8559 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008560}
8561
Takashi Iwaicb53c622007-08-10 17:21:45 +02008562#ifdef CONFIG_SND_HDA_POWER_SAVE
8563#define alc883_loopbacks alc880_loopbacks
8564#endif
8565
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008566/* pcm configuration: identiacal with ALC880 */
8567#define alc883_pcm_analog_playback alc880_pcm_analog_playback
8568#define alc883_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +01008569#define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008570#define alc883_pcm_digital_playback alc880_pcm_digital_playback
8571#define alc883_pcm_digital_capture alc880_pcm_digital_capture
8572
8573/*
8574 * configuration and preset
8575 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008576static const char *alc883_models[ALC883_MODEL_LAST] = {
8577 [ALC883_3ST_2ch_DIG] = "3stack-dig",
8578 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
8579 [ALC883_3ST_6ch] = "3stack-6ch",
8580 [ALC883_6ST_DIG] = "6stack-dig",
8581 [ALC883_TARGA_DIG] = "targa-dig",
8582 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008583 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02008584 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008585 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008586 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02008587 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008588 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008589 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02008590 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
8591 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02008592 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02008593 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008594 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008595 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008596 [ALC883_MITAC] = "mitac",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008597 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01008598 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008599 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02008600 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Wu Fengguang3ab90932008-11-17 09:51:09 +01008601 [ALC1200_ASUS_P5Q] = "asus-p5q",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008602 [ALC883_AUTO] = "auto",
8603};
8604
8605static struct snd_pci_quirk alc883_cfg_tbl[] = {
8606 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008607 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01008608 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01008609 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008610 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
8611 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02008612 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008613 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
8614 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008615 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
8616 ALC888_ACER_ASPIRE_4930G),
Takashi Iwaib3bdb302009-02-18 13:16:26 +01008617 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC883_AUTO),
Takashi Iwai94683502009-02-13 09:31:20 +01008618 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC883_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008619 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
8620 ALC888_ACER_ASPIRE_4930G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01008621 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
8622 ALC888_ACER_ASPIRE_4930G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02008623 /* default Acer -- disabled as it causes more problems.
8624 * model=auto should work fine now
8625 */
8626 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008627 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Tobin Davisfebe3372007-06-12 11:27:46 +02008628 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008629 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
8630 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01008631 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01008632 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03008633 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Kailang Yanga01c30c2008-10-15 11:14:58 +02008634 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008635 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01008636 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01008637 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02008638 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Travis Place97ec7102008-05-23 18:31:46 +02008639 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008640 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008641 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008642 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
8643 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02008644 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008645 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Tobin Davis57b14f22007-04-18 23:05:36 +02008646 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008647 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
8648 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
8649 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Jiang zhe4383fae2008-04-14 12:58:57 +02008650 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008651 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01008652 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008653 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
8654 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
8655 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
8656 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
8657 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
8658 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
8659 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
8660 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
8661 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008662 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
8663 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02008664 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01008665 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01008666 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01008667 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02008668 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008669 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008670 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008671 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
8672 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
Takashi Iwaidea0a502009-02-09 17:14:52 +01008673 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04008674 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008675 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02008676 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01008677 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02008678 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008679 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02008680 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02008681 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008682 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
8683 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02008684 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02008685 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01008686 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01008687 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02008688 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008689 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
8690 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008691 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Wu Fengguang4b558992009-01-12 09:18:58 +08008692 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC883_3ST_6ch_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008693 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008694 {}
8695};
8696
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08008697static hda_nid_t alc883_slave_dig_outs[] = {
8698 ALC1200_DIGOUT_NID, 0,
8699};
8700
Wu Fengguangb25c9da2009-02-06 15:02:27 +08008701static hda_nid_t alc1200_slave_dig_outs[] = {
8702 ALC883_DIGOUT_NID, 0,
8703};
8704
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008705static struct alc_config_preset alc883_presets[] = {
8706 [ALC883_3ST_2ch_DIG] = {
8707 .mixers = { alc883_3ST_2ch_mixer },
8708 .init_verbs = { alc883_init_verbs },
8709 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8710 .dac_nids = alc883_dac_nids,
8711 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008712 .dig_in_nid = ALC883_DIGIN_NID,
8713 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8714 .channel_mode = alc883_3ST_2ch_modes,
8715 .input_mux = &alc883_capture_source,
8716 },
8717 [ALC883_3ST_6ch_DIG] = {
8718 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8719 .init_verbs = { alc883_init_verbs },
8720 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8721 .dac_nids = alc883_dac_nids,
8722 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008723 .dig_in_nid = ALC883_DIGIN_NID,
8724 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8725 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008726 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008727 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008728 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008729 [ALC883_3ST_6ch] = {
8730 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8731 .init_verbs = { alc883_init_verbs },
8732 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8733 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008734 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8735 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008736 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008737 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008738 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02008739 [ALC883_3ST_6ch_INTEL] = {
8740 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
8741 .init_verbs = { alc883_init_verbs },
8742 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8743 .dac_nids = alc883_dac_nids,
8744 .dig_out_nid = ALC883_DIGOUT_NID,
8745 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08008746 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +02008747 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
8748 .channel_mode = alc883_3ST_6ch_intel_modes,
8749 .need_dac_fix = 1,
8750 .input_mux = &alc883_3stack_6ch_intel,
8751 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008752 [ALC883_6ST_DIG] = {
8753 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
8754 .init_verbs = { alc883_init_verbs },
8755 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8756 .dac_nids = alc883_dac_nids,
8757 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008758 .dig_in_nid = ALC883_DIGIN_NID,
8759 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8760 .channel_mode = alc883_sixstack_modes,
8761 .input_mux = &alc883_capture_source,
8762 },
Kailang Yangccc656c2006-10-17 12:32:26 +02008763 [ALC883_TARGA_DIG] = {
8764 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
8765 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8766 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8767 .dac_nids = alc883_dac_nids,
8768 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008769 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8770 .channel_mode = alc883_3ST_6ch_modes,
8771 .need_dac_fix = 1,
8772 .input_mux = &alc883_capture_source,
8773 .unsol_event = alc883_tagra_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008774 .init_hook = alc883_tagra_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02008775 },
8776 [ALC883_TARGA_2ch_DIG] = {
8777 .mixers = { alc883_tagra_2ch_mixer},
8778 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8779 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8780 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008781 .adc_nids = alc883_adc_nids_alt,
8782 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangccc656c2006-10-17 12:32:26 +02008783 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008784 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8785 .channel_mode = alc883_3ST_2ch_modes,
8786 .input_mux = &alc883_capture_source,
8787 .unsol_event = alc883_tagra_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008788 .init_hook = alc883_tagra_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02008789 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008790 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008791 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008792 /* On TravelMate laptops, GPIO 0 enables the internal speaker
8793 * and the headphone jack. Turn this on and rely on the
8794 * standard mute methods whenever the user wants to turn
8795 * these outputs off.
8796 */
8797 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
8798 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8799 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008800 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8801 .channel_mode = alc883_3ST_2ch_modes,
8802 .input_mux = &alc883_capture_source,
8803 },
Tobin Davis2880a862007-08-07 11:50:26 +02008804 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008805 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02008806 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02008807 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8808 .dac_nids = alc883_dac_nids,
8809 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02008810 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8811 .channel_mode = alc883_3ST_2ch_modes,
8812 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008813 .unsol_event = alc_automute_amp_unsol_event,
8814 .init_hook = alc883_acer_aspire_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +02008815 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008816 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008817 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008818 alc883_chmode_mixer },
8819 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
8820 alc888_acer_aspire_4930g_verbs },
8821 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8822 .dac_nids = alc883_dac_nids,
8823 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
8824 .adc_nids = alc883_adc_nids_rev,
8825 .capsrc_nids = alc883_capsrc_nids_rev,
8826 .dig_out_nid = ALC883_DIGOUT_NID,
8827 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8828 .channel_mode = alc883_3ST_6ch_modes,
8829 .need_dac_fix = 1,
8830 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008831 ARRAY_SIZE(alc888_2_capture_sources),
8832 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008833 .unsol_event = alc_automute_amp_unsol_event,
8834 .init_hook = alc888_acer_aspire_4930g_init_hook,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008835 },
Tobin Davisc07584c2006-10-13 12:32:16 +02008836 [ALC883_MEDION] = {
8837 .mixers = { alc883_fivestack_mixer,
8838 alc883_chmode_mixer },
8839 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008840 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02008841 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8842 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008843 .adc_nids = alc883_adc_nids_alt,
8844 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Tobin Davisc07584c2006-10-13 12:32:16 +02008845 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8846 .channel_mode = alc883_sixstack_modes,
8847 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008848 },
Kailang Yang272a5272007-05-14 11:00:38 +02008849 [ALC883_MEDION_MD2] = {
8850 .mixers = { alc883_medion_md2_mixer},
8851 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
8852 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8853 .dac_nids = alc883_dac_nids,
8854 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008855 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8856 .channel_mode = alc883_3ST_2ch_modes,
8857 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008858 .unsol_event = alc_automute_amp_unsol_event,
8859 .init_hook = alc883_medion_md2_init_hook,
Kailang Yangea1fb292008-08-26 12:58:38 +02008860 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008861 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008862 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008863 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
8864 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8865 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008866 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8867 .channel_mode = alc883_3ST_2ch_modes,
8868 .input_mux = &alc883_capture_source,
8869 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008870 [ALC883_CLEVO_M720] = {
8871 .mixers = { alc883_clevo_m720_mixer },
8872 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01008873 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8874 .dac_nids = alc883_dac_nids,
8875 .dig_out_nid = ALC883_DIGOUT_NID,
8876 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8877 .channel_mode = alc883_3ST_2ch_modes,
8878 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008879 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008880 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +01008881 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008882 [ALC883_LENOVO_101E_2ch] = {
8883 .mixers = { alc883_lenovo_101e_2ch_mixer},
8884 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
8885 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8886 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008887 .adc_nids = alc883_adc_nids_alt,
8888 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008889 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8890 .channel_mode = alc883_3ST_2ch_modes,
8891 .input_mux = &alc883_lenovo_101e_capture_source,
8892 .unsol_event = alc883_lenovo_101e_unsol_event,
8893 .init_hook = alc883_lenovo_101e_all_automute,
8894 },
Kailang Yang272a5272007-05-14 11:00:38 +02008895 [ALC883_LENOVO_NB0763] = {
8896 .mixers = { alc883_lenovo_nb0763_mixer },
8897 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
8898 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8899 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02008900 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8901 .channel_mode = alc883_3ST_2ch_modes,
8902 .need_dac_fix = 1,
8903 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008904 .unsol_event = alc_automute_amp_unsol_event,
8905 .init_hook = alc883_medion_md2_init_hook,
Kailang Yang272a5272007-05-14 11:00:38 +02008906 },
8907 [ALC888_LENOVO_MS7195_DIG] = {
8908 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8909 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
8910 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8911 .dac_nids = alc883_dac_nids,
8912 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008913 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8914 .channel_mode = alc883_3ST_6ch_modes,
8915 .need_dac_fix = 1,
8916 .input_mux = &alc883_capture_source,
8917 .unsol_event = alc883_lenovo_ms7195_unsol_event,
8918 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02008919 },
8920 [ALC883_HAIER_W66] = {
8921 .mixers = { alc883_tagra_2ch_mixer},
8922 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
8923 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8924 .dac_nids = alc883_dac_nids,
8925 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02008926 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8927 .channel_mode = alc883_3ST_2ch_modes,
8928 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008929 .unsol_event = alc_automute_amp_unsol_event,
8930 .init_hook = alc883_haier_w66_init_hook,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01008931 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008932 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01008933 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008934 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008935 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8936 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008937 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
8938 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008939 .need_dac_fix = 1,
8940 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008941 .unsol_event = alc_automute_amp_unsol_event,
8942 .init_hook = alc888_3st_hp_init_hook,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008943 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008944 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01008945 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008946 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
8947 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8948 .dac_nids = alc883_dac_nids,
8949 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008950 .dig_in_nid = ALC883_DIGIN_NID,
8951 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8952 .channel_mode = alc883_sixstack_modes,
8953 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008954 .unsol_event = alc_automute_amp_unsol_event,
8955 .init_hook = alc888_6st_dell_init_hook,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008956 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008957 [ALC883_MITAC] = {
8958 .mixers = { alc883_mitac_mixer },
8959 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
8960 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8961 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008962 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8963 .channel_mode = alc883_3ST_2ch_modes,
8964 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008965 .unsol_event = alc_automute_amp_unsol_event,
8966 .init_hook = alc883_mitac_init_hook,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008967 },
Jiang zhefb97dc62008-03-06 11:07:11 +01008968 [ALC883_FUJITSU_PI2515] = {
8969 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
8970 .init_verbs = { alc883_init_verbs,
8971 alc883_2ch_fujitsu_pi2515_verbs},
8972 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8973 .dac_nids = alc883_dac_nids,
8974 .dig_out_nid = ALC883_DIGOUT_NID,
8975 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8976 .channel_mode = alc883_3ST_2ch_modes,
8977 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008978 .unsol_event = alc_automute_amp_unsol_event,
8979 .init_hook = alc883_2ch_fujitsu_pi2515_init_hook,
Jiang zhefb97dc62008-03-06 11:07:11 +01008980 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008981 [ALC888_FUJITSU_XA3530] = {
8982 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
8983 .init_verbs = { alc883_init_verbs,
8984 alc888_fujitsu_xa3530_verbs },
8985 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8986 .dac_nids = alc883_dac_nids,
8987 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
8988 .adc_nids = alc883_adc_nids_rev,
8989 .capsrc_nids = alc883_capsrc_nids_rev,
8990 .dig_out_nid = ALC883_DIGOUT_NID,
8991 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
8992 .channel_mode = alc888_4ST_8ch_intel_modes,
8993 .num_mux_defs =
8994 ARRAY_SIZE(alc888_2_capture_sources),
8995 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008996 .unsol_event = alc_automute_amp_unsol_event,
8997 .init_hook = alc888_fujitsu_xa3530_init_hook,
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008998 },
Kailang Yange2757d52008-08-26 13:17:46 +02008999 [ALC888_LENOVO_SKY] = {
9000 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
9001 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
9002 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9003 .dac_nids = alc883_dac_nids,
9004 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +02009005 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9006 .channel_mode = alc883_sixstack_modes,
9007 .need_dac_fix = 1,
9008 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009009 .unsol_event = alc_automute_amp_unsol_event,
9010 .init_hook = alc888_lenovo_sky_init_hook,
Kailang Yange2757d52008-08-26 13:17:46 +02009011 },
9012 [ALC888_ASUS_M90V] = {
9013 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9014 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
9015 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9016 .dac_nids = alc883_dac_nids,
9017 .dig_out_nid = ALC883_DIGOUT_NID,
9018 .dig_in_nid = ALC883_DIGIN_NID,
9019 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9020 .channel_mode = alc883_3ST_6ch_modes,
9021 .need_dac_fix = 1,
9022 .input_mux = &alc883_fujitsu_pi2515_capture_source,
9023 .unsol_event = alc883_mode2_unsol_event,
9024 .init_hook = alc883_mode2_inithook,
9025 },
9026 [ALC888_ASUS_EEE1601] = {
9027 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009028 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +02009029 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
9030 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9031 .dac_nids = alc883_dac_nids,
9032 .dig_out_nid = ALC883_DIGOUT_NID,
9033 .dig_in_nid = ALC883_DIGIN_NID,
9034 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9035 .channel_mode = alc883_3ST_2ch_modes,
9036 .need_dac_fix = 1,
9037 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009038 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +02009039 .init_hook = alc883_eee1601_inithook,
9040 },
Wu Fengguang3ab90932008-11-17 09:51:09 +01009041 [ALC1200_ASUS_P5Q] = {
9042 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9043 .init_verbs = { alc883_init_verbs },
9044 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9045 .dac_nids = alc883_dac_nids,
9046 .dig_out_nid = ALC1200_DIGOUT_NID,
9047 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +08009048 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +01009049 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9050 .channel_mode = alc883_sixstack_modes,
9051 .input_mux = &alc883_capture_source,
9052 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009053};
9054
9055
9056/*
9057 * BIOS auto configuration
9058 */
9059static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
9060 hda_nid_t nid, int pin_type,
9061 int dac_idx)
9062{
9063 /* set as output */
9064 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009065 int idx;
9066
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009067 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009068 if (spec->multiout.dac_nids[dac_idx] == 0x25)
9069 idx = 4;
9070 else
9071 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009072 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
9073
9074}
9075
9076static void alc883_auto_init_multi_out(struct hda_codec *codec)
9077{
9078 struct alc_spec *spec = codec->spec;
9079 int i;
9080
9081 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009082 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009083 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009084 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009085 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009086 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009087 }
9088}
9089
9090static void alc883_auto_init_hp_out(struct hda_codec *codec)
9091{
9092 struct alc_spec *spec = codec->spec;
9093 hda_nid_t pin;
9094
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009095 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009096 if (pin) /* connect to front */
9097 /* use dac 0 */
9098 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009099 pin = spec->autocfg.speaker_pins[0];
9100 if (pin)
9101 alc883_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009102}
9103
9104#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
9105#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
9106
9107static void alc883_auto_init_analog_input(struct hda_codec *codec)
9108{
9109 struct alc_spec *spec = codec->spec;
9110 int i;
9111
9112 for (i = 0; i < AUTO_PIN_LAST; i++) {
9113 hda_nid_t nid = spec->autocfg.input_pins[i];
9114 if (alc883_is_input_pin(nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01009115 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01009116 if (nid != ALC883_PIN_CD_NID &&
9117 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009118 snd_hda_codec_write(codec, nid, 0,
9119 AC_VERB_SET_AMP_GAIN_MUTE,
9120 AMP_OUT_MUTE);
9121 }
9122 }
9123}
9124
Takashi Iwaif511b012008-08-15 16:46:42 +02009125#define alc883_auto_init_input_src alc882_auto_init_input_src
9126
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009127/* almost identical with ALC880 parser... */
9128static int alc883_parse_auto_config(struct hda_codec *codec)
9129{
9130 struct alc_spec *spec = codec->spec;
9131 int err = alc880_parse_auto_config(codec);
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009132 struct auto_pin_cfg *cfg = &spec->autocfg;
9133 int i;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009134
9135 if (err < 0)
9136 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02009137 else if (!err)
9138 return 0; /* no config found */
9139
9140 err = alc_auto_add_mic_boost(codec);
9141 if (err < 0)
9142 return err;
9143
9144 /* hack - override the init verbs */
9145 spec->init_verbs[0] = alc883_auto_init_verbs;
Takashi Iwai776e1842007-08-29 15:07:11 +02009146
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009147 /* setup input_mux for ALC889 */
9148 if (codec->vendor_id == 0x10ec0889) {
9149 /* digital-mic input pin is excluded in alc880_auto_create..()
9150 * because it's under 0x18
9151 */
9152 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
9153 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
9154 struct hda_input_mux *imux = &spec->private_imux[0];
9155 for (i = 1; i < 3; i++)
9156 memcpy(&spec->private_imux[i],
9157 &spec->private_imux[0],
9158 sizeof(spec->private_imux[0]));
9159 imux->items[imux->num_items].label = "Int DMic";
9160 imux->items[imux->num_items].index = 0x0b;
9161 imux->num_items++;
9162 spec->num_mux_defs = 3;
9163 spec->input_mux = spec->private_imux;
9164 }
9165 }
9166
Takashi Iwai776e1842007-08-29 15:07:11 +02009167 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009168}
9169
9170/* additional initialization for auto-configuration model */
9171static void alc883_auto_init(struct hda_codec *codec)
9172{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009173 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009174 alc883_auto_init_multi_out(codec);
9175 alc883_auto_init_hp_out(codec);
9176 alc883_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02009177 alc883_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009178 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02009179 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009180}
9181
9182static int patch_alc883(struct hda_codec *codec)
9183{
9184 struct alc_spec *spec;
9185 int err, board_config;
9186
9187 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
9188 if (spec == NULL)
9189 return -ENOMEM;
9190
9191 codec->spec = spec;
9192
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02009193 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
9194
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009195 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
9196 alc883_models,
9197 alc883_cfg_tbl);
9198 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009199 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
9200 "trying auto-probe from BIOS...\n");
9201 board_config = ALC883_AUTO;
9202 }
9203
9204 if (board_config == ALC883_AUTO) {
9205 /* automatic parse from the BIOS config */
9206 err = alc883_parse_auto_config(codec);
9207 if (err < 0) {
9208 alc_free(codec);
9209 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009210 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009211 printk(KERN_INFO
9212 "hda_codec: Cannot set up configuration "
9213 "from BIOS. Using base mode...\n");
9214 board_config = ALC883_3ST_2ch_DIG;
9215 }
9216 }
9217
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09009218 err = snd_hda_attach_beep_device(codec, 0x1);
9219 if (err < 0) {
9220 alc_free(codec);
9221 return err;
9222 }
9223
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009224 if (board_config != ALC883_AUTO)
9225 setup_preset(spec, &alc883_presets[board_config]);
9226
Kailang Yang2f893282008-05-27 12:14:47 +02009227 switch (codec->vendor_id) {
9228 case 0x10ec0888:
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009229 if (!spec->num_adc_nids) {
9230 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
9231 spec->adc_nids = alc883_adc_nids;
9232 }
9233 if (!spec->capsrc_nids)
9234 spec->capsrc_nids = alc883_capsrc_nids;
9235 spec->capture_style = CAPT_MIX; /* matrix-style capture */
Takashi Iwai4a79ba32009-04-22 16:31:35 +02009236 spec->init_amp = ALC_INIT_DEFAULT; /* always initialize */
Kailang Yang2f893282008-05-27 12:14:47 +02009237 break;
9238 case 0x10ec0889:
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009239 if (!spec->num_adc_nids) {
9240 spec->num_adc_nids = ARRAY_SIZE(alc889_adc_nids);
9241 spec->adc_nids = alc889_adc_nids;
9242 }
9243 if (!spec->capsrc_nids)
9244 spec->capsrc_nids = alc889_capsrc_nids;
9245 spec->capture_style = CAPT_1MUX_MIX; /* 1mux/Nmix-style
9246 capture */
Kailang Yang2f893282008-05-27 12:14:47 +02009247 break;
9248 default:
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009249 if (!spec->num_adc_nids) {
9250 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
9251 spec->adc_nids = alc883_adc_nids;
9252 }
9253 if (!spec->capsrc_nids)
9254 spec->capsrc_nids = alc883_capsrc_nids;
9255 spec->capture_style = CAPT_MIX; /* matrix-style capture */
Kailang Yang2f893282008-05-27 12:14:47 +02009256 break;
9257 }
9258
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009259 spec->stream_analog_playback = &alc883_pcm_analog_playback;
9260 spec->stream_analog_capture = &alc883_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01009261 spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009262
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009263 spec->stream_digital_playback = &alc883_pcm_digital_playback;
9264 spec->stream_digital_capture = &alc883_pcm_digital_capture;
9265
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009266 if (!spec->cap_mixer)
9267 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01009268 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009269
Takashi Iwai2134ea42008-01-10 16:53:55 +01009270 spec->vmaster_nid = 0x0c;
9271
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009272 codec->patch_ops = alc_patch_ops;
9273 if (board_config == ALC883_AUTO)
9274 spec->init_hook = alc883_auto_init;
Kailang Yangf9423e72008-05-27 12:32:25 +02009275
Takashi Iwaicb53c622007-08-10 17:21:45 +02009276#ifdef CONFIG_SND_HDA_POWER_SAVE
9277 if (!spec->loopback.amplist)
9278 spec->loopback.amplist = alc883_loopbacks;
9279#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01009280 codec->proc_widget_hook = print_realtek_coef;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009281
9282 return 0;
9283}
9284
9285/*
Kailang Yangdf694da2005-12-05 19:42:22 +01009286 * ALC262 support
9287 */
9288
9289#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
9290#define ALC262_DIGIN_NID ALC880_DIGIN_NID
9291
9292#define alc262_dac_nids alc260_dac_nids
9293#define alc262_adc_nids alc882_adc_nids
9294#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +01009295#define alc262_capsrc_nids alc882_capsrc_nids
9296#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +01009297
9298#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01009299#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01009300
Kailang Yang4e555fe2008-08-26 13:05:55 +02009301static hda_nid_t alc262_dmic_adc_nids[1] = {
9302 /* ADC0 */
9303 0x09
9304};
9305
9306static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
9307
Kailang Yangdf694da2005-12-05 19:42:22 +01009308static struct snd_kcontrol_new alc262_base_mixer[] = {
9309 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9310 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9311 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9312 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9313 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9314 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9315 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9316 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009317 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009318 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9319 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009320 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009321 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
9322 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9323 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
9324 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009325 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01009326};
9327
Takashi Iwaice875f02008-01-28 18:17:43 +01009328/* update HP, line and mono-out pins according to the master switch */
9329static void alc262_hp_master_update(struct hda_codec *codec)
9330{
9331 struct alc_spec *spec = codec->spec;
9332 int val = spec->master_sw;
9333
9334 /* HP & line-out */
9335 snd_hda_codec_write_cache(codec, 0x1b, 0,
9336 AC_VERB_SET_PIN_WIDGET_CONTROL,
9337 val ? PIN_HP : 0);
9338 snd_hda_codec_write_cache(codec, 0x15, 0,
9339 AC_VERB_SET_PIN_WIDGET_CONTROL,
9340 val ? PIN_HP : 0);
9341 /* mono (speaker) depending on the HP jack sense */
9342 val = val && !spec->jack_present;
9343 snd_hda_codec_write_cache(codec, 0x16, 0,
9344 AC_VERB_SET_PIN_WIDGET_CONTROL,
9345 val ? PIN_OUT : 0);
9346}
9347
9348static void alc262_hp_bpc_automute(struct hda_codec *codec)
9349{
9350 struct alc_spec *spec = codec->spec;
9351 unsigned int presence;
9352 presence = snd_hda_codec_read(codec, 0x1b, 0,
9353 AC_VERB_GET_PIN_SENSE, 0);
9354 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9355 alc262_hp_master_update(codec);
9356}
9357
9358static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
9359{
9360 if ((res >> 26) != ALC880_HP_EVENT)
9361 return;
9362 alc262_hp_bpc_automute(codec);
9363}
9364
9365static void alc262_hp_wildwest_automute(struct hda_codec *codec)
9366{
9367 struct alc_spec *spec = codec->spec;
9368 unsigned int presence;
9369 presence = snd_hda_codec_read(codec, 0x15, 0,
9370 AC_VERB_GET_PIN_SENSE, 0);
9371 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9372 alc262_hp_master_update(codec);
9373}
9374
9375static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
9376 unsigned int res)
9377{
9378 if ((res >> 26) != ALC880_HP_EVENT)
9379 return;
9380 alc262_hp_wildwest_automute(codec);
9381}
9382
Takashi Iwaib72519b2009-05-08 14:31:55 +02009383#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +01009384
9385static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
9386 struct snd_ctl_elem_value *ucontrol)
9387{
9388 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9389 struct alc_spec *spec = codec->spec;
9390 int val = !!*ucontrol->value.integer.value;
9391
9392 if (val == spec->master_sw)
9393 return 0;
9394 spec->master_sw = val;
9395 alc262_hp_master_update(codec);
9396 return 1;
9397}
9398
Takashi Iwaib72519b2009-05-08 14:31:55 +02009399#define ALC262_HP_MASTER_SWITCH \
9400 { \
9401 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
9402 .name = "Master Playback Switch", \
9403 .info = snd_ctl_boolean_mono_info, \
9404 .get = alc262_hp_master_sw_get, \
9405 .put = alc262_hp_master_sw_put, \
9406 }
9407
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009408static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +02009409 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009410 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9411 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9412 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009413 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9414 HDA_OUTPUT),
9415 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9416 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009417 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9418 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009419 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009420 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9421 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009422 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009423 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9424 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9425 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9426 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009427 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
9428 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
9429 { } /* end */
9430};
9431
Kailang Yangcd7509a2007-01-26 18:33:17 +01009432static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +02009433 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +01009434 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9435 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9436 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9437 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009438 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9439 HDA_OUTPUT),
9440 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9441 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009442 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
9443 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009444 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009445 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9446 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9447 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9448 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009449 { } /* end */
9450};
9451
9452static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
9453 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9454 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009455 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009456 { } /* end */
9457};
9458
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009459/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009460static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009461{
9462 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009463
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009464 spec->autocfg.hp_pins[0] = 0x15;
9465 spec->autocfg.speaker_pins[0] = 0x0c; /* HACK: not actually a pin */
9466 alc_automute_amp(codec);
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009467}
9468
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009469static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +01009470 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9471 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009472 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9473 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9474 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9475 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9476 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9477 { } /* end */
9478};
9479
9480static struct hda_verb alc262_hp_t5735_verbs[] = {
9481 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9482 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9483
9484 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9485 { }
9486};
9487
Kailang Yang8c427222008-01-10 13:03:59 +01009488static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +01009489 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9490 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01009491 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
9492 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +01009493 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9494 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9495 { } /* end */
9496};
9497
9498static struct hda_verb alc262_hp_rp5700_verbs[] = {
9499 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9500 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9501 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9502 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9503 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9504 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9505 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9506 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9507 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9508 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9509 {}
9510};
9511
9512static struct hda_input_mux alc262_hp_rp5700_capture_source = {
9513 .num_items = 1,
9514 .items = {
9515 { "Line", 0x1 },
9516 },
9517};
9518
Takashi Iwai42171c12009-05-08 14:11:43 +02009519/* bind hp and internal speaker mute (with plug check) as master switch */
9520static void alc262_hippo_master_update(struct hda_codec *codec)
9521{
9522 struct alc_spec *spec = codec->spec;
9523 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
9524 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
9525 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
9526 unsigned int mute;
9527
9528 /* HP */
9529 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
9530 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
9531 HDA_AMP_MUTE, mute);
9532 /* mute internal speaker per jack sense */
9533 if (spec->jack_present)
9534 mute = HDA_AMP_MUTE;
9535 if (line_nid)
9536 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
9537 HDA_AMP_MUTE, mute);
9538 if (speaker_nid && speaker_nid != line_nid)
9539 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
9540 HDA_AMP_MUTE, mute);
9541}
9542
9543#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
9544
9545static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
9546 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +02009547{
9548 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +02009549 struct alc_spec *spec = codec->spec;
9550 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +02009551
Takashi Iwai42171c12009-05-08 14:11:43 +02009552 if (val == spec->master_sw)
9553 return 0;
9554 spec->master_sw = val;
9555 alc262_hippo_master_update(codec);
9556 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +02009557}
Takashi Iwai5b319542007-07-26 11:49:22 +02009558
Takashi Iwai42171c12009-05-08 14:11:43 +02009559#define ALC262_HIPPO_MASTER_SWITCH \
9560 { \
9561 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
9562 .name = "Master Playback Switch", \
9563 .info = snd_ctl_boolean_mono_info, \
9564 .get = alc262_hippo_master_sw_get, \
9565 .put = alc262_hippo_master_sw_put, \
9566 }
9567
9568static struct snd_kcontrol_new alc262_hippo_mixer[] = {
9569 ALC262_HIPPO_MASTER_SWITCH,
9570 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9571 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9572 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9573 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9574 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9575 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9576 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9577 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9578 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9579 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9580 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9581 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9582 { } /* end */
9583};
9584
9585static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
9586 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9587 ALC262_HIPPO_MASTER_SWITCH,
9588 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9589 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9590 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9591 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9592 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9593 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9594 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9595 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9596 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9597 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9598 { } /* end */
9599};
9600
9601/* mute/unmute internal speaker according to the hp jack and mute state */
9602static void alc262_hippo_automute(struct hda_codec *codec)
9603{
9604 struct alc_spec *spec = codec->spec;
9605 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
9606 unsigned int present;
9607
9608 /* need to execute and sync at first */
9609 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
9610 present = snd_hda_codec_read(codec, hp_nid, 0,
9611 AC_VERB_GET_PIN_SENSE, 0);
9612 spec->jack_present = (present & 0x80000000) != 0;
9613 alc262_hippo_master_update(codec);
9614}
9615
9616static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
9617{
9618 if ((res >> 26) != ALC880_HP_EVENT)
9619 return;
9620 alc262_hippo_automute(codec);
9621}
9622
9623static void alc262_hippo_init_hook(struct hda_codec *codec)
9624{
9625 struct alc_spec *spec = codec->spec;
9626
9627 spec->autocfg.hp_pins[0] = 0x15;
9628 spec->autocfg.speaker_pins[0] = 0x14;
9629 alc262_hippo_automute(codec);
9630}
9631
9632static void alc262_hippo1_init_hook(struct hda_codec *codec)
9633{
9634 struct alc_spec *spec = codec->spec;
9635
9636 spec->autocfg.hp_pins[0] = 0x1b;
9637 spec->autocfg.speaker_pins[0] = 0x14;
9638 alc262_hippo_automute(codec);
9639}
9640
9641
Kailang Yang272a5272007-05-14 11:00:38 +02009642static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +02009643 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +02009644 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +02009645 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9646 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9647 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9648 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9649 { } /* end */
9650};
9651
Kailang Yang83c34212007-07-05 11:43:05 +02009652static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +02009653 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9654 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +02009655 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9656 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9657 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9658 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9659 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9660 { } /* end */
9661};
Kailang Yang272a5272007-05-14 11:00:38 +02009662
Tony Vroonba340e82009-02-02 19:01:30 +00009663static struct snd_kcontrol_new alc262_tyan_mixer[] = {
9664 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9665 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
9666 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
9667 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
9668 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9669 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9670 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9671 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9672 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9673 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9674 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9675 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9676 { } /* end */
9677};
9678
9679static struct hda_verb alc262_tyan_verbs[] = {
9680 /* Headphone automute */
9681 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9682 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9683 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9684
9685 /* P11 AUX_IN, white 4-pin connector */
9686 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9687 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
9688 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
9689 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
9690
9691 {}
9692};
9693
9694/* unsolicited event for HP jack sensing */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009695static void alc262_tyan_init_hook(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +00009696{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009697 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +00009698
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009699 spec->autocfg.hp_pins[0] = 0x1b;
9700 spec->autocfg.speaker_pins[0] = 0x15;
9701 alc_automute_amp(codec);
Tony Vroonba340e82009-02-02 19:01:30 +00009702}
9703
Tony Vroonba340e82009-02-02 19:01:30 +00009704
Kailang Yangdf694da2005-12-05 19:42:22 +01009705#define alc262_capture_mixer alc882_capture_mixer
9706#define alc262_capture_alt_mixer alc882_capture_alt_mixer
9707
9708/*
9709 * generic initialization of ADC, input mixers and output mixers
9710 */
9711static struct hda_verb alc262_init_verbs[] = {
9712 /*
9713 * Unmute ADC0-2 and set the default input to mic-in
9714 */
9715 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9716 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9717 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9718 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9719 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9720 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9721
Takashi Iwaicb53c622007-08-10 17:21:45 +02009722 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01009723 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009724 * Note: PASD motherboards uses the Line In 2 as the input for
9725 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01009726 */
9727 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009728 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9729 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9730 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9731 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9732 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009733
9734 /*
9735 * Set up output mixers (0x0c - 0x0e)
9736 */
9737 /* set vol=0 to output mixers */
9738 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9739 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9740 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9741 /* set up input amps for analog loopback */
9742 /* Amp Indices: DAC = 0, mixer = 1 */
9743 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9744 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9745 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9746 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9747 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9748 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9749
9750 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9751 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9752 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9753 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9754 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9755 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9756
9757 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9758 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9759 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9760 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9761 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +02009762
Kailang Yangdf694da2005-12-05 19:42:22 +01009763 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9764 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +02009765
Kailang Yangdf694da2005-12-05 19:42:22 +01009766 /* FIXME: use matrix-type input source selection */
9767 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9768 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9769 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9770 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9771 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9772 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9773 /* Input mixer2 */
9774 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9775 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9776 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9777 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9778 /* Input mixer3 */
9779 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9780 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9781 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009782 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +01009783
9784 { }
9785};
9786
Kailang Yang4e555fe2008-08-26 13:05:55 +02009787static struct hda_verb alc262_eapd_verbs[] = {
9788 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
9789 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
9790 { }
9791};
9792
Kailang Yangccc656c2006-10-17 12:32:26 +02009793static struct hda_verb alc262_hippo_unsol_verbs[] = {
9794 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9795 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9796 {}
9797};
9798
9799static struct hda_verb alc262_hippo1_unsol_verbs[] = {
9800 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9801 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9802 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9803
9804 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9805 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9806 {}
9807};
9808
Kailang Yang272a5272007-05-14 11:00:38 +02009809static struct hda_verb alc262_sony_unsol_verbs[] = {
9810 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9811 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9812 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
9813
9814 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9815 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +09009816 {}
Kailang Yang272a5272007-05-14 11:00:38 +02009817};
9818
Kailang Yang4e555fe2008-08-26 13:05:55 +02009819static struct hda_input_mux alc262_dmic_capture_source = {
9820 .num_items = 2,
9821 .items = {
9822 { "Int DMic", 0x9 },
9823 { "Mic", 0x0 },
9824 },
9825};
9826
9827static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
9828 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9829 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9830 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9831 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9832 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +02009833 { } /* end */
9834};
9835
9836static struct hda_verb alc262_toshiba_s06_verbs[] = {
9837 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9838 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9839 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9840 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9841 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
9842 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9843 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
9844 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9845 {}
9846};
9847
9848static void alc262_dmic_automute(struct hda_codec *codec)
9849{
9850 unsigned int present;
9851
9852 present = snd_hda_codec_read(codec, 0x18, 0,
9853 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9854 snd_hda_codec_write(codec, 0x22, 0,
9855 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x09);
9856}
9857
Kailang Yang4e555fe2008-08-26 13:05:55 +02009858
9859/* unsolicited event for HP jack sensing */
9860static void alc262_toshiba_s06_unsol_event(struct hda_codec *codec,
9861 unsigned int res)
9862{
Kailang Yang4e555fe2008-08-26 13:05:55 +02009863 if ((res >> 26) == ALC880_MIC_EVENT)
9864 alc262_dmic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009865 else
9866 alc_sku_unsol_event(codec, res);
Kailang Yang4e555fe2008-08-26 13:05:55 +02009867}
9868
9869static void alc262_toshiba_s06_init_hook(struct hda_codec *codec)
9870{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009871 struct alc_spec *spec = codec->spec;
9872
9873 spec->autocfg.hp_pins[0] = 0x15;
9874 spec->autocfg.speaker_pins[0] = 0x14;
9875 alc_automute_pin(codec);
Kailang Yang4e555fe2008-08-26 13:05:55 +02009876 alc262_dmic_automute(codec);
9877}
9878
Takashi Iwai834be882006-03-01 14:16:17 +01009879/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +02009880 * nec model
9881 * 0x15 = headphone
9882 * 0x16 = internal speaker
9883 * 0x18 = external mic
9884 */
9885
9886static struct snd_kcontrol_new alc262_nec_mixer[] = {
9887 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
9888 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
9889
9890 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9891 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9892 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9893
9894 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9895 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9896 { } /* end */
9897};
9898
9899static struct hda_verb alc262_nec_verbs[] = {
9900 /* Unmute Speaker */
9901 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9902
9903 /* Headphone */
9904 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9905 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9906
9907 /* External mic to headphone */
9908 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9909 /* External mic to speaker */
9910 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9911 {}
9912};
9913
9914/*
Takashi Iwai834be882006-03-01 14:16:17 +01009915 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +01009916 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
9917 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +01009918 */
9919
9920#define ALC_HP_EVENT 0x37
9921
9922static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
9923 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9924 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +01009925 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9926 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +01009927 {}
9928};
9929
Jiang zhe0e31daf2008-03-20 12:12:39 +01009930static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
9931 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9932 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9933 {}
9934};
9935
Takashi Iwai834be882006-03-01 14:16:17 +01009936static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009937 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +01009938 .items = {
9939 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009940 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +01009941 { "CD", 0x4 },
9942 },
9943};
9944
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009945static struct hda_input_mux alc262_HP_capture_source = {
9946 .num_items = 5,
9947 .items = {
9948 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +02009949 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009950 { "Line", 0x2 },
9951 { "CD", 0x4 },
9952 { "AUX IN", 0x6 },
9953 },
9954};
9955
zhejiangaccbe492007-08-31 12:36:05 +02009956static struct hda_input_mux alc262_HP_D7000_capture_source = {
9957 .num_items = 4,
9958 .items = {
9959 { "Mic", 0x0 },
9960 { "Front Mic", 0x2 },
9961 { "Line", 0x1 },
9962 { "CD", 0x4 },
9963 },
9964};
9965
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009966/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +01009967static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
9968{
9969 struct alc_spec *spec = codec->spec;
9970 unsigned int mute;
9971
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009972 if (force || !spec->sense_updated) {
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009973 unsigned int present;
Takashi Iwai834be882006-03-01 14:16:17 +01009974 /* need to execute and sync at first */
9975 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009976 /* check laptop HP jack */
9977 present = snd_hda_codec_read(codec, 0x14, 0,
9978 AC_VERB_GET_PIN_SENSE, 0);
9979 /* need to execute and sync at first */
9980 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9981 /* check docking HP jack */
9982 present |= snd_hda_codec_read(codec, 0x1b, 0,
9983 AC_VERB_GET_PIN_SENSE, 0);
9984 if (present & AC_PINSENSE_PRESENCE)
9985 spec->jack_present = 1;
9986 else
9987 spec->jack_present = 0;
Takashi Iwai834be882006-03-01 14:16:17 +01009988 spec->sense_updated = 1;
9989 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009990 /* unmute internal speaker only if both HPs are unplugged and
9991 * master switch is on
9992 */
9993 if (spec->jack_present)
9994 mute = HDA_AMP_MUTE;
9995 else
Takashi Iwai834be882006-03-01 14:16:17 +01009996 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009997 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9998 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +01009999}
10000
10001/* unsolicited event for HP jack sensing */
10002static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
10003 unsigned int res)
10004{
10005 if ((res >> 26) != ALC_HP_EVENT)
10006 return;
10007 alc262_fujitsu_automute(codec, 1);
10008}
10009
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010010static void alc262_fujitsu_init_hook(struct hda_codec *codec)
10011{
10012 alc262_fujitsu_automute(codec, 1);
10013}
10014
Takashi Iwai834be882006-03-01 14:16:17 +010010015/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020010016static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
10017 .ops = &snd_hda_bind_vol,
10018 .values = {
10019 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
10020 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
10021 0
10022 },
10023};
Takashi Iwai834be882006-03-01 14:16:17 +010010024
Jiang zhe0e31daf2008-03-20 12:12:39 +010010025/* mute/unmute internal speaker according to the hp jack and mute state */
10026static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
10027{
10028 struct alc_spec *spec = codec->spec;
10029 unsigned int mute;
10030
10031 if (force || !spec->sense_updated) {
10032 unsigned int present_int_hp;
10033 /* need to execute and sync at first */
10034 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10035 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
10036 AC_VERB_GET_PIN_SENSE, 0);
10037 spec->jack_present = (present_int_hp & 0x80000000) != 0;
10038 spec->sense_updated = 1;
10039 }
10040 if (spec->jack_present) {
10041 /* mute internal speaker */
10042 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10043 HDA_AMP_MUTE, HDA_AMP_MUTE);
10044 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10045 HDA_AMP_MUTE, HDA_AMP_MUTE);
10046 } else {
10047 /* unmute internal speaker if necessary */
10048 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
10049 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10050 HDA_AMP_MUTE, mute);
10051 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10052 HDA_AMP_MUTE, mute);
10053 }
10054}
10055
10056/* unsolicited event for HP jack sensing */
10057static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
10058 unsigned int res)
10059{
10060 if ((res >> 26) != ALC_HP_EVENT)
10061 return;
10062 alc262_lenovo_3000_automute(codec, 1);
10063}
10064
Takashi Iwai834be882006-03-01 14:16:17 +010010065/* bind hp and internal speaker mute (with plug check) */
10066static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
10067 struct snd_ctl_elem_value *ucontrol)
10068{
10069 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10070 long *valp = ucontrol->value.integer.value;
10071 int change;
10072
Tony Vroon5d9fab22008-03-14 17:09:18 +010010073 change = snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10074 HDA_AMP_MUTE,
10075 valp ? 0 : HDA_AMP_MUTE);
10076 change |= snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
10077 HDA_AMP_MUTE,
10078 valp ? 0 : HDA_AMP_MUTE);
10079
Takashi Iwai82beb8f2007-08-10 17:09:26 +020010080 if (change)
10081 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010010082 return change;
10083}
10084
10085static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020010086 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010010087 {
10088 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10089 .name = "Master Playback Switch",
10090 .info = snd_hda_mixer_amp_switch_info,
10091 .get = snd_hda_mixer_amp_switch_get,
10092 .put = alc262_fujitsu_master_sw_put,
10093 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10094 },
10095 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10096 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10097 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10098 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10099 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010100 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10101 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10102 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010010103 { } /* end */
10104};
10105
Jiang zhe0e31daf2008-03-20 12:12:39 +010010106/* bind hp and internal speaker mute (with plug check) */
10107static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
10108 struct snd_ctl_elem_value *ucontrol)
10109{
10110 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10111 long *valp = ucontrol->value.integer.value;
10112 int change;
10113
10114 change = snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
10115 HDA_AMP_MUTE,
10116 valp ? 0 : HDA_AMP_MUTE);
10117
10118 if (change)
10119 alc262_lenovo_3000_automute(codec, 0);
10120 return change;
10121}
10122
10123static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
10124 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10125 {
10126 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10127 .name = "Master Playback Switch",
10128 .info = snd_hda_mixer_amp_switch_info,
10129 .get = snd_hda_mixer_amp_switch_get,
10130 .put = alc262_lenovo_3000_master_sw_put,
10131 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
10132 },
10133 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10134 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10135 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10136 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10137 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10138 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10139 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10140 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10141 { } /* end */
10142};
10143
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010144static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
10145 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020010146 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010147 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10148 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10149 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10150 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10151 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10152 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10153 { } /* end */
10154};
10155
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010156/* additional init verbs for Benq laptops */
10157static struct hda_verb alc262_EAPD_verbs[] = {
10158 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10159 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
10160 {}
10161};
10162
Kailang Yang83c34212007-07-05 11:43:05 +020010163static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
10164 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10165 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10166
10167 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10168 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
10169 {}
10170};
10171
Tobin Davisf651b502007-10-26 12:40:47 +020010172/* Samsung Q1 Ultra Vista model setup */
10173static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010174 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10175 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010176 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10177 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10178 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010179 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010180 { } /* end */
10181};
10182
10183static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010184 /* output mixer */
10185 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10186 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10187 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10188 /* speaker */
10189 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10190 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10191 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10192 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10193 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020010194 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010195 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10196 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10197 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10198 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10199 /* internal mic */
10200 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10201 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10202 /* ADC, choose mic */
10203 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10204 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10205 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10206 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10207 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10208 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10209 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10210 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10211 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
10212 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020010213 {}
10214};
10215
Tobin Davisf651b502007-10-26 12:40:47 +020010216/* mute/unmute internal speaker according to the hp jack and mute state */
10217static void alc262_ultra_automute(struct hda_codec *codec)
10218{
10219 struct alc_spec *spec = codec->spec;
10220 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020010221
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010222 mute = 0;
10223 /* auto-mute only when HP is used as HP */
10224 if (!spec->cur_mux[0]) {
10225 unsigned int present;
10226 /* need to execute and sync at first */
10227 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
10228 present = snd_hda_codec_read(codec, 0x15, 0,
10229 AC_VERB_GET_PIN_SENSE, 0);
10230 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
10231 if (spec->jack_present)
10232 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020010233 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010234 /* mute/unmute internal speaker */
10235 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10236 HDA_AMP_MUTE, mute);
10237 /* mute/unmute HP */
10238 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10239 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020010240}
10241
10242/* unsolicited event for HP jack sensing */
10243static void alc262_ultra_unsol_event(struct hda_codec *codec,
10244 unsigned int res)
10245{
10246 if ((res >> 26) != ALC880_HP_EVENT)
10247 return;
10248 alc262_ultra_automute(codec);
10249}
10250
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010251static struct hda_input_mux alc262_ultra_capture_source = {
10252 .num_items = 2,
10253 .items = {
10254 { "Mic", 0x1 },
10255 { "Headphone", 0x7 },
10256 },
10257};
10258
10259static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
10260 struct snd_ctl_elem_value *ucontrol)
10261{
10262 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10263 struct alc_spec *spec = codec->spec;
10264 int ret;
10265
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010266 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010267 if (!ret)
10268 return 0;
10269 /* reprogram the HP pin as mic or HP according to the input source */
10270 snd_hda_codec_write_cache(codec, 0x15, 0,
10271 AC_VERB_SET_PIN_WIDGET_CONTROL,
10272 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
10273 alc262_ultra_automute(codec); /* mute/unmute HP */
10274 return ret;
10275}
10276
10277static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
10278 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10279 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10280 {
10281 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10282 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010283 .info = alc_mux_enum_info,
10284 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010285 .put = alc262_ultra_mux_enum_put,
10286 },
10287 { } /* end */
10288};
10289
Kailang Yangdf694da2005-12-05 19:42:22 +010010290/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010291static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
10292 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010010293{
10294 hda_nid_t nid;
10295 int err;
10296
10297 spec->multiout.num_dacs = 1; /* only use one dac */
10298 spec->multiout.dac_nids = spec->private_dac_nids;
10299 spec->multiout.dac_nids[0] = 2;
10300
10301 nid = cfg->line_out_pins[0];
10302 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010303 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10304 "Front Playback Volume",
10305 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
10306 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010307 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010308 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10309 "Front Playback Switch",
10310 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
10311 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010312 return err;
10313 }
10314
Takashi Iwai82bc9552006-03-21 11:24:42 +010010315 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010316 if (nid) {
10317 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010318 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10319 "Speaker Playback Volume",
10320 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10321 HDA_OUTPUT));
10322 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010323 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010324 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10325 "Speaker Playback Switch",
10326 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10327 HDA_OUTPUT));
10328 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010329 return err;
10330 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010331 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10332 "Speaker Playback Switch",
10333 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10334 HDA_OUTPUT));
10335 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010336 return err;
10337 }
10338 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +020010339 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010340 if (nid) {
10341 /* spec->multiout.hp_nid = 2; */
10342 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010343 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10344 "Headphone Playback Volume",
10345 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10346 HDA_OUTPUT));
10347 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010348 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010349 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10350 "Headphone Playback Switch",
10351 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10352 HDA_OUTPUT));
10353 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010354 return err;
10355 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010356 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10357 "Headphone Playback Switch",
10358 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10359 HDA_OUTPUT));
10360 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010361 return err;
10362 }
10363 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010364 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010010365}
10366
10367/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010368#define alc262_auto_create_analog_input_ctls \
10369 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010010370
10371/*
10372 * generic initialization of ADC, input mixers and output mixers
10373 */
10374static struct hda_verb alc262_volume_init_verbs[] = {
10375 /*
10376 * Unmute ADC0-2 and set the default input to mic-in
10377 */
10378 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10379 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10380 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10381 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10382 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10383 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10384
Takashi Iwaicb53c622007-08-10 17:21:45 +020010385 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010386 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010387 * Note: PASD motherboards uses the Line In 2 as the input for
10388 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010389 */
10390 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010391 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10392 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10393 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10394 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10395 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010396
10397 /*
10398 * Set up output mixers (0x0c - 0x0f)
10399 */
10400 /* set vol=0 to output mixers */
10401 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10402 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10403 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020010404
Kailang Yangdf694da2005-12-05 19:42:22 +010010405 /* set up input amps for analog loopback */
10406 /* Amp Indices: DAC = 0, mixer = 1 */
10407 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10408 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10409 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10410 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10411 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10412 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10413
10414 /* FIXME: use matrix-type input source selection */
10415 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10416 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10417 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10418 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10419 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10420 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10421 /* Input mixer2 */
10422 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10423 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10424 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10425 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10426 /* Input mixer3 */
10427 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10428 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10429 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10430 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10431
10432 { }
10433};
10434
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010435static struct hda_verb alc262_HP_BPC_init_verbs[] = {
10436 /*
10437 * Unmute ADC0-2 and set the default input to mic-in
10438 */
10439 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10440 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10441 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10442 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10443 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10444 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10445
Takashi Iwaicb53c622007-08-10 17:21:45 +020010446 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010447 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010448 * Note: PASD motherboards uses the Line In 2 as the input for
10449 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010450 */
10451 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010452 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10453 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10454 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10455 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10456 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10457 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10458 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020010459
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010460 /*
10461 * Set up output mixers (0x0c - 0x0e)
10462 */
10463 /* set vol=0 to output mixers */
10464 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10465 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10466 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10467
10468 /* set up input amps for analog loopback */
10469 /* Amp Indices: DAC = 0, mixer = 1 */
10470 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10471 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10472 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10473 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10474 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10475 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10476
Takashi Iwaice875f02008-01-28 18:17:43 +010010477 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010478 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10479 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10480
10481 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10482 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10483
10484 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10485 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10486
10487 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10488 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10489 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10490 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10491 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10492
10493 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10494 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10495 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10496 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10497 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10498 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10499
10500
10501 /* FIXME: use matrix-type input source selection */
10502 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10503 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10504 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10505 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10506 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10507 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10508 /* Input mixer2 */
10509 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10510 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10511 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10512 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10513 /* Input mixer3 */
10514 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10515 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10516 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10517 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10518
Takashi Iwaice875f02008-01-28 18:17:43 +010010519 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10520
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010521 { }
10522};
10523
Kailang Yangcd7509a2007-01-26 18:33:17 +010010524static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
10525 /*
10526 * Unmute ADC0-2 and set the default input to mic-in
10527 */
10528 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10529 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10530 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10531 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10532 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10533 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10534
Takashi Iwaicb53c622007-08-10 17:21:45 +020010535 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010010536 * mixer widget
10537 * Note: PASD motherboards uses the Line In 2 as the input for front
10538 * panel mic (mic 2)
10539 */
10540 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010541 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10542 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10543 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10544 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10545 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10546 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10547 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10548 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010010549 /*
10550 * Set up output mixers (0x0c - 0x0e)
10551 */
10552 /* set vol=0 to output mixers */
10553 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10554 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10555 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10556
10557 /* set up input amps for analog loopback */
10558 /* Amp Indices: DAC = 0, mixer = 1 */
10559 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10560 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10561 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10562 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10563 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10564 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10565
10566
10567 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
10568 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
10569 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
10570 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
10571 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10572 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
10573 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
10574
10575 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10576 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10577
10578 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10579 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
10580
10581 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
10582 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10583 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10584 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10585 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10586 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10587
10588 /* FIXME: use matrix-type input source selection */
10589 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10590 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10591 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
10592 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
10593 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
10594 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
10595 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
10596 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10597 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
10598 /* Input mixer2 */
10599 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10600 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10601 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10602 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10603 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10604 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10605 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10606 /* Input mixer3 */
10607 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10608 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10609 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10610 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10611 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10612 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10613 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10614
Takashi Iwaice875f02008-01-28 18:17:43 +010010615 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10616
Kailang Yangcd7509a2007-01-26 18:33:17 +010010617 { }
10618};
10619
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010620static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
10621
10622 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
10623 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10624 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
10625
10626 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
10627 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10628 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10629 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10630
10631 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
10632 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10633 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10634 {}
10635};
10636
10637
Takashi Iwaicb53c622007-08-10 17:21:45 +020010638#ifdef CONFIG_SND_HDA_POWER_SAVE
10639#define alc262_loopbacks alc880_loopbacks
10640#endif
10641
Kailang Yangdf694da2005-12-05 19:42:22 +010010642/* pcm configuration: identiacal with ALC880 */
10643#define alc262_pcm_analog_playback alc880_pcm_analog_playback
10644#define alc262_pcm_analog_capture alc880_pcm_analog_capture
10645#define alc262_pcm_digital_playback alc880_pcm_digital_playback
10646#define alc262_pcm_digital_capture alc880_pcm_digital_capture
10647
10648/*
10649 * BIOS auto configuration
10650 */
10651static int alc262_parse_auto_config(struct hda_codec *codec)
10652{
10653 struct alc_spec *spec = codec->spec;
10654 int err;
10655 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
10656
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010657 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10658 alc262_ignore);
10659 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010660 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010661 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010010662 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010663 spec->multiout.max_channels = 2;
10664 spec->no_analog = 1;
10665 goto dig_only;
10666 }
Kailang Yangdf694da2005-12-05 19:42:22 +010010667 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010668 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010669 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
10670 if (err < 0)
10671 return err;
10672 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
10673 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010674 return err;
10675
10676 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10677
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010678 dig_only:
Takashi Iwai0852d7a2009-02-11 11:35:15 +010010679 if (spec->autocfg.dig_outs) {
Kailang Yangdf694da2005-12-05 19:42:22 +010010680 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
Takashi Iwai0852d7a2009-02-11 11:35:15 +010010681 spec->dig_out_type = spec->autocfg.dig_out_type[0];
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010682 }
Kailang Yangdf694da2005-12-05 19:42:22 +010010683 if (spec->autocfg.dig_in_pin)
10684 spec->dig_in_nid = ALC262_DIGIN_NID;
10685
Takashi Iwai603c4012008-07-30 15:01:44 +020010686 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010010687 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010010688
Takashi Iwaid88897e2008-10-31 15:01:37 +010010689 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020010690 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020010691 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010692
Takashi Iwai776e1842007-08-29 15:07:11 +020010693 err = alc_auto_add_mic_boost(codec);
10694 if (err < 0)
10695 return err;
10696
Takashi Iwai4a79ba32009-04-22 16:31:35 +020010697 alc_ssid_check(codec, 0x15, 0x14, 0x1b);
10698
Kailang Yangdf694da2005-12-05 19:42:22 +010010699 return 1;
10700}
10701
10702#define alc262_auto_init_multi_out alc882_auto_init_multi_out
10703#define alc262_auto_init_hp_out alc882_auto_init_hp_out
10704#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020010705#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010010706
10707
10708/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010709static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010010710{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010711 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010010712 alc262_auto_init_multi_out(codec);
10713 alc262_auto_init_hp_out(codec);
10714 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020010715 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010716 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020010717 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010010718}
10719
10720/*
10721 * configuration and preset
10722 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010723static const char *alc262_models[ALC262_MODEL_LAST] = {
10724 [ALC262_BASIC] = "basic",
10725 [ALC262_HIPPO] = "hippo",
10726 [ALC262_HIPPO_1] = "hippo_1",
10727 [ALC262_FUJITSU] = "fujitsu",
10728 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010010729 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010010730 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010010731 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010732 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020010733 [ALC262_BENQ_T31] = "benq-t31",
10734 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020010735 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010736 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020010737 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010010738 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010739 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000010740 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010741 [ALC262_AUTO] = "auto",
10742};
10743
10744static struct snd_pci_quirk alc262_cfg_tbl[] = {
10745 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010746 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010010747 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
10748 ALC262_HP_BPC),
10749 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
10750 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010010751 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
10752 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010753 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010754 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010755 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010756 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010757 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010758 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010759 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010760 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010761 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
10762 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
10763 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010764 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
10765 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010010766 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010767 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010768 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010769 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010010770 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwaif872a912009-02-26 00:57:01 +010010771 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
10772 ALC262_SONY_ASSAMD),
Akio Idehara36ca6e12008-06-09 22:57:40 +090010773 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010774 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020010775 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010776 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010010777 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000010778 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010010779 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
10780 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110010781 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010010782 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010783 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020010784 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010785 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010010786 {}
10787};
10788
10789static struct alc_config_preset alc262_presets[] = {
10790 [ALC262_BASIC] = {
10791 .mixers = { alc262_base_mixer },
10792 .init_verbs = { alc262_init_verbs },
10793 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10794 .dac_nids = alc262_dac_nids,
10795 .hp_nid = 0x03,
10796 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10797 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010010798 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010010799 },
Kailang Yangccc656c2006-10-17 12:32:26 +020010800 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020010801 .mixers = { alc262_hippo_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +020010802 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
10803 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10804 .dac_nids = alc262_dac_nids,
10805 .hp_nid = 0x03,
10806 .dig_out_nid = ALC262_DIGOUT_NID,
10807 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10808 .channel_mode = alc262_modes,
10809 .input_mux = &alc262_capture_source,
10810 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020010811 .init_hook = alc262_hippo_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +020010812 },
10813 [ALC262_HIPPO_1] = {
10814 .mixers = { alc262_hippo1_mixer },
10815 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
10816 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10817 .dac_nids = alc262_dac_nids,
10818 .hp_nid = 0x02,
10819 .dig_out_nid = ALC262_DIGOUT_NID,
10820 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10821 .channel_mode = alc262_modes,
10822 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020010823 .unsol_event = alc262_hippo_unsol_event,
10824 .init_hook = alc262_hippo1_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +020010825 },
Takashi Iwai834be882006-03-01 14:16:17 +010010826 [ALC262_FUJITSU] = {
10827 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010828 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
10829 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010010830 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10831 .dac_nids = alc262_dac_nids,
10832 .hp_nid = 0x03,
10833 .dig_out_nid = ALC262_DIGOUT_NID,
10834 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10835 .channel_mode = alc262_modes,
10836 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010837 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010838 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010010839 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010840 [ALC262_HP_BPC] = {
10841 .mixers = { alc262_HP_BPC_mixer },
10842 .init_verbs = { alc262_HP_BPC_init_verbs },
10843 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10844 .dac_nids = alc262_dac_nids,
10845 .hp_nid = 0x03,
10846 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10847 .channel_mode = alc262_modes,
10848 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010849 .unsol_event = alc262_hp_bpc_unsol_event,
10850 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010851 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010010852 [ALC262_HP_BPC_D7000_WF] = {
10853 .mixers = { alc262_HP_BPC_WildWest_mixer },
10854 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
10855 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10856 .dac_nids = alc262_dac_nids,
10857 .hp_nid = 0x03,
10858 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10859 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020010860 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010861 .unsol_event = alc262_hp_wildwest_unsol_event,
10862 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010863 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010010864 [ALC262_HP_BPC_D7000_WL] = {
10865 .mixers = { alc262_HP_BPC_WildWest_mixer,
10866 alc262_HP_BPC_WildWest_option_mixer },
10867 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
10868 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10869 .dac_nids = alc262_dac_nids,
10870 .hp_nid = 0x03,
10871 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10872 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020010873 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010874 .unsol_event = alc262_hp_wildwest_unsol_event,
10875 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010876 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010877 [ALC262_HP_TC_T5735] = {
10878 .mixers = { alc262_hp_t5735_mixer },
10879 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
10880 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10881 .dac_nids = alc262_dac_nids,
10882 .hp_nid = 0x03,
10883 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10884 .channel_mode = alc262_modes,
10885 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010886 .unsol_event = alc_automute_amp_unsol_event,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010887 .init_hook = alc262_hp_t5735_init_hook,
Kailang Yang8c427222008-01-10 13:03:59 +010010888 },
10889 [ALC262_HP_RP5700] = {
10890 .mixers = { alc262_hp_rp5700_mixer },
10891 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
10892 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10893 .dac_nids = alc262_dac_nids,
10894 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10895 .channel_mode = alc262_modes,
10896 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010897 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010898 [ALC262_BENQ_ED8] = {
10899 .mixers = { alc262_base_mixer },
10900 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
10901 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10902 .dac_nids = alc262_dac_nids,
10903 .hp_nid = 0x03,
10904 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10905 .channel_mode = alc262_modes,
10906 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010907 },
Kailang Yang272a5272007-05-14 11:00:38 +020010908 [ALC262_SONY_ASSAMD] = {
10909 .mixers = { alc262_sony_mixer },
10910 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
10911 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10912 .dac_nids = alc262_dac_nids,
10913 .hp_nid = 0x02,
10914 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10915 .channel_mode = alc262_modes,
10916 .input_mux = &alc262_capture_source,
10917 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020010918 .init_hook = alc262_hippo_init_hook,
Kailang Yang83c34212007-07-05 11:43:05 +020010919 },
10920 [ALC262_BENQ_T31] = {
10921 .mixers = { alc262_benq_t31_mixer },
10922 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
10923 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10924 .dac_nids = alc262_dac_nids,
10925 .hp_nid = 0x03,
10926 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10927 .channel_mode = alc262_modes,
10928 .input_mux = &alc262_capture_source,
10929 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020010930 .init_hook = alc262_hippo_init_hook,
Kailang Yangea1fb292008-08-26 12:58:38 +020010931 },
Tobin Davisf651b502007-10-26 12:40:47 +020010932 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010933 .mixers = { alc262_ultra_mixer },
10934 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010935 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020010936 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10937 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020010938 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10939 .channel_mode = alc262_modes,
10940 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010941 .adc_nids = alc262_adc_nids, /* ADC0 */
10942 .capsrc_nids = alc262_capsrc_nids,
10943 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020010944 .unsol_event = alc262_ultra_unsol_event,
10945 .init_hook = alc262_ultra_automute,
10946 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010010947 [ALC262_LENOVO_3000] = {
10948 .mixers = { alc262_lenovo_3000_mixer },
10949 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
10950 alc262_lenovo_3000_unsol_verbs },
10951 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10952 .dac_nids = alc262_dac_nids,
10953 .hp_nid = 0x03,
10954 .dig_out_nid = ALC262_DIGOUT_NID,
10955 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10956 .channel_mode = alc262_modes,
10957 .input_mux = &alc262_fujitsu_capture_source,
10958 .unsol_event = alc262_lenovo_3000_unsol_event,
10959 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010960 [ALC262_NEC] = {
10961 .mixers = { alc262_nec_mixer },
10962 .init_verbs = { alc262_nec_verbs },
10963 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10964 .dac_nids = alc262_dac_nids,
10965 .hp_nid = 0x03,
10966 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10967 .channel_mode = alc262_modes,
10968 .input_mux = &alc262_capture_source,
10969 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020010970 [ALC262_TOSHIBA_S06] = {
10971 .mixers = { alc262_toshiba_s06_mixer },
10972 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
10973 alc262_eapd_verbs },
10974 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10975 .capsrc_nids = alc262_dmic_capsrc_nids,
10976 .dac_nids = alc262_dac_nids,
10977 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
10978 .dig_out_nid = ALC262_DIGOUT_NID,
10979 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10980 .channel_mode = alc262_modes,
10981 .input_mux = &alc262_dmic_capture_source,
10982 .unsol_event = alc262_toshiba_s06_unsol_event,
10983 .init_hook = alc262_toshiba_s06_init_hook,
10984 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010985 [ALC262_TOSHIBA_RX1] = {
10986 .mixers = { alc262_toshiba_rx1_mixer },
10987 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
10988 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10989 .dac_nids = alc262_dac_nids,
10990 .hp_nid = 0x03,
10991 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10992 .channel_mode = alc262_modes,
10993 .input_mux = &alc262_capture_source,
10994 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020010995 .init_hook = alc262_hippo_init_hook,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010996 },
Tony Vroonba340e82009-02-02 19:01:30 +000010997 [ALC262_TYAN] = {
10998 .mixers = { alc262_tyan_mixer },
10999 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
11000 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11001 .dac_nids = alc262_dac_nids,
11002 .hp_nid = 0x02,
11003 .dig_out_nid = ALC262_DIGOUT_NID,
11004 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11005 .channel_mode = alc262_modes,
11006 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011007 .unsol_event = alc_automute_amp_unsol_event,
11008 .init_hook = alc262_tyan_init_hook,
Tony Vroonba340e82009-02-02 19:01:30 +000011009 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011010};
11011
11012static int patch_alc262(struct hda_codec *codec)
11013{
11014 struct alc_spec *spec;
11015 int board_config;
11016 int err;
11017
Robert P. J. Daydc041e02006-12-19 14:44:15 +010011018 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010011019 if (spec == NULL)
11020 return -ENOMEM;
11021
11022 codec->spec = spec;
11023#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011024 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
11025 * under-run
11026 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011027 {
11028 int tmp;
11029 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11030 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
11031 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11032 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
11033 }
11034#endif
11035
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020011036 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
11037
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011038 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
11039 alc262_models,
11040 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010011041
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011042 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011043 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
11044 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011045 board_config = ALC262_AUTO;
11046 }
11047
11048 if (board_config == ALC262_AUTO) {
11049 /* automatic parse from the BIOS config */
11050 err = alc262_parse_auto_config(codec);
11051 if (err < 0) {
11052 alc_free(codec);
11053 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011054 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011055 printk(KERN_INFO
11056 "hda_codec: Cannot set up configuration "
11057 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011058 board_config = ALC262_BASIC;
11059 }
11060 }
11061
Takashi Iwai07eba612009-02-19 08:06:35 +010011062 if (!spec->no_analog) {
11063 err = snd_hda_attach_beep_device(codec, 0x1);
11064 if (err < 0) {
11065 alc_free(codec);
11066 return err;
11067 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090011068 }
11069
Kailang Yangdf694da2005-12-05 19:42:22 +010011070 if (board_config != ALC262_AUTO)
11071 setup_preset(spec, &alc262_presets[board_config]);
11072
Kailang Yangdf694da2005-12-05 19:42:22 +010011073 spec->stream_analog_playback = &alc262_pcm_analog_playback;
11074 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020011075
Kailang Yangdf694da2005-12-05 19:42:22 +010011076 spec->stream_digital_playback = &alc262_pcm_digital_playback;
11077 spec->stream_digital_capture = &alc262_pcm_digital_capture;
11078
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011079 spec->capture_style = CAPT_MIX;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011080 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011081 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +010011082 unsigned int wcap = get_wcaps(codec, 0x07);
11083
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011084 /* get type */
11085 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +010011086 if (wcap != AC_WID_AUD_IN) {
11087 spec->adc_nids = alc262_adc_nids_alt;
11088 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwai88c71a92008-02-14 17:27:17 +010011089 spec->capsrc_nids = alc262_capsrc_nids_alt;
Kailang Yangdf694da2005-12-05 19:42:22 +010011090 } else {
11091 spec->adc_nids = alc262_adc_nids;
11092 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
Takashi Iwai88c71a92008-02-14 17:27:17 +010011093 spec->capsrc_nids = alc262_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010011094 }
11095 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011096 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011097 set_capture_mixer(spec);
Takashi Iwai07eba612009-02-19 08:06:35 +010011098 if (!spec->no_analog)
11099 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010011100
Takashi Iwai2134ea42008-01-10 16:53:55 +010011101 spec->vmaster_nid = 0x0c;
11102
Kailang Yangdf694da2005-12-05 19:42:22 +010011103 codec->patch_ops = alc_patch_ops;
11104 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011105 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011106#ifdef CONFIG_SND_HDA_POWER_SAVE
11107 if (!spec->loopback.amplist)
11108 spec->loopback.amplist = alc262_loopbacks;
11109#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010011110 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020011111
Kailang Yangdf694da2005-12-05 19:42:22 +010011112 return 0;
11113}
11114
Kailang Yangdf694da2005-12-05 19:42:22 +010011115/*
Kailang Yanga361d842007-06-05 12:30:55 +020011116 * ALC268 channel source setting (2 channel)
11117 */
11118#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
11119#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020011120
Kailang Yanga361d842007-06-05 12:30:55 +020011121static hda_nid_t alc268_dac_nids[2] = {
11122 /* front, hp */
11123 0x02, 0x03
11124};
11125
11126static hda_nid_t alc268_adc_nids[2] = {
11127 /* ADC0-1 */
11128 0x08, 0x07
11129};
11130
11131static hda_nid_t alc268_adc_nids_alt[1] = {
11132 /* ADC0 */
11133 0x08
11134};
11135
Takashi Iwaie1406342008-02-11 18:32:32 +010011136static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
11137
Kailang Yanga361d842007-06-05 12:30:55 +020011138static struct snd_kcontrol_new alc268_base_mixer[] = {
11139 /* output mixer control */
11140 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11141 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11142 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11143 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011144 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11145 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11146 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020011147 { }
11148};
11149
Takashi Iwai42171c12009-05-08 14:11:43 +020011150static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
11151 /* output mixer control */
11152 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11153 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11154 ALC262_HIPPO_MASTER_SWITCH,
11155 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11156 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11157 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11158 { }
11159};
11160
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011161/* bind Beep switches of both NID 0x0f and 0x10 */
11162static struct hda_bind_ctls alc268_bind_beep_sw = {
11163 .ops = &snd_hda_bind_sw,
11164 .values = {
11165 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
11166 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
11167 0
11168 },
11169};
11170
11171static struct snd_kcontrol_new alc268_beep_mixer[] = {
11172 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
11173 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
11174 { }
11175};
11176
Kailang Yangd1a991a2007-08-15 16:21:59 +020011177static struct hda_verb alc268_eapd_verbs[] = {
11178 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11179 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11180 { }
11181};
11182
Takashi Iwaid2738092007-08-16 14:59:45 +020011183/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020011184static struct hda_verb alc268_toshiba_verbs[] = {
11185 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11186 { } /* end */
11187};
11188
Kailang Yang8ef355d2008-08-26 13:10:22 +020011189static struct hda_input_mux alc268_acer_lc_capture_source = {
11190 .num_items = 2,
11191 .items = {
11192 { "i-Mic", 0x6 },
11193 { "E-Mic", 0x0 },
11194 },
11195};
11196
Takashi Iwaid2738092007-08-16 14:59:45 +020011197/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020011198/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020011199static struct hda_bind_ctls alc268_acer_bind_master_vol = {
11200 .ops = &snd_hda_bind_vol,
11201 .values = {
11202 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
11203 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
11204 0
11205 },
11206};
11207
Takashi Iwai889c4392007-08-23 18:56:52 +020011208/* mute/unmute internal speaker according to the hp jack and mute state */
11209static void alc268_acer_automute(struct hda_codec *codec, int force)
11210{
11211 struct alc_spec *spec = codec->spec;
11212 unsigned int mute;
11213
11214 if (force || !spec->sense_updated) {
11215 unsigned int present;
11216 present = snd_hda_codec_read(codec, 0x14, 0,
11217 AC_VERB_GET_PIN_SENSE, 0);
11218 spec->jack_present = (present & 0x80000000) != 0;
11219 spec->sense_updated = 1;
11220 }
11221 if (spec->jack_present)
11222 mute = HDA_AMP_MUTE; /* mute internal speaker */
11223 else /* unmute internal speaker if necessary */
11224 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
11225 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11226 HDA_AMP_MUTE, mute);
11227}
11228
11229
11230/* bind hp and internal speaker mute (with plug check) */
11231static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
11232 struct snd_ctl_elem_value *ucontrol)
11233{
11234 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11235 long *valp = ucontrol->value.integer.value;
11236 int change;
11237
11238 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
11239 HDA_AMP_MUTE,
11240 valp[0] ? 0 : HDA_AMP_MUTE);
11241 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
11242 HDA_AMP_MUTE,
11243 valp[1] ? 0 : HDA_AMP_MUTE);
11244 if (change)
11245 alc268_acer_automute(codec, 0);
11246 return change;
11247}
Takashi Iwaid2738092007-08-16 14:59:45 +020011248
Kailang Yang8ef355d2008-08-26 13:10:22 +020011249static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
11250 /* output mixer control */
11251 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11252 {
11253 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11254 .name = "Master Playback Switch",
11255 .info = snd_hda_mixer_amp_switch_info,
11256 .get = snd_hda_mixer_amp_switch_get,
11257 .put = alc268_acer_master_sw_put,
11258 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11259 },
11260 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
11261 { }
11262};
11263
Takashi Iwaid2738092007-08-16 14:59:45 +020011264static struct snd_kcontrol_new alc268_acer_mixer[] = {
11265 /* output mixer control */
11266 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11267 {
11268 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11269 .name = "Master Playback Switch",
11270 .info = snd_hda_mixer_amp_switch_info,
11271 .get = snd_hda_mixer_amp_switch_get,
11272 .put = alc268_acer_master_sw_put,
11273 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11274 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011275 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11276 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11277 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020011278 { }
11279};
11280
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011281static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
11282 /* output mixer control */
11283 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11284 {
11285 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11286 .name = "Master Playback Switch",
11287 .info = snd_hda_mixer_amp_switch_info,
11288 .get = snd_hda_mixer_amp_switch_get,
11289 .put = alc268_acer_master_sw_put,
11290 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11291 },
11292 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11293 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11294 { }
11295};
11296
Kailang Yang8ef355d2008-08-26 13:10:22 +020011297static struct hda_verb alc268_acer_aspire_one_verbs[] = {
11298 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11299 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11300 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11301 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11302 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
11303 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
11304 { }
11305};
11306
Takashi Iwaid2738092007-08-16 14:59:45 +020011307static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011308 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
11309 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020011310 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11311 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011312 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11313 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020011314 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11315 { }
11316};
11317
11318/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020011319#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
11320#define alc268_toshiba_init_hook alc262_hippo_init_hook
Takashi Iwaid2738092007-08-16 14:59:45 +020011321
11322static void alc268_acer_unsol_event(struct hda_codec *codec,
11323 unsigned int res)
11324{
Takashi Iwai889c4392007-08-23 18:56:52 +020011325 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020011326 return;
11327 alc268_acer_automute(codec, 1);
11328}
11329
Takashi Iwai889c4392007-08-23 18:56:52 +020011330static void alc268_acer_init_hook(struct hda_codec *codec)
11331{
11332 alc268_acer_automute(codec, 1);
11333}
11334
Kailang Yang8ef355d2008-08-26 13:10:22 +020011335/* toggle speaker-output according to the hp-jack state */
11336static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
11337{
11338 unsigned int present;
11339 unsigned char bits;
11340
11341 present = snd_hda_codec_read(codec, 0x15, 0,
11342 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11343 bits = present ? AMP_IN_MUTE(0) : 0;
11344 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
11345 AMP_IN_MUTE(0), bits);
11346 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
11347 AMP_IN_MUTE(0), bits);
11348}
11349
11350
11351static void alc268_acer_mic_automute(struct hda_codec *codec)
11352{
11353 unsigned int present;
11354
11355 present = snd_hda_codec_read(codec, 0x18, 0,
11356 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11357 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_CONNECT_SEL,
11358 present ? 0x0 : 0x6);
11359}
11360
11361static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
11362 unsigned int res)
11363{
11364 if ((res >> 26) == ALC880_HP_EVENT)
11365 alc268_aspire_one_speaker_automute(codec);
11366 if ((res >> 26) == ALC880_MIC_EVENT)
11367 alc268_acer_mic_automute(codec);
11368}
11369
11370static void alc268_acer_lc_init_hook(struct hda_codec *codec)
11371{
11372 alc268_aspire_one_speaker_automute(codec);
11373 alc268_acer_mic_automute(codec);
11374}
11375
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011376static struct snd_kcontrol_new alc268_dell_mixer[] = {
11377 /* output mixer control */
11378 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11379 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11380 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11381 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11382 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11383 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11384 { }
11385};
11386
11387static struct hda_verb alc268_dell_verbs[] = {
11388 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11389 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11390 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11391 { }
11392};
11393
11394/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011395static void alc268_dell_init_hook(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011396{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011397 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011398
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011399 spec->autocfg.hp_pins[0] = 0x15;
11400 spec->autocfg.speaker_pins[0] = 0x14;
11401 alc_automute_pin(codec);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011402}
11403
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011404static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
11405 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11406 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11407 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11408 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11409 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11410 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
11411 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
11412 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11413 { }
11414};
11415
11416static struct hda_verb alc267_quanta_il1_verbs[] = {
11417 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11418 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
11419 { }
11420};
11421
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011422static void alc267_quanta_il1_mic_automute(struct hda_codec *codec)
11423{
11424 unsigned int present;
11425
11426 present = snd_hda_codec_read(codec, 0x18, 0,
11427 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11428 snd_hda_codec_write(codec, 0x23, 0,
11429 AC_VERB_SET_CONNECT_SEL,
11430 present ? 0x00 : 0x01);
11431}
11432
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011433static void alc267_quanta_il1_init_hook(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011434{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011435 struct alc_spec *spec = codec->spec;
11436
11437 spec->autocfg.hp_pins[0] = 0x15;
11438 spec->autocfg.speaker_pins[0] = 0x14;
11439 alc_automute_pin(codec);
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011440 alc267_quanta_il1_mic_automute(codec);
11441}
11442
11443static void alc267_quanta_il1_unsol_event(struct hda_codec *codec,
11444 unsigned int res)
11445{
11446 switch (res >> 26) {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011447 case ALC880_MIC_EVENT:
11448 alc267_quanta_il1_mic_automute(codec);
11449 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011450 default:
11451 alc_sku_unsol_event(codec, res);
11452 break;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011453 }
11454}
11455
Kailang Yanga361d842007-06-05 12:30:55 +020011456/*
11457 * generic initialization of ADC, input mixers and output mixers
11458 */
11459static struct hda_verb alc268_base_init_verbs[] = {
11460 /* Unmute DAC0-1 and set vol = 0 */
11461 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011462 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011463
11464 /*
11465 * Set up output mixers (0x0c - 0x0e)
11466 */
11467 /* set vol=0 to output mixers */
11468 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020011469 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
11470
11471 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11472 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11473
11474 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11475 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11476 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11477 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11478 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11479 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11480 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11481 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11482
11483 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11484 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11485 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11486 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011487 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011488
11489 /* set PCBEEP vol = 0, mute connections */
11490 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11491 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11492 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020011493
Jiang Zhea9b3aa82007-12-20 13:13:13 +010011494 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020011495
Jiang Zhea9b3aa82007-12-20 13:13:13 +010011496 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
11497 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11498 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
11499 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011500
Kailang Yanga361d842007-06-05 12:30:55 +020011501 { }
11502};
11503
11504/*
11505 * generic initialization of ADC, input mixers and output mixers
11506 */
11507static struct hda_verb alc268_volume_init_verbs[] = {
11508 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010011509 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11510 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011511
11512 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11513 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11514 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11515 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11516 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11517
Kailang Yanga361d842007-06-05 12:30:55 +020011518 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020011519 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11520 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11521
11522 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011523 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011524
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011525 /* set PCBEEP vol = 0, mute connections */
11526 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11527 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11528 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020011529
11530 { }
11531};
11532
Kailang Yanga361d842007-06-05 12:30:55 +020011533static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
11534 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11535 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11536 {
11537 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11538 /* The multiple "Capture Source" controls confuse alsamixer
11539 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020011540 */
11541 /* .name = "Capture Source", */
11542 .name = "Input Source",
11543 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011544 .info = alc_mux_enum_info,
11545 .get = alc_mux_enum_get,
11546 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020011547 },
11548 { } /* end */
11549};
11550
11551static struct snd_kcontrol_new alc268_capture_mixer[] = {
11552 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11553 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11554 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
11555 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
11556 {
11557 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11558 /* The multiple "Capture Source" controls confuse alsamixer
11559 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020011560 */
11561 /* .name = "Capture Source", */
11562 .name = "Input Source",
11563 .count = 2,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011564 .info = alc_mux_enum_info,
11565 .get = alc_mux_enum_get,
11566 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020011567 },
11568 { } /* end */
11569};
11570
11571static struct hda_input_mux alc268_capture_source = {
11572 .num_items = 4,
11573 .items = {
11574 { "Mic", 0x0 },
11575 { "Front Mic", 0x1 },
11576 { "Line", 0x2 },
11577 { "CD", 0x3 },
11578 },
11579};
11580
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011581static struct hda_input_mux alc268_acer_capture_source = {
11582 .num_items = 3,
11583 .items = {
11584 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011585 { "Internal Mic", 0x1 },
11586 { "Line", 0x2 },
11587 },
11588};
11589
11590static struct hda_input_mux alc268_acer_dmic_capture_source = {
11591 .num_items = 3,
11592 .items = {
11593 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011594 { "Internal Mic", 0x6 },
11595 { "Line", 0x2 },
11596 },
11597};
11598
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011599#ifdef CONFIG_SND_DEBUG
11600static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011601 /* Volume widgets */
11602 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11603 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11604 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
11605 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
11606 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
11607 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
11608 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
11609 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
11610 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
11611 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
11612 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
11613 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
11614 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010011615 /* The below appears problematic on some hardwares */
11616 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011617 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11618 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
11619 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
11620 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
11621
11622 /* Modes for retasking pin widgets */
11623 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
11624 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
11625 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
11626 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
11627
11628 /* Controls for GPIO pins, assuming they are configured as outputs */
11629 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
11630 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
11631 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
11632 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
11633
11634 /* Switches to allow the digital SPDIF output pin to be enabled.
11635 * The ALC268 does not have an SPDIF input.
11636 */
11637 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
11638
11639 /* A switch allowing EAPD to be enabled. Some laptops seem to use
11640 * this output to turn on an external amplifier.
11641 */
11642 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
11643 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
11644
11645 { } /* end */
11646};
11647#endif
11648
Kailang Yanga361d842007-06-05 12:30:55 +020011649/* create input playback/capture controls for the given pin */
11650static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
11651 const char *ctlname, int idx)
11652{
11653 char name[32];
11654 int err;
11655
11656 sprintf(name, "%s Playback Volume", ctlname);
11657 if (nid == 0x14) {
11658 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11659 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
11660 HDA_OUTPUT));
11661 if (err < 0)
11662 return err;
11663 } else if (nid == 0x15) {
11664 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11665 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
11666 HDA_OUTPUT));
11667 if (err < 0)
11668 return err;
11669 } else
11670 return -1;
11671 sprintf(name, "%s Playback Switch", ctlname);
11672 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
11673 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
11674 if (err < 0)
11675 return err;
11676 return 0;
11677}
11678
11679/* add playback controls from the parsed DAC table */
11680static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
11681 const struct auto_pin_cfg *cfg)
11682{
11683 hda_nid_t nid;
11684 int err;
11685
11686 spec->multiout.num_dacs = 2; /* only use one dac */
11687 spec->multiout.dac_nids = spec->private_dac_nids;
11688 spec->multiout.dac_nids[0] = 2;
11689 spec->multiout.dac_nids[1] = 3;
11690
11691 nid = cfg->line_out_pins[0];
11692 if (nid)
Kailang Yangea1fb292008-08-26 12:58:38 +020011693 alc268_new_analog_output(spec, nid, "Front", 0);
Kailang Yanga361d842007-06-05 12:30:55 +020011694
11695 nid = cfg->speaker_pins[0];
11696 if (nid == 0x1d) {
11697 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11698 "Speaker Playback Volume",
11699 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
11700 if (err < 0)
11701 return err;
11702 }
11703 nid = cfg->hp_pins[0];
11704 if (nid)
11705 alc268_new_analog_output(spec, nid, "Headphone", 0);
11706
11707 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
11708 if (nid == 0x16) {
11709 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11710 "Mono Playback Switch",
11711 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
11712 if (err < 0)
11713 return err;
11714 }
Kailang Yangea1fb292008-08-26 12:58:38 +020011715 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020011716}
11717
11718/* create playback/capture controls for input pins */
11719static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
11720 const struct auto_pin_cfg *cfg)
11721{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011722 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020011723 int i, idx1;
11724
11725 for (i = 0; i < AUTO_PIN_LAST; i++) {
11726 switch(cfg->input_pins[i]) {
11727 case 0x18:
11728 idx1 = 0; /* Mic 1 */
11729 break;
11730 case 0x19:
11731 idx1 = 1; /* Mic 2 */
11732 break;
11733 case 0x1a:
11734 idx1 = 2; /* Line In */
11735 break;
Kailang Yangea1fb292008-08-26 12:58:38 +020011736 case 0x1c:
Kailang Yanga361d842007-06-05 12:30:55 +020011737 idx1 = 3; /* CD */
11738 break;
Takashi Iwai7194cae2008-03-06 16:58:17 +010011739 case 0x12:
11740 case 0x13:
11741 idx1 = 6; /* digital mics */
11742 break;
Kailang Yanga361d842007-06-05 12:30:55 +020011743 default:
11744 continue;
11745 }
11746 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
11747 imux->items[imux->num_items].index = idx1;
Kailang Yangea1fb292008-08-26 12:58:38 +020011748 imux->num_items++;
Kailang Yanga361d842007-06-05 12:30:55 +020011749 }
11750 return 0;
11751}
11752
11753static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
11754{
11755 struct alc_spec *spec = codec->spec;
11756 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
11757 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
11758 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
11759 unsigned int dac_vol1, dac_vol2;
11760
11761 if (speaker_nid) {
11762 snd_hda_codec_write(codec, speaker_nid, 0,
11763 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
11764 snd_hda_codec_write(codec, 0x0f, 0,
11765 AC_VERB_SET_AMP_GAIN_MUTE,
11766 AMP_IN_UNMUTE(1));
11767 snd_hda_codec_write(codec, 0x10, 0,
11768 AC_VERB_SET_AMP_GAIN_MUTE,
11769 AMP_IN_UNMUTE(1));
11770 } else {
11771 snd_hda_codec_write(codec, 0x0f, 0,
11772 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
11773 snd_hda_codec_write(codec, 0x10, 0,
11774 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
11775 }
11776
11777 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020011778 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020011779 dac_vol2 = AMP_OUT_ZERO;
11780 else if (line_nid == 0x15)
11781 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020011782 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020011783 dac_vol2 = AMP_OUT_ZERO;
11784 else if (hp_nid == 0x15)
11785 dac_vol1 = AMP_OUT_ZERO;
11786 if (line_nid != 0x16 || hp_nid != 0x16 ||
11787 spec->autocfg.line_out_pins[1] != 0x16 ||
11788 spec->autocfg.line_out_pins[2] != 0x16)
11789 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
11790
11791 snd_hda_codec_write(codec, 0x02, 0,
11792 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
11793 snd_hda_codec_write(codec, 0x03, 0,
11794 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
11795}
11796
11797/* pcm configuration: identiacal with ALC880 */
11798#define alc268_pcm_analog_playback alc880_pcm_analog_playback
11799#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010011800#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020011801#define alc268_pcm_digital_playback alc880_pcm_digital_playback
11802
11803/*
11804 * BIOS auto configuration
11805 */
11806static int alc268_parse_auto_config(struct hda_codec *codec)
11807{
11808 struct alc_spec *spec = codec->spec;
11809 int err;
11810 static hda_nid_t alc268_ignore[] = { 0 };
11811
11812 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11813 alc268_ignore);
11814 if (err < 0)
11815 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010011816 if (!spec->autocfg.line_outs) {
11817 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
11818 spec->multiout.max_channels = 2;
11819 spec->no_analog = 1;
11820 goto dig_only;
11821 }
Kailang Yanga361d842007-06-05 12:30:55 +020011822 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010011823 }
Kailang Yanga361d842007-06-05 12:30:55 +020011824 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
11825 if (err < 0)
11826 return err;
11827 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
11828 if (err < 0)
11829 return err;
11830
11831 spec->multiout.max_channels = 2;
11832
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010011833 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020011834 /* digital only support output */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010011835 if (spec->autocfg.dig_outs) {
Kailang Yanga361d842007-06-05 12:30:55 +020011836 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010011837 spec->dig_out_type = spec->autocfg.dig_out_type[0];
11838 }
Takashi Iwai603c4012008-07-30 15:01:44 +020011839 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011840 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020011841
Takashi Iwai892981f2009-03-02 08:04:35 +010011842 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011843 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011844
Takashi Iwaid88897e2008-10-31 15:01:37 +010011845 add_verb(spec, alc268_volume_init_verbs);
Kailang Yanga361d842007-06-05 12:30:55 +020011846 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011847 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020011848
Takashi Iwai776e1842007-08-29 15:07:11 +020011849 err = alc_auto_add_mic_boost(codec);
11850 if (err < 0)
11851 return err;
11852
Kailang Yanga361d842007-06-05 12:30:55 +020011853 return 1;
11854}
11855
11856#define alc268_auto_init_multi_out alc882_auto_init_multi_out
11857#define alc268_auto_init_hp_out alc882_auto_init_hp_out
11858#define alc268_auto_init_analog_input alc882_auto_init_analog_input
11859
11860/* init callback for auto-configuration model -- overriding the default init */
11861static void alc268_auto_init(struct hda_codec *codec)
11862{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011863 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020011864 alc268_auto_init_multi_out(codec);
11865 alc268_auto_init_hp_out(codec);
11866 alc268_auto_init_mono_speaker_out(codec);
11867 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011868 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020011869 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020011870}
11871
11872/*
11873 * configuration and preset
11874 */
11875static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011876 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020011877 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020011878 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020011879 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011880 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020011881 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011882 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011883 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011884#ifdef CONFIG_SND_DEBUG
11885 [ALC268_TEST] = "test",
11886#endif
Kailang Yanga361d842007-06-05 12:30:55 +020011887 [ALC268_AUTO] = "auto",
11888};
11889
11890static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020011891 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011892 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010011893 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011894 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010011895 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020011896 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
11897 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011898 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Takashi Iwai57d13922009-01-08 15:52:09 +010011899 SND_PCI_QUIRK(0x1028, 0x02b0, "Dell Inspiron Mini9", ALC268_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011900 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
Kailang Yanga361d842007-06-05 12:30:55 +020011901 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Kailang Yangd1a991a2007-08-15 16:21:59 +020011902 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
Takashi Iwai8e7f00f2007-09-07 10:58:58 +020011903 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
Travis Place2346d0c2008-09-01 08:24:00 +020011904 SND_PCI_QUIRK(0x1179, 0xff64, "TOSHIBA L305", ALC268_TOSHIBA),
Tony Vroon378bd6a2008-06-04 12:08:30 +020011905 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020011906 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011907 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011908 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Kailang Yanga361d842007-06-05 12:30:55 +020011909 {}
11910};
11911
11912static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011913 [ALC267_QUANTA_IL1] = {
Takashi Iwai22971e32009-02-10 11:56:44 +010011914 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011915 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11916 alc267_quanta_il1_verbs },
11917 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11918 .dac_nids = alc268_dac_nids,
11919 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11920 .adc_nids = alc268_adc_nids_alt,
11921 .hp_nid = 0x03,
11922 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11923 .channel_mode = alc268_modes,
11924 .input_mux = &alc268_capture_source,
11925 .unsol_event = alc267_quanta_il1_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011926 .init_hook = alc267_quanta_il1_init_hook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011927 },
Kailang Yanga361d842007-06-05 12:30:55 +020011928 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011929 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
11930 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020011931 .init_verbs = { alc268_base_init_verbs },
11932 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11933 .dac_nids = alc268_dac_nids,
11934 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11935 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011936 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020011937 .hp_nid = 0x03,
11938 .dig_out_nid = ALC268_DIGOUT_NID,
11939 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11940 .channel_mode = alc268_modes,
11941 .input_mux = &alc268_capture_source,
11942 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020011943 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011944 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011945 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020011946 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11947 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020011948 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11949 .dac_nids = alc268_dac_nids,
11950 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11951 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011952 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020011953 .hp_nid = 0x03,
11954 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11955 .channel_mode = alc268_modes,
11956 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020011957 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011958 .init_hook = alc268_toshiba_init_hook,
Takashi Iwaid2738092007-08-16 14:59:45 +020011959 },
11960 [ALC268_ACER] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011961 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
11962 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020011963 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11964 alc268_acer_verbs },
11965 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11966 .dac_nids = alc268_dac_nids,
11967 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11968 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011969 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020011970 .hp_nid = 0x02,
11971 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11972 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011973 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020011974 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020011975 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020011976 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011977 [ALC268_ACER_DMIC] = {
11978 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
11979 alc268_beep_mixer },
11980 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11981 alc268_acer_verbs },
11982 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11983 .dac_nids = alc268_dac_nids,
11984 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11985 .adc_nids = alc268_adc_nids_alt,
11986 .capsrc_nids = alc268_capsrc_nids,
11987 .hp_nid = 0x02,
11988 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11989 .channel_mode = alc268_modes,
11990 .input_mux = &alc268_acer_dmic_capture_source,
11991 .unsol_event = alc268_acer_unsol_event,
11992 .init_hook = alc268_acer_init_hook,
11993 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020011994 [ALC268_ACER_ASPIRE_ONE] = {
11995 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010011996 alc268_beep_mixer,
11997 alc268_capture_alt_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020011998 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11999 alc268_acer_aspire_one_verbs },
12000 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12001 .dac_nids = alc268_dac_nids,
12002 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12003 .adc_nids = alc268_adc_nids_alt,
12004 .capsrc_nids = alc268_capsrc_nids,
12005 .hp_nid = 0x03,
12006 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12007 .channel_mode = alc268_modes,
12008 .input_mux = &alc268_acer_lc_capture_source,
12009 .unsol_event = alc268_acer_lc_unsol_event,
12010 .init_hook = alc268_acer_lc_init_hook,
12011 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012012 [ALC268_DELL] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012013 .mixers = { alc268_dell_mixer, alc268_beep_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012014 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12015 alc268_dell_verbs },
12016 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12017 .dac_nids = alc268_dac_nids,
12018 .hp_nid = 0x02,
12019 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12020 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012021 .unsol_event = alc_sku_unsol_event,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012022 .init_hook = alc268_dell_init_hook,
12023 .input_mux = &alc268_capture_source,
12024 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012025 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012026 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12027 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012028 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12029 alc268_toshiba_verbs },
12030 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12031 .dac_nids = alc268_dac_nids,
12032 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12033 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012034 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012035 .hp_nid = 0x03,
12036 .dig_out_nid = ALC268_DIGOUT_NID,
12037 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12038 .channel_mode = alc268_modes,
12039 .input_mux = &alc268_capture_source,
12040 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020012041 .init_hook = alc268_toshiba_init_hook
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012042 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012043#ifdef CONFIG_SND_DEBUG
12044 [ALC268_TEST] = {
12045 .mixers = { alc268_test_mixer, alc268_capture_mixer },
12046 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12047 alc268_volume_init_verbs },
12048 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12049 .dac_nids = alc268_dac_nids,
12050 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12051 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012052 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012053 .hp_nid = 0x03,
12054 .dig_out_nid = ALC268_DIGOUT_NID,
12055 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12056 .channel_mode = alc268_modes,
12057 .input_mux = &alc268_capture_source,
12058 },
12059#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012060};
12061
12062static int patch_alc268(struct hda_codec *codec)
12063{
12064 struct alc_spec *spec;
12065 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010012066 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020012067
12068 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
12069 if (spec == NULL)
12070 return -ENOMEM;
12071
12072 codec->spec = spec;
12073
12074 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
12075 alc268_models,
12076 alc268_cfg_tbl);
12077
12078 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
12079 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
12080 "trying auto-probe from BIOS...\n");
12081 board_config = ALC268_AUTO;
12082 }
12083
12084 if (board_config == ALC268_AUTO) {
12085 /* automatic parse from the BIOS config */
12086 err = alc268_parse_auto_config(codec);
12087 if (err < 0) {
12088 alc_free(codec);
12089 return err;
12090 } else if (!err) {
12091 printk(KERN_INFO
12092 "hda_codec: Cannot set up configuration "
12093 "from BIOS. Using base mode...\n");
12094 board_config = ALC268_3ST;
12095 }
12096 }
12097
12098 if (board_config != ALC268_AUTO)
12099 setup_preset(spec, &alc268_presets[board_config]);
12100
Kailang Yanga361d842007-06-05 12:30:55 +020012101 spec->stream_analog_playback = &alc268_pcm_analog_playback;
12102 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010012103 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020012104
Kailang Yanga361d842007-06-05 12:30:55 +020012105 spec->stream_digital_playback = &alc268_pcm_digital_playback;
12106
Takashi Iwai22971e32009-02-10 11:56:44 +010012107 has_beep = 0;
12108 for (i = 0; i < spec->num_mixers; i++) {
12109 if (spec->mixers[i] == alc268_beep_mixer) {
12110 has_beep = 1;
12111 break;
12112 }
12113 }
12114
12115 if (has_beep) {
12116 err = snd_hda_attach_beep_device(codec, 0x1);
12117 if (err < 0) {
12118 alc_free(codec);
12119 return err;
12120 }
12121 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
12122 /* override the amp caps for beep generator */
12123 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012124 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
12125 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
12126 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
12127 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010012128 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012129
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012130 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012131 /* check whether NID 0x07 is valid */
12132 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010012133 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020012134
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012135 /* get type */
12136 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwai67ebcb02008-02-19 15:03:57 +010012137 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012138 spec->adc_nids = alc268_adc_nids_alt;
12139 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012140 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012141 } else {
12142 spec->adc_nids = alc268_adc_nids;
12143 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012144 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020012145 }
Takashi Iwaie1406342008-02-11 18:32:32 +010012146 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai85860c02008-02-19 15:00:15 +010012147 /* set default input source */
12148 for (i = 0; i < spec->num_adc_nids; i++)
12149 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
12150 0, AC_VERB_SET_CONNECT_SEL,
12151 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020012152 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010012153
12154 spec->vmaster_nid = 0x02;
12155
Kailang Yanga361d842007-06-05 12:30:55 +020012156 codec->patch_ops = alc_patch_ops;
12157 if (board_config == ALC268_AUTO)
12158 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020012159
Takashi Iwaidaead532008-11-28 12:55:36 +010012160 codec->proc_widget_hook = print_realtek_coef;
12161
Kailang Yanga361d842007-06-05 12:30:55 +020012162 return 0;
12163}
12164
12165/*
Kailang Yangf6a92242007-12-13 16:52:54 +010012166 * ALC269 channel source setting (2 channel)
12167 */
12168#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
12169
12170#define alc269_dac_nids alc260_dac_nids
12171
12172static hda_nid_t alc269_adc_nids[1] = {
12173 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020012174 0x08,
12175};
12176
Takashi Iwaie01bf502008-08-21 16:25:07 +020012177static hda_nid_t alc269_capsrc_nids[1] = {
12178 0x23,
12179};
12180
12181/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
12182 * not a mux!
12183 */
12184
Kailang Yangf53281e2008-07-18 12:36:43 +020012185static struct hda_input_mux alc269_eeepc_dmic_capture_source = {
12186 .num_items = 2,
12187 .items = {
12188 { "i-Mic", 0x5 },
12189 { "e-Mic", 0x0 },
12190 },
12191};
12192
12193static struct hda_input_mux alc269_eeepc_amic_capture_source = {
12194 .num_items = 2,
12195 .items = {
12196 { "i-Mic", 0x1 },
12197 { "e-Mic", 0x0 },
12198 },
Kailang Yangf6a92242007-12-13 16:52:54 +010012199};
12200
12201#define alc269_modes alc260_modes
12202#define alc269_capture_source alc880_lg_lw_capture_source
12203
12204static struct snd_kcontrol_new alc269_base_mixer[] = {
12205 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12206 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12207 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12208 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12209 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12210 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12211 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12212 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12213 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12214 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12215 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12216 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
12217 { } /* end */
12218};
12219
Kailang Yang60db6b52008-08-26 13:13:00 +020012220static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
12221 /* output mixer control */
12222 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12223 {
12224 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12225 .name = "Master Playback Switch",
12226 .info = snd_hda_mixer_amp_switch_info,
12227 .get = snd_hda_mixer_amp_switch_get,
12228 .put = alc268_acer_master_sw_put,
12229 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12230 },
12231 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12232 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12233 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12234 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12235 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12236 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020012237 { }
12238};
12239
Tony Vroon64154832008-11-06 15:08:49 +000012240static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
12241 /* output mixer control */
12242 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12243 {
12244 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12245 .name = "Master Playback Switch",
12246 .info = snd_hda_mixer_amp_switch_info,
12247 .get = snd_hda_mixer_amp_switch_get,
12248 .put = alc268_acer_master_sw_put,
12249 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12250 },
12251 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12252 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12253 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12254 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12255 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12256 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12257 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
12258 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
12259 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000012260 { }
12261};
12262
Kailang Yangf53281e2008-07-18 12:36:43 +020012263/* bind volumes of both NID 0x0c and 0x0d */
12264static struct hda_bind_ctls alc269_epc_bind_vol = {
12265 .ops = &snd_hda_bind_vol,
12266 .values = {
12267 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
12268 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
12269 0
12270 },
12271};
12272
12273static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
12274 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12275 HDA_BIND_VOL("LineOut Playback Volume", &alc269_epc_bind_vol),
12276 HDA_CODEC_MUTE("LineOut Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12277 { } /* end */
12278};
12279
Kailang Yangf6a92242007-12-13 16:52:54 +010012280/* capture mixer elements */
Kailang Yangf53281e2008-07-18 12:36:43 +020012281static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
12282 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12283 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012284 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12285 { } /* end */
12286};
12287
12288/* FSC amilo */
12289static struct snd_kcontrol_new alc269_fujitsu_mixer[] = {
12290 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12291 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12292 HDA_BIND_VOL("PCM Playback Volume", &alc269_epc_bind_vol),
Kailang Yangf53281e2008-07-18 12:36:43 +020012293 { } /* end */
12294};
12295
Kailang Yang60db6b52008-08-26 13:13:00 +020012296static struct hda_verb alc269_quanta_fl1_verbs[] = {
12297 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12298 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12299 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12300 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12301 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12302 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12303 { }
12304};
12305
Tony Vroon64154832008-11-06 15:08:49 +000012306static struct hda_verb alc269_lifebook_verbs[] = {
12307 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12308 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
12309 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12310 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12311 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12312 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12313 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12314 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12315 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12316 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12317 { }
12318};
12319
Kailang Yang60db6b52008-08-26 13:13:00 +020012320/* toggle speaker-output according to the hp-jack state */
12321static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
12322{
12323 unsigned int present;
12324 unsigned char bits;
12325
12326 present = snd_hda_codec_read(codec, 0x15, 0,
12327 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12328 bits = present ? AMP_IN_MUTE(0) : 0;
12329 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12330 AMP_IN_MUTE(0), bits);
12331 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12332 AMP_IN_MUTE(0), bits);
12333
12334 snd_hda_codec_write(codec, 0x20, 0,
12335 AC_VERB_SET_COEF_INDEX, 0x0c);
12336 snd_hda_codec_write(codec, 0x20, 0,
12337 AC_VERB_SET_PROC_COEF, 0x680);
12338
12339 snd_hda_codec_write(codec, 0x20, 0,
12340 AC_VERB_SET_COEF_INDEX, 0x0c);
12341 snd_hda_codec_write(codec, 0x20, 0,
12342 AC_VERB_SET_PROC_COEF, 0x480);
12343}
12344
Tony Vroon64154832008-11-06 15:08:49 +000012345/* toggle speaker-output according to the hp-jacks state */
12346static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
12347{
12348 unsigned int present;
12349 unsigned char bits;
12350
12351 /* Check laptop headphone socket */
12352 present = snd_hda_codec_read(codec, 0x15, 0,
12353 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12354
12355 /* Check port replicator headphone socket */
12356 present |= snd_hda_codec_read(codec, 0x1a, 0,
12357 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12358
12359 bits = present ? AMP_IN_MUTE(0) : 0;
12360 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12361 AMP_IN_MUTE(0), bits);
12362 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12363 AMP_IN_MUTE(0), bits);
12364
12365 snd_hda_codec_write(codec, 0x20, 0,
12366 AC_VERB_SET_COEF_INDEX, 0x0c);
12367 snd_hda_codec_write(codec, 0x20, 0,
12368 AC_VERB_SET_PROC_COEF, 0x680);
12369
12370 snd_hda_codec_write(codec, 0x20, 0,
12371 AC_VERB_SET_COEF_INDEX, 0x0c);
12372 snd_hda_codec_write(codec, 0x20, 0,
12373 AC_VERB_SET_PROC_COEF, 0x480);
12374}
12375
Kailang Yang60db6b52008-08-26 13:13:00 +020012376static void alc269_quanta_fl1_mic_automute(struct hda_codec *codec)
12377{
12378 unsigned int present;
12379
12380 present = snd_hda_codec_read(codec, 0x18, 0,
12381 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12382 snd_hda_codec_write(codec, 0x23, 0,
12383 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x1);
12384}
12385
Tony Vroon64154832008-11-06 15:08:49 +000012386static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
12387{
12388 unsigned int present_laptop;
12389 unsigned int present_dock;
12390
12391 present_laptop = snd_hda_codec_read(codec, 0x18, 0,
12392 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12393
12394 present_dock = snd_hda_codec_read(codec, 0x1b, 0,
12395 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12396
12397 /* Laptop mic port overrides dock mic port, design decision */
12398 if (present_dock)
12399 snd_hda_codec_write(codec, 0x23, 0,
12400 AC_VERB_SET_CONNECT_SEL, 0x3);
12401 if (present_laptop)
12402 snd_hda_codec_write(codec, 0x23, 0,
12403 AC_VERB_SET_CONNECT_SEL, 0x0);
12404 if (!present_dock && !present_laptop)
12405 snd_hda_codec_write(codec, 0x23, 0,
12406 AC_VERB_SET_CONNECT_SEL, 0x1);
12407}
12408
Kailang Yang60db6b52008-08-26 13:13:00 +020012409static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
12410 unsigned int res)
12411{
12412 if ((res >> 26) == ALC880_HP_EVENT)
12413 alc269_quanta_fl1_speaker_automute(codec);
12414 if ((res >> 26) == ALC880_MIC_EVENT)
12415 alc269_quanta_fl1_mic_automute(codec);
12416}
12417
Tony Vroon64154832008-11-06 15:08:49 +000012418static void alc269_lifebook_unsol_event(struct hda_codec *codec,
12419 unsigned int res)
12420{
12421 if ((res >> 26) == ALC880_HP_EVENT)
12422 alc269_lifebook_speaker_automute(codec);
12423 if ((res >> 26) == ALC880_MIC_EVENT)
12424 alc269_lifebook_mic_autoswitch(codec);
12425}
12426
Kailang Yang60db6b52008-08-26 13:13:00 +020012427static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
12428{
12429 alc269_quanta_fl1_speaker_automute(codec);
12430 alc269_quanta_fl1_mic_automute(codec);
12431}
12432
Tony Vroon64154832008-11-06 15:08:49 +000012433static void alc269_lifebook_init_hook(struct hda_codec *codec)
12434{
12435 alc269_lifebook_speaker_automute(codec);
12436 alc269_lifebook_mic_autoswitch(codec);
12437}
12438
Kailang Yang60db6b52008-08-26 13:13:00 +020012439static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
12440 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12441 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
12442 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12443 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
12444 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12445 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12446 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12447 {}
12448};
12449
12450static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
12451 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12452 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
12453 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12454 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
12455 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12456 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12457 {}
12458};
12459
12460/* toggle speaker-output according to the hp-jack state */
12461static void alc269_speaker_automute(struct hda_codec *codec)
12462{
12463 unsigned int present;
12464 unsigned char bits;
12465
12466 present = snd_hda_codec_read(codec, 0x15, 0,
12467 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12468 bits = present ? AMP_IN_MUTE(0) : 0;
12469 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12470 AMP_IN_MUTE(0), bits);
12471 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12472 AMP_IN_MUTE(0), bits);
12473}
12474
12475static void alc269_eeepc_dmic_automute(struct hda_codec *codec)
12476{
12477 unsigned int present;
12478
12479 present = snd_hda_codec_read(codec, 0x18, 0,
12480 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12481 snd_hda_codec_write(codec, 0x23, 0,
12482 AC_VERB_SET_CONNECT_SEL, (present ? 0 : 5));
12483}
12484
12485static void alc269_eeepc_amic_automute(struct hda_codec *codec)
12486{
12487 unsigned int present;
12488
12489 present = snd_hda_codec_read(codec, 0x18, 0,
12490 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12491 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12492 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
12493 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12494 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
12495}
12496
12497/* unsolicited event for HP jack sensing */
12498static void alc269_eeepc_dmic_unsol_event(struct hda_codec *codec,
12499 unsigned int res)
12500{
12501 if ((res >> 26) == ALC880_HP_EVENT)
12502 alc269_speaker_automute(codec);
12503
12504 if ((res >> 26) == ALC880_MIC_EVENT)
12505 alc269_eeepc_dmic_automute(codec);
12506}
12507
12508static void alc269_eeepc_dmic_inithook(struct hda_codec *codec)
12509{
12510 alc269_speaker_automute(codec);
12511 alc269_eeepc_dmic_automute(codec);
12512}
12513
12514/* unsolicited event for HP jack sensing */
12515static void alc269_eeepc_amic_unsol_event(struct hda_codec *codec,
12516 unsigned int res)
12517{
12518 if ((res >> 26) == ALC880_HP_EVENT)
12519 alc269_speaker_automute(codec);
12520
12521 if ((res >> 26) == ALC880_MIC_EVENT)
12522 alc269_eeepc_amic_automute(codec);
12523}
12524
12525static void alc269_eeepc_amic_inithook(struct hda_codec *codec)
12526{
12527 alc269_speaker_automute(codec);
12528 alc269_eeepc_amic_automute(codec);
12529}
12530
Kailang Yangf6a92242007-12-13 16:52:54 +010012531/*
12532 * generic initialization of ADC, input mixers and output mixers
12533 */
12534static struct hda_verb alc269_init_verbs[] = {
12535 /*
12536 * Unmute ADC0 and set the default input to mic-in
12537 */
Kailang Yang60db6b52008-08-26 13:13:00 +020012538 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010012539
12540 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
12541 * analog-loopback mixer widget
12542 * Note: PASD motherboards uses the Line In 2 as the input for
12543 * front panel mic (mic 2)
12544 */
12545 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
12546 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12547 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12548 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12549 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12550 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12551
12552 /*
12553 * Set up output mixers (0x0c - 0x0e)
12554 */
12555 /* set vol=0 to output mixers */
12556 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12557 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12558
12559 /* set up input amps for analog loopback */
12560 /* Amp Indices: DAC = 0, mixer = 1 */
12561 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12562 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12563 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12564 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12565 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12566 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12567
12568 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12569 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12570 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12571 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12572 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12573 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12574 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12575
12576 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12577 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12578 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12579 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12580 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12581 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12582 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12583
12584 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
12585 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12586
12587 /* FIXME: use matrix-type input source selection */
12588 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
12589 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang60db6b52008-08-26 13:13:00 +020012590 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12591 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangf6a92242007-12-13 16:52:54 +010012592 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12593 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12594
12595 /* set EAPD */
12596 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12597 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12598 { }
12599};
12600
12601/* add playback controls from the parsed DAC table */
12602static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
12603 const struct auto_pin_cfg *cfg)
12604{
12605 hda_nid_t nid;
12606 int err;
12607
12608 spec->multiout.num_dacs = 1; /* only use one dac */
12609 spec->multiout.dac_nids = spec->private_dac_nids;
12610 spec->multiout.dac_nids[0] = 2;
12611
12612 nid = cfg->line_out_pins[0];
12613 if (nid) {
12614 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12615 "Front Playback Volume",
12616 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
12617 if (err < 0)
12618 return err;
12619 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12620 "Front Playback Switch",
12621 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
12622 if (err < 0)
12623 return err;
12624 }
12625
12626 nid = cfg->speaker_pins[0];
12627 if (nid) {
12628 if (!cfg->line_out_pins[0]) {
12629 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12630 "Speaker Playback Volume",
12631 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12632 HDA_OUTPUT));
12633 if (err < 0)
12634 return err;
12635 }
12636 if (nid == 0x16) {
12637 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12638 "Speaker Playback Switch",
12639 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12640 HDA_OUTPUT));
12641 if (err < 0)
12642 return err;
12643 } else {
12644 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12645 "Speaker Playback Switch",
12646 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12647 HDA_OUTPUT));
12648 if (err < 0)
12649 return err;
12650 }
12651 }
12652 nid = cfg->hp_pins[0];
12653 if (nid) {
12654 /* spec->multiout.hp_nid = 2; */
12655 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
12656 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12657 "Headphone Playback Volume",
12658 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12659 HDA_OUTPUT));
12660 if (err < 0)
12661 return err;
12662 }
12663 if (nid == 0x16) {
12664 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12665 "Headphone Playback Switch",
12666 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12667 HDA_OUTPUT));
12668 if (err < 0)
12669 return err;
12670 } else {
12671 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12672 "Headphone Playback Switch",
12673 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12674 HDA_OUTPUT));
12675 if (err < 0)
12676 return err;
12677 }
12678 }
12679 return 0;
12680}
12681
Takashi Iwaiee956e02008-10-31 17:16:31 +010012682static int alc269_auto_create_analog_input_ctls(struct alc_spec *spec,
12683 const struct auto_pin_cfg *cfg)
12684{
12685 int err;
12686
12687 err = alc880_auto_create_analog_input_ctls(spec, cfg);
12688 if (err < 0)
12689 return err;
12690 /* digital-mic input pin is excluded in alc880_auto_create..()
12691 * because it's under 0x18
12692 */
12693 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
12694 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012695 struct hda_input_mux *imux = &spec->private_imux[0];
Takashi Iwaiee956e02008-10-31 17:16:31 +010012696 imux->items[imux->num_items].label = "Int Mic";
12697 imux->items[imux->num_items].index = 0x05;
12698 imux->num_items++;
12699 }
12700 return 0;
12701}
Kailang Yangf6a92242007-12-13 16:52:54 +010012702
12703#ifdef CONFIG_SND_HDA_POWER_SAVE
12704#define alc269_loopbacks alc880_loopbacks
12705#endif
12706
12707/* pcm configuration: identiacal with ALC880 */
12708#define alc269_pcm_analog_playback alc880_pcm_analog_playback
12709#define alc269_pcm_analog_capture alc880_pcm_analog_capture
12710#define alc269_pcm_digital_playback alc880_pcm_digital_playback
12711#define alc269_pcm_digital_capture alc880_pcm_digital_capture
12712
Takashi Iwaif03d3112009-03-05 14:18:16 +010012713static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
12714 .substreams = 1,
12715 .channels_min = 2,
12716 .channels_max = 8,
12717 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
12718 /* NID is set in alc_build_pcms */
12719 .ops = {
12720 .open = alc880_playback_pcm_open,
12721 .prepare = alc880_playback_pcm_prepare,
12722 .cleanup = alc880_playback_pcm_cleanup
12723 },
12724};
12725
12726static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
12727 .substreams = 1,
12728 .channels_min = 2,
12729 .channels_max = 2,
12730 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
12731 /* NID is set in alc_build_pcms */
12732};
12733
Kailang Yangf6a92242007-12-13 16:52:54 +010012734/*
12735 * BIOS auto configuration
12736 */
12737static int alc269_parse_auto_config(struct hda_codec *codec)
12738{
12739 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010012740 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010012741 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
12742
12743 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12744 alc269_ignore);
12745 if (err < 0)
12746 return err;
12747
12748 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
12749 if (err < 0)
12750 return err;
12751 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
12752 if (err < 0)
12753 return err;
12754
12755 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12756
Takashi Iwai0852d7a2009-02-11 11:35:15 +010012757 if (spec->autocfg.dig_outs)
Kailang Yangf6a92242007-12-13 16:52:54 +010012758 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
12759
Takashi Iwai603c4012008-07-30 15:01:44 +020012760 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012761 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010012762
Takashi Iwaid88897e2008-10-31 15:01:37 +010012763 add_verb(spec, alc269_init_verbs);
Kailang Yangf6a92242007-12-13 16:52:54 +010012764 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012765 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie01bf502008-08-21 16:25:07 +020012766 /* set default input source */
12767 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
12768 0, AC_VERB_SET_CONNECT_SEL,
12769 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010012770
12771 err = alc_auto_add_mic_boost(codec);
12772 if (err < 0)
12773 return err;
12774
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012775 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012776 set_capture_mixer(spec);
Kailang Yangf53281e2008-07-18 12:36:43 +020012777
Kailang Yangf6a92242007-12-13 16:52:54 +010012778 return 1;
12779}
12780
12781#define alc269_auto_init_multi_out alc882_auto_init_multi_out
12782#define alc269_auto_init_hp_out alc882_auto_init_hp_out
12783#define alc269_auto_init_analog_input alc882_auto_init_analog_input
12784
12785
12786/* init callback for auto-configuration model -- overriding the default init */
12787static void alc269_auto_init(struct hda_codec *codec)
12788{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012789 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010012790 alc269_auto_init_multi_out(codec);
12791 alc269_auto_init_hp_out(codec);
12792 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012793 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012794 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010012795}
12796
12797/*
12798 * configuration and preset
12799 */
12800static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020012801 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020012802 [ALC269_QUANTA_FL1] = "quanta",
12803 [ALC269_ASUS_EEEPC_P703] = "eeepc-p703",
Takashi Iwai26f5df22008-11-03 17:39:46 +010012804 [ALC269_ASUS_EEEPC_P901] = "eeepc-p901",
Tony Vroon64154832008-11-06 15:08:49 +000012805 [ALC269_FUJITSU] = "fujitsu",
12806 [ALC269_LIFEBOOK] = "lifebook"
Kailang Yangf6a92242007-12-13 16:52:54 +010012807};
12808
12809static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020012810 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020012811 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
12812 ALC269_ASUS_EEEPC_P703),
Kailang Yang622e84c2009-04-21 07:39:04 +020012813 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_ASUS_EEEPC_P703),
12814 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_ASUS_EEEPC_P703),
12815 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_ASUS_EEEPC_P703),
12816 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_ASUS_EEEPC_P703),
12817 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_ASUS_EEEPC_P703),
12818 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_ASUS_EEEPC_P703),
Kailang Yangf53281e2008-07-18 12:36:43 +020012819 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
12820 ALC269_ASUS_EEEPC_P901),
Kailang Yang60db6b52008-08-26 13:13:00 +020012821 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
12822 ALC269_ASUS_EEEPC_P901),
Kailang Yang622e84c2009-04-21 07:39:04 +020012823 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_ASUS_EEEPC_P901),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012824 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
Tony Vroon64154832008-11-06 15:08:49 +000012825 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yangf6a92242007-12-13 16:52:54 +010012826 {}
12827};
12828
12829static struct alc_config_preset alc269_presets[] = {
12830 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012831 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010012832 .init_verbs = { alc269_init_verbs },
12833 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12834 .dac_nids = alc269_dac_nids,
12835 .hp_nid = 0x03,
12836 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12837 .channel_mode = alc269_modes,
12838 .input_mux = &alc269_capture_source,
12839 },
Kailang Yang60db6b52008-08-26 13:13:00 +020012840 [ALC269_QUANTA_FL1] = {
12841 .mixers = { alc269_quanta_fl1_mixer },
12842 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
12843 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12844 .dac_nids = alc269_dac_nids,
12845 .hp_nid = 0x03,
12846 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12847 .channel_mode = alc269_modes,
12848 .input_mux = &alc269_capture_source,
12849 .unsol_event = alc269_quanta_fl1_unsol_event,
12850 .init_hook = alc269_quanta_fl1_init_hook,
12851 },
Kailang Yangf53281e2008-07-18 12:36:43 +020012852 [ALC269_ASUS_EEEPC_P703] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012853 .mixers = { alc269_eeepc_mixer },
12854 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020012855 .init_verbs = { alc269_init_verbs,
12856 alc269_eeepc_amic_init_verbs },
12857 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12858 .dac_nids = alc269_dac_nids,
12859 .hp_nid = 0x03,
12860 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12861 .channel_mode = alc269_modes,
12862 .input_mux = &alc269_eeepc_amic_capture_source,
12863 .unsol_event = alc269_eeepc_amic_unsol_event,
12864 .init_hook = alc269_eeepc_amic_inithook,
12865 },
12866 [ALC269_ASUS_EEEPC_P901] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012867 .mixers = { alc269_eeepc_mixer },
12868 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020012869 .init_verbs = { alc269_init_verbs,
12870 alc269_eeepc_dmic_init_verbs },
12871 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12872 .dac_nids = alc269_dac_nids,
12873 .hp_nid = 0x03,
12874 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12875 .channel_mode = alc269_modes,
12876 .input_mux = &alc269_eeepc_dmic_capture_source,
12877 .unsol_event = alc269_eeepc_dmic_unsol_event,
12878 .init_hook = alc269_eeepc_dmic_inithook,
12879 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010012880 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010012881 .mixers = { alc269_fujitsu_mixer },
Takashi Iwai26f5df22008-11-03 17:39:46 +010012882 .cap_mixer = alc269_epc_capture_mixer,
12883 .init_verbs = { alc269_init_verbs,
12884 alc269_eeepc_dmic_init_verbs },
12885 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12886 .dac_nids = alc269_dac_nids,
12887 .hp_nid = 0x03,
12888 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12889 .channel_mode = alc269_modes,
12890 .input_mux = &alc269_eeepc_dmic_capture_source,
12891 .unsol_event = alc269_eeepc_dmic_unsol_event,
12892 .init_hook = alc269_eeepc_dmic_inithook,
12893 },
Tony Vroon64154832008-11-06 15:08:49 +000012894 [ALC269_LIFEBOOK] = {
12895 .mixers = { alc269_lifebook_mixer },
12896 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
12897 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12898 .dac_nids = alc269_dac_nids,
12899 .hp_nid = 0x03,
12900 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12901 .channel_mode = alc269_modes,
12902 .input_mux = &alc269_capture_source,
12903 .unsol_event = alc269_lifebook_unsol_event,
12904 .init_hook = alc269_lifebook_init_hook,
12905 },
Kailang Yangf6a92242007-12-13 16:52:54 +010012906};
12907
12908static int patch_alc269(struct hda_codec *codec)
12909{
12910 struct alc_spec *spec;
12911 int board_config;
12912 int err;
12913
12914 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
12915 if (spec == NULL)
12916 return -ENOMEM;
12917
12918 codec->spec = spec;
12919
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020012920 alc_fix_pll_init(codec, 0x20, 0x04, 15);
12921
Kailang Yangf6a92242007-12-13 16:52:54 +010012922 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
12923 alc269_models,
12924 alc269_cfg_tbl);
12925
12926 if (board_config < 0) {
12927 printk(KERN_INFO "hda_codec: Unknown model for ALC269, "
12928 "trying auto-probe from BIOS...\n");
12929 board_config = ALC269_AUTO;
12930 }
12931
12932 if (board_config == ALC269_AUTO) {
12933 /* automatic parse from the BIOS config */
12934 err = alc269_parse_auto_config(codec);
12935 if (err < 0) {
12936 alc_free(codec);
12937 return err;
12938 } else if (!err) {
12939 printk(KERN_INFO
12940 "hda_codec: Cannot set up configuration "
12941 "from BIOS. Using base mode...\n");
12942 board_config = ALC269_BASIC;
12943 }
12944 }
12945
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090012946 err = snd_hda_attach_beep_device(codec, 0x1);
12947 if (err < 0) {
12948 alc_free(codec);
12949 return err;
12950 }
12951
Kailang Yangf6a92242007-12-13 16:52:54 +010012952 if (board_config != ALC269_AUTO)
12953 setup_preset(spec, &alc269_presets[board_config]);
12954
Takashi Iwaif03d3112009-03-05 14:18:16 +010012955 if (codec->subsystem_id == 0x17aa3bf8) {
12956 /* Due to a hardware problem on Lenovo Ideadpad, we need to
12957 * fix the sample rate of analog I/O to 44.1kHz
12958 */
12959 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
12960 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
12961 } else {
12962 spec->stream_analog_playback = &alc269_pcm_analog_playback;
12963 spec->stream_analog_capture = &alc269_pcm_analog_capture;
12964 }
Kailang Yangf6a92242007-12-13 16:52:54 +010012965 spec->stream_digital_playback = &alc269_pcm_digital_playback;
12966 spec->stream_digital_capture = &alc269_pcm_digital_capture;
12967
12968 spec->adc_nids = alc269_adc_nids;
12969 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
Takashi Iwaie01bf502008-08-21 16:25:07 +020012970 spec->capsrc_nids = alc269_capsrc_nids;
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012971 if (!spec->cap_mixer)
12972 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010012973 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010012974
12975 codec->patch_ops = alc_patch_ops;
12976 if (board_config == ALC269_AUTO)
12977 spec->init_hook = alc269_auto_init;
12978#ifdef CONFIG_SND_HDA_POWER_SAVE
12979 if (!spec->loopback.amplist)
12980 spec->loopback.amplist = alc269_loopbacks;
12981#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010012982 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010012983
12984 return 0;
12985}
12986
12987/*
Kailang Yangdf694da2005-12-05 19:42:22 +010012988 * ALC861 channel source setting (2/6 channel selection for 3-stack)
12989 */
12990
12991/*
12992 * set the path ways for 2 channel output
12993 * need to set the codec line out and mic 1 pin widgets to inputs
12994 */
12995static struct hda_verb alc861_threestack_ch2_init[] = {
12996 /* set pin widget 1Ah (line in) for input */
12997 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012998 /* set pin widget 18h (mic1/2) for input, for mic also enable
12999 * the vref
13000 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013001 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13002
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013003 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13004#if 0
13005 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13006 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13007#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013008 { } /* end */
13009};
13010/*
13011 * 6ch mode
13012 * need to set the codec line out and mic 1 pin widgets to outputs
13013 */
13014static struct hda_verb alc861_threestack_ch6_init[] = {
13015 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13016 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13017 /* set pin widget 18h (mic1) for output (CLFE)*/
13018 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13019
13020 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013021 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013022
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013023 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13024#if 0
13025 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13026 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13027#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013028 { } /* end */
13029};
13030
13031static struct hda_channel_mode alc861_threestack_modes[2] = {
13032 { 2, alc861_threestack_ch2_init },
13033 { 6, alc861_threestack_ch6_init },
13034};
Takashi Iwai22309c32006-08-09 16:57:28 +020013035/* Set mic1 as input and unmute the mixer */
13036static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
13037 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13038 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13039 { } /* end */
13040};
13041/* Set mic1 as output and mute mixer */
13042static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
13043 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13044 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13045 { } /* end */
13046};
13047
13048static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
13049 { 2, alc861_uniwill_m31_ch2_init },
13050 { 4, alc861_uniwill_m31_ch4_init },
13051};
Kailang Yangdf694da2005-12-05 19:42:22 +010013052
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013053/* Set mic1 and line-in as input and unmute the mixer */
13054static struct hda_verb alc861_asus_ch2_init[] = {
13055 /* set pin widget 1Ah (line in) for input */
13056 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013057 /* set pin widget 18h (mic1/2) for input, for mic also enable
13058 * the vref
13059 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013060 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13061
13062 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13063#if 0
13064 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13065 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13066#endif
13067 { } /* end */
13068};
13069/* Set mic1 nad line-in as output and mute mixer */
13070static struct hda_verb alc861_asus_ch6_init[] = {
13071 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13072 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13073 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13074 /* set pin widget 18h (mic1) for output (CLFE)*/
13075 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13076 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13077 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
13078 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
13079
13080 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13081#if 0
13082 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13083 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13084#endif
13085 { } /* end */
13086};
13087
13088static struct hda_channel_mode alc861_asus_modes[2] = {
13089 { 2, alc861_asus_ch2_init },
13090 { 6, alc861_asus_ch6_init },
13091};
13092
Kailang Yangdf694da2005-12-05 19:42:22 +010013093/* patch-ALC861 */
13094
13095static struct snd_kcontrol_new alc861_base_mixer[] = {
13096 /* output mixer control */
13097 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13098 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13099 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13100 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13101 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13102
13103 /*Input mixer control */
13104 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13105 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13106 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13107 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13108 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13109 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13110 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13111 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13112 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13113 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013114
Kailang Yangdf694da2005-12-05 19:42:22 +010013115 { } /* end */
13116};
13117
13118static struct snd_kcontrol_new alc861_3ST_mixer[] = {
13119 /* output mixer control */
13120 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13121 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13122 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13123 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13124 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13125
13126 /* Input mixer control */
13127 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13128 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13129 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13130 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13131 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13132 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13133 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13134 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13135 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13136 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013137
Kailang Yangdf694da2005-12-05 19:42:22 +010013138 {
13139 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13140 .name = "Channel Mode",
13141 .info = alc_ch_mode_info,
13142 .get = alc_ch_mode_get,
13143 .put = alc_ch_mode_put,
13144 .private_value = ARRAY_SIZE(alc861_threestack_modes),
13145 },
13146 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013147};
13148
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013149static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013150 /* output mixer control */
13151 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13152 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13153 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020013154
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013155 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013156};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013157
Takashi Iwai22309c32006-08-09 16:57:28 +020013158static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
13159 /* output mixer control */
13160 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13161 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13162 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13163 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13164 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13165
13166 /* Input mixer control */
13167 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13168 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13169 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13170 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13171 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13172 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13173 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13174 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13175 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13176 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013177
Takashi Iwai22309c32006-08-09 16:57:28 +020013178 {
13179 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13180 .name = "Channel Mode",
13181 .info = alc_ch_mode_info,
13182 .get = alc_ch_mode_get,
13183 .put = alc_ch_mode_put,
13184 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
13185 },
13186 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013187};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013188
13189static struct snd_kcontrol_new alc861_asus_mixer[] = {
13190 /* output mixer control */
13191 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13192 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13193 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13194 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13195 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13196
13197 /* Input mixer control */
13198 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13199 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13200 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13201 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13202 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13203 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13204 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13205 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13206 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013207 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
13208
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013209 {
13210 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13211 .name = "Channel Mode",
13212 .info = alc_ch_mode_info,
13213 .get = alc_ch_mode_get,
13214 .put = alc_ch_mode_put,
13215 .private_value = ARRAY_SIZE(alc861_asus_modes),
13216 },
13217 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013218};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013219
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013220/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013221static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013222 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13223 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013224 { }
13225};
13226
Kailang Yangdf694da2005-12-05 19:42:22 +010013227/*
13228 * generic initialization of ADC, input mixers and output mixers
13229 */
13230static struct hda_verb alc861_base_init_verbs[] = {
13231 /*
13232 * Unmute ADC0 and set the default input to mic-in
13233 */
13234 /* port-A for surround (rear panel) */
13235 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13236 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
13237 /* port-B for mic-in (rear panel) with vref */
13238 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13239 /* port-C for line-in (rear panel) */
13240 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13241 /* port-D for Front */
13242 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13243 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13244 /* port-E for HP out (front panel) */
13245 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13246 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013247 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013248 /* port-F for mic-in (front panel) with vref */
13249 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13250 /* port-G for CLFE (rear panel) */
13251 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13252 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13253 /* port-H for side (rear panel) */
13254 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13255 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
13256 /* CD-in */
13257 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13258 /* route front mic to ADC1*/
13259 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13260 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013261
Kailang Yangdf694da2005-12-05 19:42:22 +010013262 /* Unmute DAC0~3 & spdif out*/
13263 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13264 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13265 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13266 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13267 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013268
Kailang Yangdf694da2005-12-05 19:42:22 +010013269 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13270 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13271 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13272 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13273 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013274
Kailang Yangdf694da2005-12-05 19:42:22 +010013275 /* Unmute Stereo Mixer 15 */
13276 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13277 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13278 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013279 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013280
13281 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13282 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13283 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13284 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13285 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13286 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13287 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13288 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013289 /* hp used DAC 3 (Front) */
13290 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013291 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13292
13293 { }
13294};
13295
13296static struct hda_verb alc861_threestack_init_verbs[] = {
13297 /*
13298 * Unmute ADC0 and set the default input to mic-in
13299 */
13300 /* port-A for surround (rear panel) */
13301 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13302 /* port-B for mic-in (rear panel) with vref */
13303 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13304 /* port-C for line-in (rear panel) */
13305 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13306 /* port-D for Front */
13307 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13308 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13309 /* port-E for HP out (front panel) */
13310 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13311 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013312 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013313 /* port-F for mic-in (front panel) with vref */
13314 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13315 /* port-G for CLFE (rear panel) */
13316 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13317 /* port-H for side (rear panel) */
13318 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13319 /* CD-in */
13320 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13321 /* route front mic to ADC1*/
13322 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13323 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13324 /* Unmute DAC0~3 & spdif out*/
13325 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13326 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13327 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13328 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13329 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013330
Kailang Yangdf694da2005-12-05 19:42:22 +010013331 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13332 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13333 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13334 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13335 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013336
Kailang Yangdf694da2005-12-05 19:42:22 +010013337 /* Unmute Stereo Mixer 15 */
13338 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13339 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13340 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013341 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013342
13343 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13344 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13345 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13346 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13347 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13348 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13349 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13350 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013351 /* hp used DAC 3 (Front) */
13352 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013353 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13354 { }
13355};
Takashi Iwai22309c32006-08-09 16:57:28 +020013356
13357static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
13358 /*
13359 * Unmute ADC0 and set the default input to mic-in
13360 */
13361 /* port-A for surround (rear panel) */
13362 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13363 /* port-B for mic-in (rear panel) with vref */
13364 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13365 /* port-C for line-in (rear panel) */
13366 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13367 /* port-D for Front */
13368 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13369 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13370 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013371 /* this has to be set to VREF80 */
13372 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013373 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013374 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013375 /* port-F for mic-in (front panel) with vref */
13376 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13377 /* port-G for CLFE (rear panel) */
13378 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13379 /* port-H for side (rear panel) */
13380 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13381 /* CD-in */
13382 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13383 /* route front mic to ADC1*/
13384 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13385 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13386 /* Unmute DAC0~3 & spdif out*/
13387 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13388 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13389 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13390 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13391 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013392
Takashi Iwai22309c32006-08-09 16:57:28 +020013393 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13394 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13395 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13396 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13397 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013398
Takashi Iwai22309c32006-08-09 16:57:28 +020013399 /* Unmute Stereo Mixer 15 */
13400 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13401 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13402 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013403 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020013404
13405 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13406 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13407 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13408 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13409 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13410 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13411 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13412 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013413 /* hp used DAC 3 (Front) */
13414 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020013415 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13416 { }
13417};
13418
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013419static struct hda_verb alc861_asus_init_verbs[] = {
13420 /*
13421 * Unmute ADC0 and set the default input to mic-in
13422 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013423 /* port-A for surround (rear panel)
13424 * according to codec#0 this is the HP jack
13425 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013426 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
13427 /* route front PCM to HP */
13428 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
13429 /* port-B for mic-in (rear panel) with vref */
13430 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13431 /* port-C for line-in (rear panel) */
13432 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13433 /* port-D for Front */
13434 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13435 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13436 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013437 /* this has to be set to VREF80 */
13438 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013439 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013440 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013441 /* port-F for mic-in (front panel) with vref */
13442 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13443 /* port-G for CLFE (rear panel) */
13444 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13445 /* port-H for side (rear panel) */
13446 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13447 /* CD-in */
13448 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13449 /* route front mic to ADC1*/
13450 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13451 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13452 /* Unmute DAC0~3 & spdif out*/
13453 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13454 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13455 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13456 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13457 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13458 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13459 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13460 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13461 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13462 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013463
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013464 /* Unmute Stereo Mixer 15 */
13465 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13466 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13467 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013468 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013469
13470 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13471 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13472 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13473 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13474 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13475 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13476 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13477 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013478 /* hp used DAC 3 (Front) */
13479 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013480 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13481 { }
13482};
13483
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013484/* additional init verbs for ASUS laptops */
13485static struct hda_verb alc861_asus_laptop_init_verbs[] = {
13486 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
13487 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
13488 { }
13489};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013490
Kailang Yangdf694da2005-12-05 19:42:22 +010013491/*
13492 * generic initialization of ADC, input mixers and output mixers
13493 */
13494static struct hda_verb alc861_auto_init_verbs[] = {
13495 /*
13496 * Unmute ADC0 and set the default input to mic-in
13497 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013498 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010013499 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013500
Kailang Yangdf694da2005-12-05 19:42:22 +010013501 /* Unmute DAC0~3 & spdif out*/
13502 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13503 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13504 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13505 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13506 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013507
Kailang Yangdf694da2005-12-05 19:42:22 +010013508 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13509 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13510 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13511 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13512 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013513
Kailang Yangdf694da2005-12-05 19:42:22 +010013514 /* Unmute Stereo Mixer 15 */
13515 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13516 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13517 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13518 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
13519
13520 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13521 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13522 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13523 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13524 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13525 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13526 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13527 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13528
13529 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13530 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013531 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13532 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013533 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13534 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013535 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13536 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013537
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013538 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013539
13540 { }
13541};
13542
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013543static struct hda_verb alc861_toshiba_init_verbs[] = {
13544 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013545
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013546 { }
13547};
13548
13549/* toggle speaker-output according to the hp-jack state */
13550static void alc861_toshiba_automute(struct hda_codec *codec)
13551{
13552 unsigned int present;
13553
13554 present = snd_hda_codec_read(codec, 0x0f, 0,
13555 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013556 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
13557 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
13558 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
13559 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013560}
13561
13562static void alc861_toshiba_unsol_event(struct hda_codec *codec,
13563 unsigned int res)
13564{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013565 if ((res >> 26) == ALC880_HP_EVENT)
13566 alc861_toshiba_automute(codec);
13567}
13568
Kailang Yangdf694da2005-12-05 19:42:22 +010013569/* pcm configuration: identiacal with ALC880 */
13570#define alc861_pcm_analog_playback alc880_pcm_analog_playback
13571#define alc861_pcm_analog_capture alc880_pcm_analog_capture
13572#define alc861_pcm_digital_playback alc880_pcm_digital_playback
13573#define alc861_pcm_digital_capture alc880_pcm_digital_capture
13574
13575
13576#define ALC861_DIGOUT_NID 0x07
13577
13578static struct hda_channel_mode alc861_8ch_modes[1] = {
13579 { 8, NULL }
13580};
13581
13582static hda_nid_t alc861_dac_nids[4] = {
13583 /* front, surround, clfe, side */
13584 0x03, 0x06, 0x05, 0x04
13585};
13586
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013587static hda_nid_t alc660_dac_nids[3] = {
13588 /* front, clfe, surround */
13589 0x03, 0x05, 0x06
13590};
13591
Kailang Yangdf694da2005-12-05 19:42:22 +010013592static hda_nid_t alc861_adc_nids[1] = {
13593 /* ADC0-2 */
13594 0x08,
13595};
13596
13597static struct hda_input_mux alc861_capture_source = {
13598 .num_items = 5,
13599 .items = {
13600 { "Mic", 0x0 },
13601 { "Front Mic", 0x3 },
13602 { "Line", 0x1 },
13603 { "CD", 0x4 },
13604 { "Mixer", 0x5 },
13605 },
13606};
13607
13608/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013609static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
13610 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010013611{
13612 int i;
13613 hda_nid_t nid;
13614
13615 spec->multiout.dac_nids = spec->private_dac_nids;
13616 for (i = 0; i < cfg->line_outs; i++) {
13617 nid = cfg->line_out_pins[i];
13618 if (nid) {
13619 if (i >= ARRAY_SIZE(alc861_dac_nids))
13620 continue;
13621 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
13622 }
13623 }
13624 spec->multiout.num_dacs = cfg->line_outs;
13625 return 0;
13626}
13627
13628/* add playback controls from the parsed DAC table */
13629static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
13630 const struct auto_pin_cfg *cfg)
13631{
13632 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013633 static const char *chname[4] = {
13634 "Front", "Surround", NULL /*CLFE*/, "Side"
13635 };
Kailang Yangdf694da2005-12-05 19:42:22 +010013636 hda_nid_t nid;
13637 int i, idx, err;
13638
13639 for (i = 0; i < cfg->line_outs; i++) {
13640 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013641 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010013642 continue;
13643 if (nid == 0x05) {
13644 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013645 err = add_control(spec, ALC_CTL_BIND_MUTE,
13646 "Center Playback Switch",
13647 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
13648 HDA_OUTPUT));
13649 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013650 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013651 err = add_control(spec, ALC_CTL_BIND_MUTE,
13652 "LFE Playback Switch",
13653 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13654 HDA_OUTPUT));
13655 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013656 return err;
13657 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013658 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
13659 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +010013660 if (nid == alc861_dac_nids[idx])
13661 break;
13662 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013663 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
13664 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13665 HDA_OUTPUT));
13666 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013667 return err;
13668 }
13669 }
13670 return 0;
13671}
13672
13673static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
13674{
13675 int err;
13676 hda_nid_t nid;
13677
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013678 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010013679 return 0;
13680
13681 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
13682 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013683 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13684 "Headphone Playback Switch",
13685 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
13686 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013687 return err;
13688 spec->multiout.hp_nid = nid;
13689 }
13690 return 0;
13691}
13692
13693/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013694static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
13695 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010013696{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013697 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010013698 int i, err, idx, idx1;
13699
13700 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013701 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010013702 case 0x0c:
13703 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013704 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013705 break;
13706 case 0x0f:
13707 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013708 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013709 break;
13710 case 0x0d:
13711 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013712 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013713 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013714 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010013715 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013716 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013717 break;
13718 case 0x11:
13719 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013720 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010013721 break;
13722 default:
13723 continue;
13724 }
13725
Takashi Iwai4a471b72005-12-07 13:56:29 +010013726 err = new_analog_input(spec, cfg->input_pins[i],
13727 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010013728 if (err < 0)
13729 return err;
13730
Takashi Iwai4a471b72005-12-07 13:56:29 +010013731 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010013732 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013733 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010013734 }
13735 return 0;
13736}
13737
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013738static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
13739 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +010013740 int pin_type, int dac_idx)
13741{
Jacek Luczak564c5be2008-05-03 18:41:23 +020013742 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
13743 pin_type);
13744 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13745 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +010013746}
13747
13748static void alc861_auto_init_multi_out(struct hda_codec *codec)
13749{
13750 struct alc_spec *spec = codec->spec;
13751 int i;
13752
13753 for (i = 0; i < spec->autocfg.line_outs; i++) {
13754 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013755 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010013756 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013757 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013758 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010013759 }
13760}
13761
13762static void alc861_auto_init_hp_out(struct hda_codec *codec)
13763{
13764 struct alc_spec *spec = codec->spec;
13765 hda_nid_t pin;
13766
Takashi Iwaieb06ed82006-09-20 17:10:27 +020013767 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010013768 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013769 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
13770 spec->multiout.dac_nids[0]);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013771 pin = spec->autocfg.speaker_pins[0];
13772 if (pin)
13773 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010013774}
13775
13776static void alc861_auto_init_analog_input(struct hda_codec *codec)
13777{
13778 struct alc_spec *spec = codec->spec;
13779 int i;
13780
13781 for (i = 0; i < AUTO_PIN_LAST; i++) {
13782 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai23f0c042009-02-26 13:03:58 +010013783 if (nid >= 0x0c && nid <= 0x11)
13784 alc_set_input_pin(codec, nid, i);
Kailang Yangdf694da2005-12-05 19:42:22 +010013785 }
13786}
13787
13788/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013789/* return 1 if successful, 0 if the proper config is not found,
13790 * or a negative error code
13791 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013792static int alc861_parse_auto_config(struct hda_codec *codec)
13793{
13794 struct alc_spec *spec = codec->spec;
13795 int err;
13796 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
13797
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013798 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13799 alc861_ignore);
13800 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013801 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013802 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010013803 return 0; /* can't find valid BIOS pin config */
13804
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013805 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
13806 if (err < 0)
13807 return err;
13808 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
13809 if (err < 0)
13810 return err;
13811 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
13812 if (err < 0)
13813 return err;
13814 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
13815 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013816 return err;
13817
13818 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13819
Takashi Iwai0852d7a2009-02-11 11:35:15 +010013820 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010013821 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
13822
Takashi Iwai603c4012008-07-30 15:01:44 +020013823 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013824 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010013825
Takashi Iwaid88897e2008-10-31 15:01:37 +010013826 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010013827
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020013828 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013829 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010013830
13831 spec->adc_nids = alc861_adc_nids;
13832 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013833 set_capture_mixer(spec);
Kailang Yangdf694da2005-12-05 19:42:22 +010013834
Takashi Iwai4a79ba32009-04-22 16:31:35 +020013835 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b);
13836
Kailang Yangdf694da2005-12-05 19:42:22 +010013837 return 1;
13838}
13839
Takashi Iwaiae6b8132006-03-03 16:47:17 +010013840/* additional initialization for auto-configuration model */
13841static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010013842{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013843 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010013844 alc861_auto_init_multi_out(codec);
13845 alc861_auto_init_hp_out(codec);
13846 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013847 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013848 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010013849}
13850
Takashi Iwaicb53c622007-08-10 17:21:45 +020013851#ifdef CONFIG_SND_HDA_POWER_SAVE
13852static struct hda_amp_list alc861_loopbacks[] = {
13853 { 0x15, HDA_INPUT, 0 },
13854 { 0x15, HDA_INPUT, 1 },
13855 { 0x15, HDA_INPUT, 2 },
13856 { 0x15, HDA_INPUT, 3 },
13857 { } /* end */
13858};
13859#endif
13860
Kailang Yangdf694da2005-12-05 19:42:22 +010013861
13862/*
13863 * configuration and preset
13864 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013865static const char *alc861_models[ALC861_MODEL_LAST] = {
13866 [ALC861_3ST] = "3stack",
13867 [ALC660_3ST] = "3stack-660",
13868 [ALC861_3ST_DIG] = "3stack-dig",
13869 [ALC861_6ST_DIG] = "6stack-dig",
13870 [ALC861_UNIWILL_M31] = "uniwill-m31",
13871 [ALC861_TOSHIBA] = "toshiba",
13872 [ALC861_ASUS] = "asus",
13873 [ALC861_ASUS_LAPTOP] = "asus-laptop",
13874 [ALC861_AUTO] = "auto",
13875};
13876
13877static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010013878 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013879 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
13880 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
13881 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013882 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020013883 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010013884 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020013885 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
13886 * Any other models that need this preset?
13887 */
13888 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020013889 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
13890 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013891 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
13892 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
13893 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
13894 /* FIXME: the below seems conflict */
13895 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
13896 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
13897 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010013898 {}
13899};
13900
13901static struct alc_config_preset alc861_presets[] = {
13902 [ALC861_3ST] = {
13903 .mixers = { alc861_3ST_mixer },
13904 .init_verbs = { alc861_threestack_init_verbs },
13905 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13906 .dac_nids = alc861_dac_nids,
13907 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13908 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020013909 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010013910 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13911 .adc_nids = alc861_adc_nids,
13912 .input_mux = &alc861_capture_source,
13913 },
13914 [ALC861_3ST_DIG] = {
13915 .mixers = { alc861_base_mixer },
13916 .init_verbs = { alc861_threestack_init_verbs },
13917 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13918 .dac_nids = alc861_dac_nids,
13919 .dig_out_nid = ALC861_DIGOUT_NID,
13920 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13921 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020013922 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010013923 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13924 .adc_nids = alc861_adc_nids,
13925 .input_mux = &alc861_capture_source,
13926 },
13927 [ALC861_6ST_DIG] = {
13928 .mixers = { alc861_base_mixer },
13929 .init_verbs = { alc861_base_init_verbs },
13930 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13931 .dac_nids = alc861_dac_nids,
13932 .dig_out_nid = ALC861_DIGOUT_NID,
13933 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
13934 .channel_mode = alc861_8ch_modes,
13935 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13936 .adc_nids = alc861_adc_nids,
13937 .input_mux = &alc861_capture_source,
13938 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013939 [ALC660_3ST] = {
13940 .mixers = { alc861_3ST_mixer },
13941 .init_verbs = { alc861_threestack_init_verbs },
13942 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
13943 .dac_nids = alc660_dac_nids,
13944 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13945 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020013946 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013947 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13948 .adc_nids = alc861_adc_nids,
13949 .input_mux = &alc861_capture_source,
13950 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013951 [ALC861_UNIWILL_M31] = {
13952 .mixers = { alc861_uniwill_m31_mixer },
13953 .init_verbs = { alc861_uniwill_m31_init_verbs },
13954 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13955 .dac_nids = alc861_dac_nids,
13956 .dig_out_nid = ALC861_DIGOUT_NID,
13957 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
13958 .channel_mode = alc861_uniwill_m31_modes,
13959 .need_dac_fix = 1,
13960 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13961 .adc_nids = alc861_adc_nids,
13962 .input_mux = &alc861_capture_source,
13963 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013964 [ALC861_TOSHIBA] = {
13965 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013966 .init_verbs = { alc861_base_init_verbs,
13967 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013968 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13969 .dac_nids = alc861_dac_nids,
13970 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
13971 .channel_mode = alc883_3ST_2ch_modes,
13972 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13973 .adc_nids = alc861_adc_nids,
13974 .input_mux = &alc861_capture_source,
13975 .unsol_event = alc861_toshiba_unsol_event,
13976 .init_hook = alc861_toshiba_automute,
13977 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013978 [ALC861_ASUS] = {
13979 .mixers = { alc861_asus_mixer },
13980 .init_verbs = { alc861_asus_init_verbs },
13981 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13982 .dac_nids = alc861_dac_nids,
13983 .dig_out_nid = ALC861_DIGOUT_NID,
13984 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
13985 .channel_mode = alc861_asus_modes,
13986 .need_dac_fix = 1,
13987 .hp_nid = 0x06,
13988 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13989 .adc_nids = alc861_adc_nids,
13990 .input_mux = &alc861_capture_source,
13991 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013992 [ALC861_ASUS_LAPTOP] = {
13993 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
13994 .init_verbs = { alc861_asus_init_verbs,
13995 alc861_asus_laptop_init_verbs },
13996 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13997 .dac_nids = alc861_dac_nids,
13998 .dig_out_nid = ALC861_DIGOUT_NID,
13999 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14000 .channel_mode = alc883_3ST_2ch_modes,
14001 .need_dac_fix = 1,
14002 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14003 .adc_nids = alc861_adc_nids,
14004 .input_mux = &alc861_capture_source,
14005 },
14006};
Kailang Yangdf694da2005-12-05 19:42:22 +010014007
14008
14009static int patch_alc861(struct hda_codec *codec)
14010{
14011 struct alc_spec *spec;
14012 int board_config;
14013 int err;
14014
Robert P. J. Daydc041e02006-12-19 14:44:15 +010014015 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010014016 if (spec == NULL)
14017 return -ENOMEM;
14018
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014019 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014020
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014021 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
14022 alc861_models,
14023 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014024
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014025 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014026 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
14027 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010014028 board_config = ALC861_AUTO;
14029 }
14030
14031 if (board_config == ALC861_AUTO) {
14032 /* automatic parse from the BIOS config */
14033 err = alc861_parse_auto_config(codec);
14034 if (err < 0) {
14035 alc_free(codec);
14036 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014037 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014038 printk(KERN_INFO
14039 "hda_codec: Cannot set up configuration "
14040 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010014041 board_config = ALC861_3ST_DIG;
14042 }
14043 }
14044
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014045 err = snd_hda_attach_beep_device(codec, 0x23);
14046 if (err < 0) {
14047 alc_free(codec);
14048 return err;
14049 }
14050
Kailang Yangdf694da2005-12-05 19:42:22 +010014051 if (board_config != ALC861_AUTO)
14052 setup_preset(spec, &alc861_presets[board_config]);
14053
Kailang Yangdf694da2005-12-05 19:42:22 +010014054 spec->stream_analog_playback = &alc861_pcm_analog_playback;
14055 spec->stream_analog_capture = &alc861_pcm_analog_capture;
14056
Kailang Yangdf694da2005-12-05 19:42:22 +010014057 spec->stream_digital_playback = &alc861_pcm_digital_playback;
14058 spec->stream_digital_capture = &alc861_pcm_digital_capture;
14059
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014060 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
14061
Takashi Iwai2134ea42008-01-10 16:53:55 +010014062 spec->vmaster_nid = 0x03;
14063
Kailang Yangdf694da2005-12-05 19:42:22 +010014064 codec->patch_ops = alc_patch_ops;
14065 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014066 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014067#ifdef CONFIG_SND_HDA_POWER_SAVE
14068 if (!spec->loopback.amplist)
14069 spec->loopback.amplist = alc861_loopbacks;
14070#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010014071 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020014072
Kailang Yangdf694da2005-12-05 19:42:22 +010014073 return 0;
14074}
14075
14076/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014077 * ALC861-VD support
14078 *
14079 * Based on ALC882
14080 *
14081 * In addition, an independent DAC
14082 */
14083#define ALC861VD_DIGOUT_NID 0x06
14084
14085static hda_nid_t alc861vd_dac_nids[4] = {
14086 /* front, surr, clfe, side surr */
14087 0x02, 0x03, 0x04, 0x05
14088};
14089
14090/* dac_nids for ALC660vd are in a different order - according to
14091 * Realtek's driver.
14092 * This should probably tesult in a different mixer for 6stack models
14093 * of ALC660vd codecs, but for now there is only 3stack mixer
14094 * - and it is the same as in 861vd.
14095 * adc_nids in ALC660vd are (is) the same as in 861vd
14096 */
14097static hda_nid_t alc660vd_dac_nids[3] = {
14098 /* front, rear, clfe, rear_surr */
14099 0x02, 0x04, 0x03
14100};
14101
14102static hda_nid_t alc861vd_adc_nids[1] = {
14103 /* ADC0 */
14104 0x09,
14105};
14106
Takashi Iwaie1406342008-02-11 18:32:32 +010014107static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
14108
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014109/* input MUX */
14110/* FIXME: should be a matrix-type input source selection */
14111static struct hda_input_mux alc861vd_capture_source = {
14112 .num_items = 4,
14113 .items = {
14114 { "Mic", 0x0 },
14115 { "Front Mic", 0x1 },
14116 { "Line", 0x2 },
14117 { "CD", 0x4 },
14118 },
14119};
14120
Kailang Yang272a5272007-05-14 11:00:38 +020014121static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010014122 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020014123 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010014124 { "Ext Mic", 0x0 },
14125 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020014126 },
14127};
14128
Kailang Yangd1a991a2007-08-15 16:21:59 +020014129static struct hda_input_mux alc861vd_hp_capture_source = {
14130 .num_items = 2,
14131 .items = {
14132 { "Front Mic", 0x0 },
14133 { "ATAPI Mic", 0x1 },
14134 },
14135};
14136
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014137/*
14138 * 2ch mode
14139 */
14140static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
14141 { 2, NULL }
14142};
14143
14144/*
14145 * 6ch mode
14146 */
14147static struct hda_verb alc861vd_6stack_ch6_init[] = {
14148 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14149 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14150 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14151 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14152 { } /* end */
14153};
14154
14155/*
14156 * 8ch mode
14157 */
14158static struct hda_verb alc861vd_6stack_ch8_init[] = {
14159 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14160 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14161 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14162 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14163 { } /* end */
14164};
14165
14166static struct hda_channel_mode alc861vd_6stack_modes[2] = {
14167 { 6, alc861vd_6stack_ch6_init },
14168 { 8, alc861vd_6stack_ch8_init },
14169};
14170
14171static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
14172 {
14173 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14174 .name = "Channel Mode",
14175 .info = alc_ch_mode_info,
14176 .get = alc_ch_mode_get,
14177 .put = alc_ch_mode_put,
14178 },
14179 { } /* end */
14180};
14181
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014182/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
14183 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
14184 */
14185static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
14186 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14187 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14188
14189 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14190 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
14191
14192 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
14193 HDA_OUTPUT),
14194 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
14195 HDA_OUTPUT),
14196 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
14197 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
14198
14199 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
14200 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
14201
14202 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14203
14204 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14205 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14206 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14207
14208 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14209 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14210 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14211
14212 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14213 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14214
14215 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14216 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14217
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014218 { } /* end */
14219};
14220
14221static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
14222 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14223 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14224
14225 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14226
14227 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14228 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14229 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14230
14231 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14232 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14233 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14234
14235 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14236 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14237
14238 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14239 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14240
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014241 { } /* end */
14242};
14243
Kailang Yangbdd148a2007-05-08 15:19:08 +020014244static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
14245 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14246 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
14247 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14248
14249 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14250
14251 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14252 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14253 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14254
14255 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14256 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14257 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14258
14259 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14260 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14261
14262 { } /* end */
14263};
14264
Tobin Davisb419f342008-03-07 11:57:51 +010014265/* Pin assignment: Speaker=0x14, HP = 0x15,
14266 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020014267 */
14268static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010014269 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14270 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014271 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14272 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010014273 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
14274 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14275 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14276 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
14277 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14278 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014279 { } /* end */
14280};
14281
Kailang Yangd1a991a2007-08-15 16:21:59 +020014282/* Pin assignment: Speaker=0x14, Line-out = 0x15,
14283 * Front Mic=0x18, ATAPI Mic = 0x19,
14284 */
14285static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
14286 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14287 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14288 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14289 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
14290 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14291 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14292 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14293 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020014294
Kailang Yangd1a991a2007-08-15 16:21:59 +020014295 { } /* end */
14296};
14297
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014298/*
14299 * generic initialization of ADC, input mixers and output mixers
14300 */
14301static struct hda_verb alc861vd_volume_init_verbs[] = {
14302 /*
14303 * Unmute ADC0 and set the default input to mic-in
14304 */
14305 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14306 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14307
14308 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
14309 * the analog-loopback mixer widget
14310 */
14311 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020014312 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14313 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14314 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14315 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14316 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014317
14318 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020014319 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14320 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14321 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014322 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014323
14324 /*
14325 * Set up output mixers (0x02 - 0x05)
14326 */
14327 /* set vol=0 to output mixers */
14328 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14329 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14330 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14331 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14332
14333 /* set up input amps for analog loopback */
14334 /* Amp Indices: DAC = 0, mixer = 1 */
14335 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14336 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14337 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14338 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14339 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14340 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14341 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14342 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14343
14344 { }
14345};
14346
14347/*
14348 * 3-stack pin configuration:
14349 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
14350 */
14351static struct hda_verb alc861vd_3stack_init_verbs[] = {
14352 /*
14353 * Set pin mode and muting
14354 */
14355 /* set front pin widgets 0x14 for output */
14356 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14357 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14358 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14359
14360 /* Mic (rear) pin: input vref at 80% */
14361 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14362 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14363 /* Front Mic pin: input vref at 80% */
14364 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14365 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14366 /* Line In pin: input */
14367 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14368 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14369 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14370 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14371 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14372 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14373 /* CD pin widget for input */
14374 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14375
14376 { }
14377};
14378
14379/*
14380 * 6-stack pin configuration:
14381 */
14382static struct hda_verb alc861vd_6stack_init_verbs[] = {
14383 /*
14384 * Set pin mode and muting
14385 */
14386 /* set front pin widgets 0x14 for output */
14387 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14388 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14389 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14390
14391 /* Rear Pin: output 1 (0x0d) */
14392 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14393 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14394 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14395 /* CLFE Pin: output 2 (0x0e) */
14396 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14397 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14398 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
14399 /* Side Pin: output 3 (0x0f) */
14400 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14401 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14402 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
14403
14404 /* Mic (rear) pin: input vref at 80% */
14405 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14406 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14407 /* Front Mic pin: input vref at 80% */
14408 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14409 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14410 /* Line In pin: input */
14411 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14412 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14413 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14414 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14415 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14416 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14417 /* CD pin widget for input */
14418 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14419
14420 { }
14421};
14422
Kailang Yangbdd148a2007-05-08 15:19:08 +020014423static struct hda_verb alc861vd_eapd_verbs[] = {
14424 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14425 { }
14426};
14427
Kailang Yangf9423e72008-05-27 12:32:25 +020014428static struct hda_verb alc660vd_eapd_verbs[] = {
14429 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14430 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
14431 { }
14432};
14433
Kailang Yangbdd148a2007-05-08 15:19:08 +020014434static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
14435 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14436 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14437 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
14438 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020014439 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020014440 {}
14441};
14442
Kailang Yangbdd148a2007-05-08 15:19:08 +020014443static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
14444{
14445 unsigned int present;
14446 unsigned char bits;
14447
14448 present = snd_hda_codec_read(codec, 0x18, 0,
14449 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014450 bits = present ? HDA_AMP_MUTE : 0;
14451 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
14452 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014453}
14454
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014455static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020014456{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014457 struct alc_spec *spec = codec->spec;
14458
14459 spec->autocfg.hp_pins[0] = 0x1b;
14460 spec->autocfg.speaker_pins[0] = 0x14;
14461 alc_automute_amp(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014462 alc861vd_lenovo_mic_automute(codec);
14463}
14464
14465static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
14466 unsigned int res)
14467{
14468 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020014469 case ALC880_MIC_EVENT:
14470 alc861vd_lenovo_mic_automute(codec);
14471 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014472 default:
14473 alc_automute_amp_unsol_event(codec, res);
14474 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020014475 }
14476}
14477
Kailang Yang272a5272007-05-14 11:00:38 +020014478static struct hda_verb alc861vd_dallas_verbs[] = {
14479 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14480 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14481 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14482 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14483
14484 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14485 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14486 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14487 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14488 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14489 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14490 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14491 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014492
Kailang Yang272a5272007-05-14 11:00:38 +020014493 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14494 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14495 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14496 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14497 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14498 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14499 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14500 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14501
14502 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14503 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14504 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14505 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14506 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14507 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14508 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14509 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14510
14511 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14512 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14513 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14514 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
14515
14516 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014517 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020014518 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14519
14520 { } /* end */
14521};
14522
14523/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014524static void alc861vd_dallas_init_hook(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020014525{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014526 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020014527
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014528 spec->autocfg.hp_pins[0] = 0x15;
14529 spec->autocfg.speaker_pins[0] = 0x14;
14530 alc_automute_amp(codec);
Kailang Yang272a5272007-05-14 11:00:38 +020014531}
14532
Takashi Iwaicb53c622007-08-10 17:21:45 +020014533#ifdef CONFIG_SND_HDA_POWER_SAVE
14534#define alc861vd_loopbacks alc880_loopbacks
14535#endif
14536
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014537/* pcm configuration: identiacal with ALC880 */
14538#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
14539#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
14540#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
14541#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
14542
14543/*
14544 * configuration and preset
14545 */
14546static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
14547 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020014548 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010014549 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014550 [ALC861VD_3ST] = "3stack",
14551 [ALC861VD_3ST_DIG] = "3stack-digout",
14552 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020014553 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020014554 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020014555 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014556 [ALC861VD_AUTO] = "auto",
14557};
14558
14559static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014560 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
14561 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010014562 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014563 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Takashi Iwai13c94742008-11-05 08:06:08 +010014564 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020014565 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014566 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014567 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020014568 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Kailang Yang272a5272007-05-14 11:00:38 +020014569 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Takashi Iwai542d7c62007-08-16 18:57:30 +020014570 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010014571 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020014572 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010014573 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020014574 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014575 {}
14576};
14577
14578static struct alc_config_preset alc861vd_presets[] = {
14579 [ALC660VD_3ST] = {
14580 .mixers = { alc861vd_3st_mixer },
14581 .init_verbs = { alc861vd_volume_init_verbs,
14582 alc861vd_3stack_init_verbs },
14583 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14584 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014585 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14586 .channel_mode = alc861vd_3stack_2ch_modes,
14587 .input_mux = &alc861vd_capture_source,
14588 },
Mike Crash6963f842007-06-25 12:12:51 +020014589 [ALC660VD_3ST_DIG] = {
14590 .mixers = { alc861vd_3st_mixer },
14591 .init_verbs = { alc861vd_volume_init_verbs,
14592 alc861vd_3stack_init_verbs },
14593 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14594 .dac_nids = alc660vd_dac_nids,
14595 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020014596 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14597 .channel_mode = alc861vd_3stack_2ch_modes,
14598 .input_mux = &alc861vd_capture_source,
14599 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014600 [ALC861VD_3ST] = {
14601 .mixers = { alc861vd_3st_mixer },
14602 .init_verbs = { alc861vd_volume_init_verbs,
14603 alc861vd_3stack_init_verbs },
14604 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14605 .dac_nids = alc861vd_dac_nids,
14606 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14607 .channel_mode = alc861vd_3stack_2ch_modes,
14608 .input_mux = &alc861vd_capture_source,
14609 },
14610 [ALC861VD_3ST_DIG] = {
14611 .mixers = { alc861vd_3st_mixer },
14612 .init_verbs = { alc861vd_volume_init_verbs,
14613 alc861vd_3stack_init_verbs },
14614 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14615 .dac_nids = alc861vd_dac_nids,
14616 .dig_out_nid = ALC861VD_DIGOUT_NID,
14617 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14618 .channel_mode = alc861vd_3stack_2ch_modes,
14619 .input_mux = &alc861vd_capture_source,
14620 },
14621 [ALC861VD_6ST_DIG] = {
14622 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
14623 .init_verbs = { alc861vd_volume_init_verbs,
14624 alc861vd_6stack_init_verbs },
14625 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14626 .dac_nids = alc861vd_dac_nids,
14627 .dig_out_nid = ALC861VD_DIGOUT_NID,
14628 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
14629 .channel_mode = alc861vd_6stack_modes,
14630 .input_mux = &alc861vd_capture_source,
14631 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020014632 [ALC861VD_LENOVO] = {
14633 .mixers = { alc861vd_lenovo_mixer },
14634 .init_verbs = { alc861vd_volume_init_verbs,
14635 alc861vd_3stack_init_verbs,
14636 alc861vd_eapd_verbs,
14637 alc861vd_lenovo_unsol_verbs },
14638 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14639 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020014640 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14641 .channel_mode = alc861vd_3stack_2ch_modes,
14642 .input_mux = &alc861vd_capture_source,
14643 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014644 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020014645 },
Kailang Yang272a5272007-05-14 11:00:38 +020014646 [ALC861VD_DALLAS] = {
14647 .mixers = { alc861vd_dallas_mixer },
14648 .init_verbs = { alc861vd_dallas_verbs },
14649 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14650 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020014651 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14652 .channel_mode = alc861vd_3stack_2ch_modes,
14653 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014654 .unsol_event = alc_automute_amp_unsol_event,
14655 .init_hook = alc861vd_dallas_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014656 },
14657 [ALC861VD_HP] = {
14658 .mixers = { alc861vd_hp_mixer },
14659 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
14660 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14661 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014662 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014663 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14664 .channel_mode = alc861vd_3stack_2ch_modes,
14665 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014666 .unsol_event = alc_automute_amp_unsol_event,
14667 .init_hook = alc861vd_dallas_init_hook,
Kailang Yangea1fb292008-08-26 12:58:38 +020014668 },
Takashi Iwai13c94742008-11-05 08:06:08 +010014669 [ALC660VD_ASUS_V1S] = {
14670 .mixers = { alc861vd_lenovo_mixer },
14671 .init_verbs = { alc861vd_volume_init_verbs,
14672 alc861vd_3stack_init_verbs,
14673 alc861vd_eapd_verbs,
14674 alc861vd_lenovo_unsol_verbs },
14675 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14676 .dac_nids = alc660vd_dac_nids,
14677 .dig_out_nid = ALC861VD_DIGOUT_NID,
14678 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14679 .channel_mode = alc861vd_3stack_2ch_modes,
14680 .input_mux = &alc861vd_capture_source,
14681 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014682 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010014683 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014684};
14685
14686/*
14687 * BIOS auto configuration
14688 */
14689static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
14690 hda_nid_t nid, int pin_type, int dac_idx)
14691{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014692 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014693}
14694
14695static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
14696{
14697 struct alc_spec *spec = codec->spec;
14698 int i;
14699
14700 for (i = 0; i <= HDA_SIDE; i++) {
14701 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014702 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014703 if (nid)
14704 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014705 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014706 }
14707}
14708
14709
14710static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
14711{
14712 struct alc_spec *spec = codec->spec;
14713 hda_nid_t pin;
14714
14715 pin = spec->autocfg.hp_pins[0];
14716 if (pin) /* connect to front and use dac 0 */
14717 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014718 pin = spec->autocfg.speaker_pins[0];
14719 if (pin)
14720 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014721}
14722
14723#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
14724#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
14725
14726static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
14727{
14728 struct alc_spec *spec = codec->spec;
14729 int i;
14730
14731 for (i = 0; i < AUTO_PIN_LAST; i++) {
14732 hda_nid_t nid = spec->autocfg.input_pins[i];
14733 if (alc861vd_is_input_pin(nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010014734 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +010014735 if (nid != ALC861VD_PIN_CD_NID &&
14736 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014737 snd_hda_codec_write(codec, nid, 0,
14738 AC_VERB_SET_AMP_GAIN_MUTE,
14739 AMP_OUT_MUTE);
14740 }
14741 }
14742}
14743
Takashi Iwaif511b012008-08-15 16:46:42 +020014744#define alc861vd_auto_init_input_src alc882_auto_init_input_src
14745
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014746#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
14747#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
14748
14749/* add playback controls from the parsed DAC table */
14750/* Based on ALC880 version. But ALC861VD has separate,
14751 * different NIDs for mute/unmute switch and volume control */
14752static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
14753 const struct auto_pin_cfg *cfg)
14754{
14755 char name[32];
14756 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
14757 hda_nid_t nid_v, nid_s;
14758 int i, err;
14759
14760 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014761 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014762 continue;
14763 nid_v = alc861vd_idx_to_mixer_vol(
14764 alc880_dac_to_idx(
14765 spec->multiout.dac_nids[i]));
14766 nid_s = alc861vd_idx_to_mixer_switch(
14767 alc880_dac_to_idx(
14768 spec->multiout.dac_nids[i]));
14769
14770 if (i == 2) {
14771 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014772 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14773 "Center Playback Volume",
14774 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
14775 HDA_OUTPUT));
14776 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014777 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014778 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14779 "LFE Playback Volume",
14780 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
14781 HDA_OUTPUT));
14782 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014783 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014784 err = add_control(spec, ALC_CTL_BIND_MUTE,
14785 "Center Playback Switch",
14786 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
14787 HDA_INPUT));
14788 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014789 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014790 err = add_control(spec, ALC_CTL_BIND_MUTE,
14791 "LFE Playback Switch",
14792 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
14793 HDA_INPUT));
14794 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014795 return err;
14796 } else {
14797 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014798 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
14799 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
14800 HDA_OUTPUT));
14801 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014802 return err;
14803 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014804 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020014805 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014806 HDA_INPUT));
14807 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014808 return err;
14809 }
14810 }
14811 return 0;
14812}
14813
14814/* add playback controls for speaker and HP outputs */
14815/* Based on ALC880 version. But ALC861VD has separate,
14816 * different NIDs for mute/unmute switch and volume control */
14817static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
14818 hda_nid_t pin, const char *pfx)
14819{
14820 hda_nid_t nid_v, nid_s;
14821 int err;
14822 char name[32];
14823
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014824 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014825 return 0;
14826
14827 if (alc880_is_fixed_pin(pin)) {
14828 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
14829 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014830 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014831 spec->multiout.hp_nid = nid_v;
14832 else
14833 spec->multiout.extra_out_nid[0] = nid_v;
14834 /* control HP volume/switch on the output mixer amp */
14835 nid_v = alc861vd_idx_to_mixer_vol(
14836 alc880_fixed_pin_idx(pin));
14837 nid_s = alc861vd_idx_to_mixer_switch(
14838 alc880_fixed_pin_idx(pin));
14839
14840 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014841 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
14842 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
14843 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014844 return err;
14845 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014846 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
14847 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
14848 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014849 return err;
14850 } else if (alc880_is_multi_pin(pin)) {
14851 /* set manual connection */
14852 /* we have only a switch on HP-out PIN */
14853 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014854 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
14855 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
14856 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014857 return err;
14858 }
14859 return 0;
14860}
14861
14862/* parse the BIOS configuration and set up the alc_spec
14863 * return 1 if successful, 0 if the proper config is not found,
14864 * or a negative error code
14865 * Based on ALC880 version - had to change it to override
14866 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
14867static int alc861vd_parse_auto_config(struct hda_codec *codec)
14868{
14869 struct alc_spec *spec = codec->spec;
14870 int err;
14871 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
14872
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014873 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14874 alc861vd_ignore);
14875 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014876 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014877 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014878 return 0; /* can't find valid BIOS pin config */
14879
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014880 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
14881 if (err < 0)
14882 return err;
14883 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
14884 if (err < 0)
14885 return err;
14886 err = alc861vd_auto_create_extra_out(spec,
14887 spec->autocfg.speaker_pins[0],
14888 "Speaker");
14889 if (err < 0)
14890 return err;
14891 err = alc861vd_auto_create_extra_out(spec,
14892 spec->autocfg.hp_pins[0],
14893 "Headphone");
14894 if (err < 0)
14895 return err;
14896 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
14897 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014898 return err;
14899
14900 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14901
Takashi Iwai0852d7a2009-02-11 11:35:15 +010014902 if (spec->autocfg.dig_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014903 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
14904
Takashi Iwai603c4012008-07-30 15:01:44 +020014905 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014906 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014907
Takashi Iwaid88897e2008-10-31 15:01:37 +010014908 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014909
14910 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014911 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014912
Takashi Iwai776e1842007-08-29 15:07:11 +020014913 err = alc_auto_add_mic_boost(codec);
14914 if (err < 0)
14915 return err;
14916
Takashi Iwai4a79ba32009-04-22 16:31:35 +020014917 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
14918
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014919 return 1;
14920}
14921
14922/* additional initialization for auto-configuration model */
14923static void alc861vd_auto_init(struct hda_codec *codec)
14924{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014925 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014926 alc861vd_auto_init_multi_out(codec);
14927 alc861vd_auto_init_hp_out(codec);
14928 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020014929 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014930 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014931 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014932}
14933
14934static int patch_alc861vd(struct hda_codec *codec)
14935{
14936 struct alc_spec *spec;
14937 int err, board_config;
14938
14939 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
14940 if (spec == NULL)
14941 return -ENOMEM;
14942
14943 codec->spec = spec;
14944
14945 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
14946 alc861vd_models,
14947 alc861vd_cfg_tbl);
14948
14949 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
14950 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
14951 "ALC861VD, trying auto-probe from BIOS...\n");
14952 board_config = ALC861VD_AUTO;
14953 }
14954
14955 if (board_config == ALC861VD_AUTO) {
14956 /* automatic parse from the BIOS config */
14957 err = alc861vd_parse_auto_config(codec);
14958 if (err < 0) {
14959 alc_free(codec);
14960 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014961 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014962 printk(KERN_INFO
14963 "hda_codec: Cannot set up configuration "
14964 "from BIOS. Using base mode...\n");
14965 board_config = ALC861VD_3ST;
14966 }
14967 }
14968
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014969 err = snd_hda_attach_beep_device(codec, 0x23);
14970 if (err < 0) {
14971 alc_free(codec);
14972 return err;
14973 }
14974
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014975 if (board_config != ALC861VD_AUTO)
14976 setup_preset(spec, &alc861vd_presets[board_config]);
14977
Kailang Yang2f893282008-05-27 12:14:47 +020014978 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020014979 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010014980 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020014981 }
14982
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014983 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
14984 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
14985
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014986 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
14987 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
14988
14989 spec->adc_nids = alc861vd_adc_nids;
14990 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +010014991 spec->capsrc_nids = alc861vd_capsrc_nids;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014992 spec->capture_style = CAPT_MIX;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014993
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014994 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014995 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014996
Takashi Iwai2134ea42008-01-10 16:53:55 +010014997 spec->vmaster_nid = 0x02;
14998
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014999 codec->patch_ops = alc_patch_ops;
15000
15001 if (board_config == ALC861VD_AUTO)
15002 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015003#ifdef CONFIG_SND_HDA_POWER_SAVE
15004 if (!spec->loopback.amplist)
15005 spec->loopback.amplist = alc861vd_loopbacks;
15006#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010015007 codec->proc_widget_hook = print_realtek_coef;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015008
15009 return 0;
15010}
15011
15012/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015013 * ALC662 support
15014 *
15015 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
15016 * configuration. Each pin widget can choose any input DACs and a mixer.
15017 * Each ADC is connected from a mixer of all inputs. This makes possible
15018 * 6-channel independent captures.
15019 *
15020 * In addition, an independent DAC for the multi-playback (not used in this
15021 * driver yet).
15022 */
15023#define ALC662_DIGOUT_NID 0x06
15024#define ALC662_DIGIN_NID 0x0a
15025
15026static hda_nid_t alc662_dac_nids[4] = {
15027 /* front, rear, clfe, rear_surr */
15028 0x02, 0x03, 0x04
15029};
15030
Kailang Yang622e84c2009-04-21 07:39:04 +020015031static hda_nid_t alc272_dac_nids[2] = {
15032 0x02, 0x03
15033};
15034
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015035static hda_nid_t alc662_adc_nids[1] = {
15036 /* ADC1-2 */
15037 0x09,
15038};
Takashi Iwaie1406342008-02-11 18:32:32 +010015039
Kailang Yang622e84c2009-04-21 07:39:04 +020015040static hda_nid_t alc272_adc_nids[1] = {
15041 /* ADC1-2 */
15042 0x08,
15043};
15044
Kailang Yang77a261b2008-02-19 11:38:05 +010015045static hda_nid_t alc662_capsrc_nids[1] = { 0x22 };
Kailang Yang622e84c2009-04-21 07:39:04 +020015046static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
15047
Takashi Iwaie1406342008-02-11 18:32:32 +010015048
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015049/* input MUX */
15050/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015051static struct hda_input_mux alc662_capture_source = {
15052 .num_items = 4,
15053 .items = {
15054 { "Mic", 0x0 },
15055 { "Front Mic", 0x1 },
15056 { "Line", 0x2 },
15057 { "CD", 0x4 },
15058 },
15059};
15060
15061static struct hda_input_mux alc662_lenovo_101e_capture_source = {
15062 .num_items = 2,
15063 .items = {
15064 { "Mic", 0x1 },
15065 { "Line", 0x2 },
15066 },
15067};
Kailang Yang291702f2007-10-16 14:28:03 +020015068
15069static struct hda_input_mux alc662_eeepc_capture_source = {
15070 .num_items = 2,
15071 .items = {
15072 { "i-Mic", 0x1 },
15073 { "e-Mic", 0x0 },
15074 },
15075};
15076
Kailang Yang6dda9f42008-05-27 12:05:31 +020015077static struct hda_input_mux alc663_capture_source = {
15078 .num_items = 3,
15079 .items = {
15080 { "Mic", 0x0 },
15081 { "Front Mic", 0x1 },
15082 { "Line", 0x2 },
15083 },
15084};
15085
15086static struct hda_input_mux alc663_m51va_capture_source = {
15087 .num_items = 2,
15088 .items = {
15089 { "Ext-Mic", 0x0 },
15090 { "D-Mic", 0x9 },
15091 },
15092};
15093
Chris Pockelé9541ba12009-05-12 08:08:53 +020015094#if 1 /* set to 0 for testing other input sources below */
15095static struct hda_input_mux alc272_nc10_capture_source = {
15096 .num_items = 2,
15097 .items = {
15098 { "Autoselect Mic", 0x0 },
15099 { "Internal Mic", 0x1 },
15100 },
15101};
15102#else
15103static struct hda_input_mux alc272_nc10_capture_source = {
15104 .num_items = 16,
15105 .items = {
15106 { "Autoselect Mic", 0x0 },
15107 { "Internal Mic", 0x1 },
15108 { "In-0x02", 0x2 },
15109 { "In-0x03", 0x3 },
15110 { "In-0x04", 0x4 },
15111 { "In-0x05", 0x5 },
15112 { "In-0x06", 0x6 },
15113 { "In-0x07", 0x7 },
15114 { "In-0x08", 0x8 },
15115 { "In-0x09", 0x9 },
15116 { "In-0x0a", 0x0a },
15117 { "In-0x0b", 0x0b },
15118 { "In-0x0c", 0x0c },
15119 { "In-0x0d", 0x0d },
15120 { "In-0x0e", 0x0e },
15121 { "In-0x0f", 0x0f },
15122 },
15123};
15124#endif
15125
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015126/*
15127 * 2ch mode
15128 */
15129static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
15130 { 2, NULL }
15131};
15132
15133/*
15134 * 2ch mode
15135 */
15136static struct hda_verb alc662_3ST_ch2_init[] = {
15137 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
15138 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15139 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
15140 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15141 { } /* end */
15142};
15143
15144/*
15145 * 6ch mode
15146 */
15147static struct hda_verb alc662_3ST_ch6_init[] = {
15148 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15149 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15150 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
15151 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15152 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15153 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
15154 { } /* end */
15155};
15156
15157static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
15158 { 2, alc662_3ST_ch2_init },
15159 { 6, alc662_3ST_ch6_init },
15160};
15161
15162/*
15163 * 2ch mode
15164 */
15165static struct hda_verb alc662_sixstack_ch6_init[] = {
15166 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15167 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15168 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15169 { } /* end */
15170};
15171
15172/*
15173 * 6ch mode
15174 */
15175static struct hda_verb alc662_sixstack_ch8_init[] = {
15176 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15177 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15178 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15179 { } /* end */
15180};
15181
15182static struct hda_channel_mode alc662_5stack_modes[2] = {
15183 { 2, alc662_sixstack_ch6_init },
15184 { 6, alc662_sixstack_ch8_init },
15185};
15186
15187/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15188 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15189 */
15190
15191static struct snd_kcontrol_new alc662_base_mixer[] = {
15192 /* output mixer control */
15193 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015194 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015195 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015196 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015197 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15198 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015199 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15200 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015201 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15202
15203 /*Input mixer control */
15204 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
15205 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
15206 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
15207 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
15208 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
15209 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
15210 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
15211 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015212 { } /* end */
15213};
15214
15215static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
15216 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015217 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015218 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15219 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15220 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15221 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15222 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15223 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15224 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15225 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15226 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015227 { } /* end */
15228};
15229
15230static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
15231 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015232 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015233 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015234 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015235 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15236 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015237 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15238 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015239 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15240 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15241 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15242 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15243 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15244 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15245 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15246 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15247 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015248 { } /* end */
15249};
15250
15251static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
15252 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15253 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010015254 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15255 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015256 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15257 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15258 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15259 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15260 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015261 { } /* end */
15262};
15263
Kailang Yang291702f2007-10-16 14:28:03 +020015264static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020015265 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15266 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020015267
15268 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
15269 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15270 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15271
15272 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
15273 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15274 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15275 { } /* end */
15276};
15277
Kailang Yang8c427222008-01-10 13:03:59 +010015278static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020015279 ALC262_HIPPO_MASTER_SWITCH,
15280 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015281 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015282 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15283 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015284 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
15285 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15286 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15287 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15288 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15289 { } /* end */
15290};
15291
Kailang Yangf1d4e282008-08-26 14:03:29 +020015292static struct hda_bind_ctls alc663_asus_bind_master_vol = {
15293 .ops = &snd_hda_bind_vol,
15294 .values = {
15295 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15296 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
15297 0
15298 },
15299};
15300
15301static struct hda_bind_ctls alc663_asus_one_bind_switch = {
15302 .ops = &snd_hda_bind_sw,
15303 .values = {
15304 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15305 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15306 0
15307 },
15308};
15309
Kailang Yang6dda9f42008-05-27 12:05:31 +020015310static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015311 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15312 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
15313 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15314 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15315 { } /* end */
15316};
15317
15318static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
15319 .ops = &snd_hda_bind_sw,
15320 .values = {
15321 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15322 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15323 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15324 0
15325 },
15326};
15327
15328static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
15329 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15330 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
15331 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15332 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15333 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15334 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15335
15336 { } /* end */
15337};
15338
15339static struct hda_bind_ctls alc663_asus_four_bind_switch = {
15340 .ops = &snd_hda_bind_sw,
15341 .values = {
15342 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15343 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15344 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
15345 0
15346 },
15347};
15348
15349static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
15350 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15351 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
15352 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15353 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15354 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15355 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15356 { } /* end */
15357};
15358
15359static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020015360 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15361 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015362 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15363 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15364 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15365 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15366 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15367 { } /* end */
15368};
15369
15370static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
15371 .ops = &snd_hda_bind_vol,
15372 .values = {
15373 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15374 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
15375 0
15376 },
15377};
15378
15379static struct hda_bind_ctls alc663_asus_two_bind_switch = {
15380 .ops = &snd_hda_bind_sw,
15381 .values = {
15382 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15383 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
15384 0
15385 },
15386};
15387
15388static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
15389 HDA_BIND_VOL("Master Playback Volume",
15390 &alc663_asus_two_bind_master_vol),
15391 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15392 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015393 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15394 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15395 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015396 { } /* end */
15397};
15398
15399static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
15400 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15401 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15402 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15403 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15404 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15405 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015406 { } /* end */
15407};
15408
15409static struct snd_kcontrol_new alc663_g71v_mixer[] = {
15410 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15411 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15412 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15413 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15414 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15415
15416 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15417 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15418 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15419 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15420 { } /* end */
15421};
15422
15423static struct snd_kcontrol_new alc663_g50v_mixer[] = {
15424 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15425 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15426 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15427
15428 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15429 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15430 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15431 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15432 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15433 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15434 { } /* end */
15435};
15436
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015437static struct snd_kcontrol_new alc662_chmode_mixer[] = {
15438 {
15439 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15440 .name = "Channel Mode",
15441 .info = alc_ch_mode_info,
15442 .get = alc_ch_mode_get,
15443 .put = alc_ch_mode_put,
15444 },
15445 { } /* end */
15446};
15447
15448static struct hda_verb alc662_init_verbs[] = {
15449 /* ADC: mute amp left and right */
15450 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15451 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15452 /* Front mixer: unmute input/output amp left and right (volume = 0) */
15453
Takashi Iwaicb53c622007-08-10 17:21:45 +020015454 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15455 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15456 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15457 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15458 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015459
Kailang Yangb60dd392007-09-20 12:50:29 +020015460 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15461 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15462 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15463 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15464 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15465 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015466
15467 /* Front Pin: output 0 (0x0c) */
15468 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15469 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15470
15471 /* Rear Pin: output 1 (0x0d) */
15472 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15473 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15474
15475 /* CLFE Pin: output 2 (0x0e) */
15476 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15477 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15478
15479 /* Mic (rear) pin: input vref at 80% */
15480 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15481 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15482 /* Front Mic pin: input vref at 80% */
15483 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15484 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15485 /* Line In pin: input */
15486 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15487 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15488 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15489 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15490 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15491 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15492 /* CD pin widget for input */
15493 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15494
15495 /* FIXME: use matrix-type input source selection */
15496 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15497 /* Input mixer */
15498 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020015499 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015500
15501 /* always trun on EAPD */
15502 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15503 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
15504
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015505 { }
15506};
15507
15508static struct hda_verb alc662_sue_init_verbs[] = {
15509 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15510 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020015511 {}
15512};
15513
15514static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
15515 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15516 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15517 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015518};
15519
Kailang Yang8c427222008-01-10 13:03:59 +010015520/* Set Unsolicited Event*/
15521static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
15522 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15523 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15524 {}
15525};
15526
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015527/*
15528 * generic initialization of ADC, input mixers and output mixers
15529 */
15530static struct hda_verb alc662_auto_init_verbs[] = {
15531 /*
15532 * Unmute ADC and set the default input to mic-in
15533 */
15534 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15535 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15536
15537 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
15538 * mixer widget
15539 * Note: PASD motherboards uses the Line In 2 as the input for front
15540 * panel mic (mic 2)
15541 */
15542 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020015543 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15544 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15545 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15546 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15547 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015548
15549 /*
15550 * Set up output mixers (0x0c - 0x0f)
15551 */
15552 /* set vol=0 to output mixers */
15553 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15554 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15555 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15556
15557 /* set up input amps for analog loopback */
15558 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020015559 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15560 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15561 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15562 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15563 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15564 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015565
15566
15567 /* FIXME: use matrix-type input source selection */
15568 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15569 /* Input mixer */
15570 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020015571 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015572 { }
15573};
15574
Takashi Iwai24fb9172008-09-02 14:48:20 +020015575/* additional verbs for ALC663 */
15576static struct hda_verb alc663_auto_init_verbs[] = {
15577 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15578 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15579 { }
15580};
15581
Kailang Yang6dda9f42008-05-27 12:05:31 +020015582static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015583 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15584 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015585 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15586 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020015587 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15588 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15589 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015590 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15591 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15592 {}
15593};
15594
Kailang Yangf1d4e282008-08-26 14:03:29 +020015595static struct hda_verb alc663_21jd_amic_init_verbs[] = {
15596 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15597 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15598 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15599 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15600 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15601 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15602 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15603 {}
15604};
15605
15606static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
15607 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15608 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15609 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15610 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15611 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15612 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15613 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15614 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15615 {}
15616};
15617
15618static struct hda_verb alc663_15jd_amic_init_verbs[] = {
15619 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15620 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15621 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15622 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15623 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15624 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15625 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15626 {}
15627};
15628
15629static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
15630 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15631 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15632 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15633 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15634 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15635 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15636 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15637 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15638 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15639 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15640 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15641 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15642 {}
15643};
15644
15645static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
15646 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15647 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15648 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15649 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15650 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15651 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15652 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15653 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15654 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15655 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15656 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15657 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15658 {}
15659};
15660
Kailang Yang6dda9f42008-05-27 12:05:31 +020015661static struct hda_verb alc663_g71v_init_verbs[] = {
15662 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15663 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
15664 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
15665
15666 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15667 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15668 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15669
15670 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15671 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
15672 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
15673 {}
15674};
15675
15676static struct hda_verb alc663_g50v_init_verbs[] = {
15677 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15678 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15679 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15680
15681 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15682 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15683 {}
15684};
15685
Kailang Yangf1d4e282008-08-26 14:03:29 +020015686static struct hda_verb alc662_ecs_init_verbs[] = {
15687 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
15688 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15689 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15690 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15691 {}
15692};
15693
Kailang Yang622e84c2009-04-21 07:39:04 +020015694static struct hda_verb alc272_dell_zm1_init_verbs[] = {
15695 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15696 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15697 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15698 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15699 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15700 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15701 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15702 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15703 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
15704 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15705 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15706 {}
15707};
15708
15709static struct hda_verb alc272_dell_init_verbs[] = {
15710 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15711 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15712 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15713 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15714 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15715 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15716 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15717 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15718 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
15719 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15720 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15721 {}
15722};
15723
Kailang Yangf1d4e282008-08-26 14:03:29 +020015724static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
15725 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
15726 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
15727 { } /* end */
15728};
15729
Kailang Yang622e84c2009-04-21 07:39:04 +020015730static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
15731 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
15732 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
15733 { } /* end */
15734};
15735
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015736static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
15737{
15738 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015739 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015740
15741 present = snd_hda_codec_read(codec, 0x14, 0,
15742 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020015743 bits = present ? HDA_AMP_MUTE : 0;
15744 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15745 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015746}
15747
15748static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
15749{
15750 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015751 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015752
15753 present = snd_hda_codec_read(codec, 0x1b, 0,
15754 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020015755 bits = present ? HDA_AMP_MUTE : 0;
15756 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15757 HDA_AMP_MUTE, bits);
15758 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
15759 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015760}
15761
15762static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
15763 unsigned int res)
15764{
15765 if ((res >> 26) == ALC880_HP_EVENT)
15766 alc662_lenovo_101e_all_automute(codec);
15767 if ((res >> 26) == ALC880_FRONT_EVENT)
15768 alc662_lenovo_101e_ispeaker_automute(codec);
15769}
15770
Kailang Yang291702f2007-10-16 14:28:03 +020015771static void alc662_eeepc_mic_automute(struct hda_codec *codec)
15772{
15773 unsigned int present;
15774
15775 present = snd_hda_codec_read(codec, 0x18, 0,
15776 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
15777 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15778 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
15779 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15780 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
15781 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15782 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
15783 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15784 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
15785}
15786
15787/* unsolicited event for HP jack sensing */
15788static void alc662_eeepc_unsol_event(struct hda_codec *codec,
15789 unsigned int res)
15790{
Kailang Yang291702f2007-10-16 14:28:03 +020015791 if ((res >> 26) == ALC880_MIC_EVENT)
15792 alc662_eeepc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020015793 else
15794 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020015795}
15796
15797static void alc662_eeepc_inithook(struct hda_codec *codec)
15798{
Takashi Iwai42171c12009-05-08 14:11:43 +020015799 alc262_hippo1_init_hook(codec);
Kailang Yang291702f2007-10-16 14:28:03 +020015800 alc662_eeepc_mic_automute(codec);
15801}
15802
Kailang Yang8c427222008-01-10 13:03:59 +010015803static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
15804{
Takashi Iwai42171c12009-05-08 14:11:43 +020015805 struct alc_spec *spec = codec->spec;
15806
15807 spec->autocfg.hp_pins[0] = 0x14;
15808 spec->autocfg.speaker_pins[0] = 0x1b;
15809 alc262_hippo_master_update(codec);
Kailang Yang8c427222008-01-10 13:03:59 +010015810}
15811
Kailang Yang6dda9f42008-05-27 12:05:31 +020015812static void alc663_m51va_speaker_automute(struct hda_codec *codec)
15813{
15814 unsigned int present;
15815 unsigned char bits;
15816
15817 present = snd_hda_codec_read(codec, 0x21, 0,
Kailang Yangf1d4e282008-08-26 14:03:29 +020015818 AC_VERB_GET_PIN_SENSE, 0)
15819 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020015820 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020015821 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15822 AMP_IN_MUTE(0), bits);
15823 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15824 AMP_IN_MUTE(0), bits);
15825}
15826
15827static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
15828{
15829 unsigned int present;
15830 unsigned char bits;
15831
15832 present = snd_hda_codec_read(codec, 0x21, 0,
15833 AC_VERB_GET_PIN_SENSE, 0)
15834 & AC_PINSENSE_PRESENCE;
15835 bits = present ? HDA_AMP_MUTE : 0;
15836 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15837 AMP_IN_MUTE(0), bits);
15838 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15839 AMP_IN_MUTE(0), bits);
15840 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
15841 AMP_IN_MUTE(0), bits);
15842 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
15843 AMP_IN_MUTE(0), bits);
15844}
15845
15846static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
15847{
15848 unsigned int present;
15849 unsigned char bits;
15850
15851 present = snd_hda_codec_read(codec, 0x15, 0,
15852 AC_VERB_GET_PIN_SENSE, 0)
15853 & AC_PINSENSE_PRESENCE;
15854 bits = present ? HDA_AMP_MUTE : 0;
15855 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15856 AMP_IN_MUTE(0), bits);
15857 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15858 AMP_IN_MUTE(0), bits);
15859 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
15860 AMP_IN_MUTE(0), bits);
15861 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
15862 AMP_IN_MUTE(0), bits);
15863}
15864
15865static void alc662_f5z_speaker_automute(struct hda_codec *codec)
15866{
15867 unsigned int present;
15868 unsigned char bits;
15869
15870 present = snd_hda_codec_read(codec, 0x1b, 0,
15871 AC_VERB_GET_PIN_SENSE, 0)
15872 & AC_PINSENSE_PRESENCE;
15873 bits = present ? 0 : PIN_OUT;
15874 snd_hda_codec_write(codec, 0x14, 0,
15875 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
15876}
15877
15878static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
15879{
15880 unsigned int present1, present2;
15881
15882 present1 = snd_hda_codec_read(codec, 0x21, 0,
15883 AC_VERB_GET_PIN_SENSE, 0)
15884 & AC_PINSENSE_PRESENCE;
15885 present2 = snd_hda_codec_read(codec, 0x15, 0,
15886 AC_VERB_GET_PIN_SENSE, 0)
15887 & AC_PINSENSE_PRESENCE;
15888
15889 if (present1 || present2) {
15890 snd_hda_codec_write_cache(codec, 0x14, 0,
15891 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
15892 } else {
15893 snd_hda_codec_write_cache(codec, 0x14, 0,
15894 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
15895 }
15896}
15897
15898static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
15899{
15900 unsigned int present1, present2;
15901
15902 present1 = snd_hda_codec_read(codec, 0x1b, 0,
15903 AC_VERB_GET_PIN_SENSE, 0)
15904 & AC_PINSENSE_PRESENCE;
15905 present2 = snd_hda_codec_read(codec, 0x15, 0,
15906 AC_VERB_GET_PIN_SENSE, 0)
15907 & AC_PINSENSE_PRESENCE;
15908
15909 if (present1 || present2) {
15910 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15911 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
15912 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15913 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
15914 } else {
15915 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15916 AMP_IN_MUTE(0), 0);
15917 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15918 AMP_IN_MUTE(0), 0);
15919 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020015920}
15921
15922static void alc663_m51va_mic_automute(struct hda_codec *codec)
15923{
15924 unsigned int present;
15925
15926 present = snd_hda_codec_read(codec, 0x18, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020015927 AC_VERB_GET_PIN_SENSE, 0)
15928 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020015929 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015930 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015931 snd_hda_codec_write_cache(codec, 0x23, 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, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015934 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015935 snd_hda_codec_write_cache(codec, 0x23, 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}
15938
15939static void alc663_m51va_unsol_event(struct hda_codec *codec,
15940 unsigned int res)
15941{
15942 switch (res >> 26) {
15943 case ALC880_HP_EVENT:
15944 alc663_m51va_speaker_automute(codec);
15945 break;
15946 case ALC880_MIC_EVENT:
15947 alc663_m51va_mic_automute(codec);
15948 break;
15949 }
15950}
15951
15952static void alc663_m51va_inithook(struct hda_codec *codec)
15953{
15954 alc663_m51va_speaker_automute(codec);
15955 alc663_m51va_mic_automute(codec);
15956}
15957
Kailang Yangf1d4e282008-08-26 14:03:29 +020015958/* ***************** Mode1 ******************************/
15959static void alc663_mode1_unsol_event(struct hda_codec *codec,
15960 unsigned int res)
15961{
15962 switch (res >> 26) {
15963 case ALC880_HP_EVENT:
15964 alc663_m51va_speaker_automute(codec);
15965 break;
15966 case ALC880_MIC_EVENT:
15967 alc662_eeepc_mic_automute(codec);
15968 break;
15969 }
15970}
15971
15972static void alc663_mode1_inithook(struct hda_codec *codec)
15973{
15974 alc663_m51va_speaker_automute(codec);
15975 alc662_eeepc_mic_automute(codec);
15976}
15977/* ***************** Mode2 ******************************/
15978static void alc662_mode2_unsol_event(struct hda_codec *codec,
15979 unsigned int res)
15980{
15981 switch (res >> 26) {
15982 case ALC880_HP_EVENT:
15983 alc662_f5z_speaker_automute(codec);
15984 break;
15985 case ALC880_MIC_EVENT:
15986 alc662_eeepc_mic_automute(codec);
15987 break;
15988 }
15989}
15990
15991static void alc662_mode2_inithook(struct hda_codec *codec)
15992{
15993 alc662_f5z_speaker_automute(codec);
15994 alc662_eeepc_mic_automute(codec);
15995}
15996/* ***************** Mode3 ******************************/
15997static void alc663_mode3_unsol_event(struct hda_codec *codec,
15998 unsigned int res)
15999{
16000 switch (res >> 26) {
16001 case ALC880_HP_EVENT:
16002 alc663_two_hp_m1_speaker_automute(codec);
16003 break;
16004 case ALC880_MIC_EVENT:
16005 alc662_eeepc_mic_automute(codec);
16006 break;
16007 }
16008}
16009
16010static void alc663_mode3_inithook(struct hda_codec *codec)
16011{
16012 alc663_two_hp_m1_speaker_automute(codec);
16013 alc662_eeepc_mic_automute(codec);
16014}
16015/* ***************** Mode4 ******************************/
16016static void alc663_mode4_unsol_event(struct hda_codec *codec,
16017 unsigned int res)
16018{
16019 switch (res >> 26) {
16020 case ALC880_HP_EVENT:
16021 alc663_21jd_two_speaker_automute(codec);
16022 break;
16023 case ALC880_MIC_EVENT:
16024 alc662_eeepc_mic_automute(codec);
16025 break;
16026 }
16027}
16028
16029static void alc663_mode4_inithook(struct hda_codec *codec)
16030{
16031 alc663_21jd_two_speaker_automute(codec);
16032 alc662_eeepc_mic_automute(codec);
16033}
16034/* ***************** Mode5 ******************************/
16035static void alc663_mode5_unsol_event(struct hda_codec *codec,
16036 unsigned int res)
16037{
16038 switch (res >> 26) {
16039 case ALC880_HP_EVENT:
16040 alc663_15jd_two_speaker_automute(codec);
16041 break;
16042 case ALC880_MIC_EVENT:
16043 alc662_eeepc_mic_automute(codec);
16044 break;
16045 }
16046}
16047
16048static void alc663_mode5_inithook(struct hda_codec *codec)
16049{
16050 alc663_15jd_two_speaker_automute(codec);
16051 alc662_eeepc_mic_automute(codec);
16052}
16053/* ***************** Mode6 ******************************/
16054static void alc663_mode6_unsol_event(struct hda_codec *codec,
16055 unsigned int res)
16056{
16057 switch (res >> 26) {
16058 case ALC880_HP_EVENT:
16059 alc663_two_hp_m2_speaker_automute(codec);
16060 break;
16061 case ALC880_MIC_EVENT:
16062 alc662_eeepc_mic_automute(codec);
16063 break;
16064 }
16065}
16066
16067static void alc663_mode6_inithook(struct hda_codec *codec)
16068{
16069 alc663_two_hp_m2_speaker_automute(codec);
16070 alc662_eeepc_mic_automute(codec);
16071}
16072
Kailang Yang6dda9f42008-05-27 12:05:31 +020016073static void alc663_g71v_hp_automute(struct hda_codec *codec)
16074{
16075 unsigned int present;
16076 unsigned char bits;
16077
16078 present = snd_hda_codec_read(codec, 0x21, 0,
16079 AC_VERB_GET_PIN_SENSE, 0)
16080 & AC_PINSENSE_PRESENCE;
16081 bits = present ? HDA_AMP_MUTE : 0;
16082 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16083 HDA_AMP_MUTE, bits);
16084 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16085 HDA_AMP_MUTE, bits);
16086}
16087
16088static void alc663_g71v_front_automute(struct hda_codec *codec)
16089{
16090 unsigned int present;
16091 unsigned char bits;
16092
16093 present = snd_hda_codec_read(codec, 0x15, 0,
16094 AC_VERB_GET_PIN_SENSE, 0)
16095 & AC_PINSENSE_PRESENCE;
16096 bits = present ? HDA_AMP_MUTE : 0;
16097 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16098 HDA_AMP_MUTE, bits);
16099}
16100
16101static void alc663_g71v_unsol_event(struct hda_codec *codec,
16102 unsigned int res)
16103{
16104 switch (res >> 26) {
16105 case ALC880_HP_EVENT:
16106 alc663_g71v_hp_automute(codec);
16107 break;
16108 case ALC880_FRONT_EVENT:
16109 alc663_g71v_front_automute(codec);
16110 break;
16111 case ALC880_MIC_EVENT:
16112 alc662_eeepc_mic_automute(codec);
16113 break;
16114 }
16115}
16116
16117static void alc663_g71v_inithook(struct hda_codec *codec)
16118{
16119 alc663_g71v_front_automute(codec);
16120 alc663_g71v_hp_automute(codec);
16121 alc662_eeepc_mic_automute(codec);
16122}
16123
16124static void alc663_g50v_unsol_event(struct hda_codec *codec,
16125 unsigned int res)
16126{
16127 switch (res >> 26) {
16128 case ALC880_HP_EVENT:
16129 alc663_m51va_speaker_automute(codec);
16130 break;
16131 case ALC880_MIC_EVENT:
16132 alc662_eeepc_mic_automute(codec);
16133 break;
16134 }
16135}
16136
16137static void alc663_g50v_inithook(struct hda_codec *codec)
16138{
16139 alc663_m51va_speaker_automute(codec);
16140 alc662_eeepc_mic_automute(codec);
16141}
16142
Kailang Yangf1d4e282008-08-26 14:03:29 +020016143static struct snd_kcontrol_new alc662_ecs_mixer[] = {
16144 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020016145 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016146
16147 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
16148 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
16149 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
16150
16151 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16152 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16153 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16154 { } /* end */
16155};
16156
Chris Pockelé9541ba12009-05-12 08:08:53 +020016157static struct snd_kcontrol_new alc272_nc10_mixer[] = {
16158 /* Master Playback automatically created from Speaker and Headphone */
16159 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16160 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16161 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16162 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16163
16164 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16165 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16166 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
16167
16168 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16169 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16170 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
16171 { } /* end */
16172};
16173
Takashi Iwaicb53c622007-08-10 17:21:45 +020016174#ifdef CONFIG_SND_HDA_POWER_SAVE
16175#define alc662_loopbacks alc880_loopbacks
16176#endif
16177
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016178
16179/* pcm configuration: identiacal with ALC880 */
16180#define alc662_pcm_analog_playback alc880_pcm_analog_playback
16181#define alc662_pcm_analog_capture alc880_pcm_analog_capture
16182#define alc662_pcm_digital_playback alc880_pcm_digital_playback
16183#define alc662_pcm_digital_capture alc880_pcm_digital_capture
16184
16185/*
16186 * configuration and preset
16187 */
16188static const char *alc662_models[ALC662_MODEL_LAST] = {
16189 [ALC662_3ST_2ch_DIG] = "3stack-dig",
16190 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
16191 [ALC662_3ST_6ch] = "3stack-6ch",
16192 [ALC662_5ST_DIG] = "6stack-dig",
16193 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020016194 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010016195 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016196 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020016197 [ALC663_ASUS_M51VA] = "m51va",
16198 [ALC663_ASUS_G71V] = "g71v",
16199 [ALC663_ASUS_H13] = "h13",
16200 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016201 [ALC663_ASUS_MODE1] = "asus-mode1",
16202 [ALC662_ASUS_MODE2] = "asus-mode2",
16203 [ALC663_ASUS_MODE3] = "asus-mode3",
16204 [ALC663_ASUS_MODE4] = "asus-mode4",
16205 [ALC663_ASUS_MODE5] = "asus-mode5",
16206 [ALC663_ASUS_MODE6] = "asus-mode6",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020016207 [ALC272_DELL] = "dell",
16208 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020016209 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016210 [ALC662_AUTO] = "auto",
16211};
16212
16213static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010016214 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020016215 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
16216 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016217 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
16218 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
16219 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
16220 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
16221 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
16222 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
16223 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
16224 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
16225 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
16226 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
16227 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
16228 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016229 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
16230 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
16231 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016232 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
16233 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
16234 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
16235 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016236 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016237 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
16238 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016239 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016240 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
16241 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
16242 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020016243 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
16244 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
16245 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016246 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
16247 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
16248 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016249 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016250 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
16251 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020016252 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016253 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020016254 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016255 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
16256 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
16257 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016258 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016259 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
16260 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010016261 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020016262 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010016263 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016264 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030016265 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
16266 ALC662_3ST_6ch_DIG),
Chris Pockelé9541ba12009-05-12 08:08:53 +020016267 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030016268 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
16269 ALC662_3ST_6ch_DIG),
Vedran Miletic19c009a2008-09-29 20:29:25 +020016270 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020016271 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016272 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020016273 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020016274 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016275 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
16276 ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016277 {}
16278};
16279
16280static struct alc_config_preset alc662_presets[] = {
16281 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016282 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016283 .init_verbs = { alc662_init_verbs },
16284 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16285 .dac_nids = alc662_dac_nids,
16286 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016287 .dig_in_nid = ALC662_DIGIN_NID,
16288 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16289 .channel_mode = alc662_3ST_2ch_modes,
16290 .input_mux = &alc662_capture_source,
16291 },
16292 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016293 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016294 .init_verbs = { alc662_init_verbs },
16295 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16296 .dac_nids = alc662_dac_nids,
16297 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016298 .dig_in_nid = ALC662_DIGIN_NID,
16299 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16300 .channel_mode = alc662_3ST_6ch_modes,
16301 .need_dac_fix = 1,
16302 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016303 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016304 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016305 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016306 .init_verbs = { alc662_init_verbs },
16307 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16308 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016309 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16310 .channel_mode = alc662_3ST_6ch_modes,
16311 .need_dac_fix = 1,
16312 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016313 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016314 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016315 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016316 .init_verbs = { alc662_init_verbs },
16317 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16318 .dac_nids = alc662_dac_nids,
16319 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016320 .dig_in_nid = ALC662_DIGIN_NID,
16321 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
16322 .channel_mode = alc662_5stack_modes,
16323 .input_mux = &alc662_capture_source,
16324 },
16325 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016326 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016327 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
16328 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16329 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016330 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16331 .channel_mode = alc662_3ST_2ch_modes,
16332 .input_mux = &alc662_lenovo_101e_capture_source,
16333 .unsol_event = alc662_lenovo_101e_unsol_event,
16334 .init_hook = alc662_lenovo_101e_all_automute,
16335 },
Kailang Yang291702f2007-10-16 14:28:03 +020016336 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016337 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020016338 .init_verbs = { alc662_init_verbs,
16339 alc662_eeepc_sue_init_verbs },
16340 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16341 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020016342 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16343 .channel_mode = alc662_3ST_2ch_modes,
16344 .input_mux = &alc662_eeepc_capture_source,
16345 .unsol_event = alc662_eeepc_unsol_event,
16346 .init_hook = alc662_eeepc_inithook,
16347 },
Kailang Yang8c427222008-01-10 13:03:59 +010016348 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016349 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010016350 alc662_chmode_mixer },
16351 .init_verbs = { alc662_init_verbs,
16352 alc662_eeepc_ep20_sue_init_verbs },
16353 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16354 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010016355 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16356 .channel_mode = alc662_3ST_6ch_modes,
16357 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020016358 .unsol_event = alc662_eeepc_unsol_event,
Kailang Yang8c427222008-01-10 13:03:59 +010016359 .init_hook = alc662_eeepc_ep20_inithook,
16360 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016361 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016362 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016363 .init_verbs = { alc662_init_verbs,
16364 alc662_ecs_init_verbs },
16365 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16366 .dac_nids = alc662_dac_nids,
16367 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16368 .channel_mode = alc662_3ST_2ch_modes,
16369 .input_mux = &alc662_eeepc_capture_source,
16370 .unsol_event = alc662_eeepc_unsol_event,
16371 .init_hook = alc662_eeepc_inithook,
16372 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016373 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016374 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016375 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16376 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16377 .dac_nids = alc662_dac_nids,
16378 .dig_out_nid = ALC662_DIGOUT_NID,
16379 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16380 .channel_mode = alc662_3ST_2ch_modes,
16381 .input_mux = &alc663_m51va_capture_source,
16382 .unsol_event = alc663_m51va_unsol_event,
16383 .init_hook = alc663_m51va_inithook,
16384 },
16385 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016386 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016387 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
16388 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16389 .dac_nids = alc662_dac_nids,
16390 .dig_out_nid = ALC662_DIGOUT_NID,
16391 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16392 .channel_mode = alc662_3ST_2ch_modes,
16393 .input_mux = &alc662_eeepc_capture_source,
16394 .unsol_event = alc663_g71v_unsol_event,
16395 .init_hook = alc663_g71v_inithook,
16396 },
16397 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016398 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016399 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16400 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16401 .dac_nids = alc662_dac_nids,
16402 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16403 .channel_mode = alc662_3ST_2ch_modes,
16404 .input_mux = &alc663_m51va_capture_source,
16405 .unsol_event = alc663_m51va_unsol_event,
16406 .init_hook = alc663_m51va_inithook,
16407 },
16408 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016409 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016410 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
16411 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16412 .dac_nids = alc662_dac_nids,
16413 .dig_out_nid = ALC662_DIGOUT_NID,
16414 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16415 .channel_mode = alc662_3ST_6ch_modes,
16416 .input_mux = &alc663_capture_source,
16417 .unsol_event = alc663_g50v_unsol_event,
16418 .init_hook = alc663_g50v_inithook,
16419 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016420 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016421 .mixers = { alc663_m51va_mixer },
16422 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016423 .init_verbs = { alc662_init_verbs,
16424 alc663_21jd_amic_init_verbs },
16425 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16426 .hp_nid = 0x03,
16427 .dac_nids = alc662_dac_nids,
16428 .dig_out_nid = ALC662_DIGOUT_NID,
16429 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16430 .channel_mode = alc662_3ST_2ch_modes,
16431 .input_mux = &alc662_eeepc_capture_source,
16432 .unsol_event = alc663_mode1_unsol_event,
16433 .init_hook = alc663_mode1_inithook,
16434 },
16435 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016436 .mixers = { alc662_1bjd_mixer },
16437 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016438 .init_verbs = { alc662_init_verbs,
16439 alc662_1bjd_amic_init_verbs },
16440 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16441 .dac_nids = alc662_dac_nids,
16442 .dig_out_nid = ALC662_DIGOUT_NID,
16443 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16444 .channel_mode = alc662_3ST_2ch_modes,
16445 .input_mux = &alc662_eeepc_capture_source,
16446 .unsol_event = alc662_mode2_unsol_event,
16447 .init_hook = alc662_mode2_inithook,
16448 },
16449 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016450 .mixers = { alc663_two_hp_m1_mixer },
16451 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016452 .init_verbs = { alc662_init_verbs,
16453 alc663_two_hp_amic_m1_init_verbs },
16454 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16455 .hp_nid = 0x03,
16456 .dac_nids = alc662_dac_nids,
16457 .dig_out_nid = ALC662_DIGOUT_NID,
16458 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16459 .channel_mode = alc662_3ST_2ch_modes,
16460 .input_mux = &alc662_eeepc_capture_source,
16461 .unsol_event = alc663_mode3_unsol_event,
16462 .init_hook = alc663_mode3_inithook,
16463 },
16464 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016465 .mixers = { alc663_asus_21jd_clfe_mixer },
16466 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016467 .init_verbs = { alc662_init_verbs,
16468 alc663_21jd_amic_init_verbs},
16469 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16470 .hp_nid = 0x03,
16471 .dac_nids = alc662_dac_nids,
16472 .dig_out_nid = ALC662_DIGOUT_NID,
16473 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16474 .channel_mode = alc662_3ST_2ch_modes,
16475 .input_mux = &alc662_eeepc_capture_source,
16476 .unsol_event = alc663_mode4_unsol_event,
16477 .init_hook = alc663_mode4_inithook,
16478 },
16479 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016480 .mixers = { alc663_asus_15jd_clfe_mixer },
16481 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016482 .init_verbs = { alc662_init_verbs,
16483 alc663_15jd_amic_init_verbs },
16484 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16485 .hp_nid = 0x03,
16486 .dac_nids = alc662_dac_nids,
16487 .dig_out_nid = ALC662_DIGOUT_NID,
16488 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16489 .channel_mode = alc662_3ST_2ch_modes,
16490 .input_mux = &alc662_eeepc_capture_source,
16491 .unsol_event = alc663_mode5_unsol_event,
16492 .init_hook = alc663_mode5_inithook,
16493 },
16494 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016495 .mixers = { alc663_two_hp_m2_mixer },
16496 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016497 .init_verbs = { alc662_init_verbs,
16498 alc663_two_hp_amic_m2_init_verbs },
16499 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16500 .hp_nid = 0x03,
16501 .dac_nids = alc662_dac_nids,
16502 .dig_out_nid = ALC662_DIGOUT_NID,
16503 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16504 .channel_mode = alc662_3ST_2ch_modes,
16505 .input_mux = &alc662_eeepc_capture_source,
16506 .unsol_event = alc663_mode6_unsol_event,
16507 .init_hook = alc663_mode6_inithook,
16508 },
Kailang Yang622e84c2009-04-21 07:39:04 +020016509 [ALC272_DELL] = {
16510 .mixers = { alc663_m51va_mixer },
16511 .cap_mixer = alc272_auto_capture_mixer,
16512 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
16513 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
16514 .dac_nids = alc662_dac_nids,
16515 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16516 .adc_nids = alc272_adc_nids,
16517 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
16518 .capsrc_nids = alc272_capsrc_nids,
16519 .channel_mode = alc662_3ST_2ch_modes,
16520 .input_mux = &alc663_m51va_capture_source,
16521 .unsol_event = alc663_m51va_unsol_event,
16522 .init_hook = alc663_m51va_inithook,
16523 },
16524 [ALC272_DELL_ZM1] = {
16525 .mixers = { alc663_m51va_mixer },
16526 .cap_mixer = alc662_auto_capture_mixer,
16527 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
16528 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
16529 .dac_nids = alc662_dac_nids,
16530 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16531 .adc_nids = alc662_adc_nids,
16532 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
16533 .capsrc_nids = alc662_capsrc_nids,
16534 .channel_mode = alc662_3ST_2ch_modes,
16535 .input_mux = &alc663_m51va_capture_source,
16536 .unsol_event = alc663_m51va_unsol_event,
16537 .init_hook = alc663_m51va_inithook,
16538 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020016539 [ALC272_SAMSUNG_NC10] = {
16540 .mixers = { alc272_nc10_mixer },
16541 .init_verbs = { alc662_init_verbs,
16542 alc663_21jd_amic_init_verbs },
16543 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
16544 .dac_nids = alc272_dac_nids,
16545 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16546 .channel_mode = alc662_3ST_2ch_modes,
16547 .input_mux = &alc272_nc10_capture_source,
16548 .unsol_event = alc663_mode4_unsol_event,
16549 .init_hook = alc663_mode4_inithook,
16550 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016551};
16552
16553
16554/*
16555 * BIOS auto configuration
16556 */
16557
16558/* add playback controls from the parsed DAC table */
16559static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
16560 const struct auto_pin_cfg *cfg)
16561{
16562 char name[32];
16563 static const char *chname[4] = {
16564 "Front", "Surround", NULL /*CLFE*/, "Side"
16565 };
16566 hda_nid_t nid;
16567 int i, err;
16568
16569 for (i = 0; i < cfg->line_outs; i++) {
16570 if (!spec->multiout.dac_nids[i])
16571 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020016572 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016573 if (i == 2) {
16574 /* Center/LFE */
16575 err = add_control(spec, ALC_CTL_WIDGET_VOL,
16576 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016577 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
16578 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016579 if (err < 0)
16580 return err;
16581 err = add_control(spec, ALC_CTL_WIDGET_VOL,
16582 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016583 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
16584 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016585 if (err < 0)
16586 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016587 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016588 "Center Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016589 HDA_COMPOSE_AMP_VAL(0x0e, 1, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016590 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016591 if (err < 0)
16592 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016593 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016594 "LFE Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016595 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016596 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016597 if (err < 0)
16598 return err;
16599 } else {
16600 sprintf(name, "%s Playback Volume", chname[i]);
16601 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016602 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
16603 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016604 if (err < 0)
16605 return err;
16606 sprintf(name, "%s Playback Switch", chname[i]);
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016607 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16608 HDA_COMPOSE_AMP_VAL(alc880_idx_to_mixer(i),
16609 3, 0, HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016610 if (err < 0)
16611 return err;
16612 }
16613 }
16614 return 0;
16615}
16616
16617/* add playback controls for speaker and HP outputs */
16618static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
16619 const char *pfx)
16620{
16621 hda_nid_t nid;
16622 int err;
16623 char name[32];
16624
16625 if (!pin)
16626 return 0;
16627
Takashi Iwai24fb9172008-09-02 14:48:20 +020016628 if (pin == 0x17) {
16629 /* ALC663 has a mono output pin on 0x17 */
16630 sprintf(name, "%s Playback Switch", pfx);
16631 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16632 HDA_COMPOSE_AMP_VAL(pin, 2, 0, HDA_OUTPUT));
16633 return err;
16634 }
16635
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016636 if (alc880_is_fixed_pin(pin)) {
16637 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai939778a2009-02-05 15:57:55 +010016638 /* printk(KERN_DEBUG "DAC nid=%x\n",nid); */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016639 /* specify the DAC as the extra output */
16640 if (!spec->multiout.hp_nid)
16641 spec->multiout.hp_nid = nid;
16642 else
16643 spec->multiout.extra_out_nid[0] = nid;
16644 /* control HP volume/switch on the output mixer amp */
16645 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16646 sprintf(name, "%s Playback Volume", pfx);
16647 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
16648 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
16649 if (err < 0)
16650 return err;
16651 sprintf(name, "%s Playback Switch", pfx);
16652 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
16653 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
16654 if (err < 0)
16655 return err;
16656 } else if (alc880_is_multi_pin(pin)) {
16657 /* set manual connection */
16658 /* we have only a switch on HP-out PIN */
16659 sprintf(name, "%s Playback Switch", pfx);
16660 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16661 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
16662 if (err < 0)
16663 return err;
16664 }
16665 return 0;
16666}
16667
Takashi Iwai2d864c42009-03-20 12:52:47 +010016668/* return the index of the src widget from the connection list of the nid.
16669 * return -1 if not found
16670 */
16671static int alc662_input_pin_idx(struct hda_codec *codec, hda_nid_t nid,
16672 hda_nid_t src)
16673{
16674 hda_nid_t conn_list[HDA_MAX_CONNECTIONS];
16675 int i, conns;
16676
16677 conns = snd_hda_get_connections(codec, nid, conn_list,
16678 ARRAY_SIZE(conn_list));
16679 if (conns < 0)
16680 return -1;
16681 for (i = 0; i < conns; i++)
16682 if (conn_list[i] == src)
16683 return i;
16684 return -1;
16685}
16686
16687static int alc662_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
16688{
Takashi Iwai1327a322009-03-23 13:07:47 +010016689 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai2d864c42009-03-20 12:52:47 +010016690 return (pincap & AC_PINCAP_IN) != 0;
16691}
16692
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016693/* create playback/capture controls for input pins */
Takashi Iwai2d864c42009-03-20 12:52:47 +010016694static int alc662_auto_create_analog_input_ctls(struct hda_codec *codec,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016695 const struct auto_pin_cfg *cfg)
16696{
Takashi Iwai2d864c42009-03-20 12:52:47 +010016697 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016698 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016699 int i, err, idx;
16700
16701 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai2d864c42009-03-20 12:52:47 +010016702 if (alc662_is_input_pin(codec, cfg->input_pins[i])) {
16703 idx = alc662_input_pin_idx(codec, 0x0b,
16704 cfg->input_pins[i]);
16705 if (idx >= 0) {
16706 err = new_analog_input(spec, cfg->input_pins[i],
16707 auto_pin_cfg_labels[i],
16708 idx, 0x0b);
16709 if (err < 0)
16710 return err;
16711 }
16712 idx = alc662_input_pin_idx(codec, 0x22,
16713 cfg->input_pins[i]);
16714 if (idx >= 0) {
16715 imux->items[imux->num_items].label =
16716 auto_pin_cfg_labels[i];
16717 imux->items[imux->num_items].index = idx;
16718 imux->num_items++;
16719 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016720 }
16721 }
16722 return 0;
16723}
16724
16725static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
16726 hda_nid_t nid, int pin_type,
16727 int dac_idx)
16728{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016729 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016730 /* need the manual connection? */
16731 if (alc880_is_multi_pin(nid)) {
16732 struct alc_spec *spec = codec->spec;
16733 int idx = alc880_multi_pin_idx(nid);
16734 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
16735 AC_VERB_SET_CONNECT_SEL,
16736 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
16737 }
16738}
16739
16740static void alc662_auto_init_multi_out(struct hda_codec *codec)
16741{
16742 struct alc_spec *spec = codec->spec;
16743 int i;
16744
16745 for (i = 0; i <= HDA_SIDE; i++) {
16746 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016747 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016748 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016749 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016750 i);
16751 }
16752}
16753
16754static void alc662_auto_init_hp_out(struct hda_codec *codec)
16755{
16756 struct alc_spec *spec = codec->spec;
16757 hda_nid_t pin;
16758
16759 pin = spec->autocfg.hp_pins[0];
16760 if (pin) /* connect to front */
16761 /* use dac 0 */
16762 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016763 pin = spec->autocfg.speaker_pins[0];
16764 if (pin)
16765 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016766}
16767
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016768#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
16769
16770static void alc662_auto_init_analog_input(struct hda_codec *codec)
16771{
16772 struct alc_spec *spec = codec->spec;
16773 int i;
16774
16775 for (i = 0; i < AUTO_PIN_LAST; i++) {
16776 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai2d864c42009-03-20 12:52:47 +010016777 if (alc662_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010016778 alc_set_input_pin(codec, nid, i);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010016779 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010016780 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016781 snd_hda_codec_write(codec, nid, 0,
16782 AC_VERB_SET_AMP_GAIN_MUTE,
16783 AMP_OUT_MUTE);
16784 }
16785 }
16786}
16787
Takashi Iwaif511b012008-08-15 16:46:42 +020016788#define alc662_auto_init_input_src alc882_auto_init_input_src
16789
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016790static int alc662_parse_auto_config(struct hda_codec *codec)
16791{
16792 struct alc_spec *spec = codec->spec;
16793 int err;
16794 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
16795
16796 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
16797 alc662_ignore);
16798 if (err < 0)
16799 return err;
16800 if (!spec->autocfg.line_outs)
16801 return 0; /* can't find valid BIOS pin config */
16802
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016803 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
16804 if (err < 0)
16805 return err;
16806 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
16807 if (err < 0)
16808 return err;
16809 err = alc662_auto_create_extra_out(spec,
16810 spec->autocfg.speaker_pins[0],
16811 "Speaker");
16812 if (err < 0)
16813 return err;
16814 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
16815 "Headphone");
16816 if (err < 0)
16817 return err;
Takashi Iwai2d864c42009-03-20 12:52:47 +010016818 err = alc662_auto_create_analog_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016819 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016820 return err;
16821
16822 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
16823
Takashi Iwai0852d7a2009-02-11 11:35:15 +010016824 if (spec->autocfg.dig_outs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016825 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
16826
Takashi Iwai603c4012008-07-30 15:01:44 +020016827 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016828 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016829
16830 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016831 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020016832
Takashi Iwaid88897e2008-10-31 15:01:37 +010016833 add_verb(spec, alc662_auto_init_verbs);
Takashi Iwai24fb9172008-09-02 14:48:20 +020016834 if (codec->vendor_id == 0x10ec0663)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016835 add_verb(spec, alc663_auto_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020016836
16837 err = alc_auto_add_mic_boost(codec);
16838 if (err < 0)
16839 return err;
16840
Takashi Iwai4a79ba32009-04-22 16:31:35 +020016841 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
16842
Takashi Iwai8c87286f2007-06-19 12:11:16 +020016843 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016844}
16845
16846/* additional initialization for auto-configuration model */
16847static void alc662_auto_init(struct hda_codec *codec)
16848{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016849 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016850 alc662_auto_init_multi_out(codec);
16851 alc662_auto_init_hp_out(codec);
16852 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020016853 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016854 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020016855 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016856}
16857
16858static int patch_alc662(struct hda_codec *codec)
16859{
16860 struct alc_spec *spec;
16861 int err, board_config;
16862
16863 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
16864 if (!spec)
16865 return -ENOMEM;
16866
16867 codec->spec = spec;
16868
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020016869 alc_fix_pll_init(codec, 0x20, 0x04, 15);
16870
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016871 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
16872 alc662_models,
16873 alc662_cfg_tbl);
16874 if (board_config < 0) {
16875 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
16876 "trying auto-probe from BIOS...\n");
16877 board_config = ALC662_AUTO;
16878 }
16879
16880 if (board_config == ALC662_AUTO) {
16881 /* automatic parse from the BIOS config */
16882 err = alc662_parse_auto_config(codec);
16883 if (err < 0) {
16884 alc_free(codec);
16885 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020016886 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016887 printk(KERN_INFO
16888 "hda_codec: Cannot set up configuration "
16889 "from BIOS. Using base mode...\n");
16890 board_config = ALC662_3ST_2ch_DIG;
16891 }
16892 }
16893
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090016894 err = snd_hda_attach_beep_device(codec, 0x1);
16895 if (err < 0) {
16896 alc_free(codec);
16897 return err;
16898 }
16899
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016900 if (board_config != ALC662_AUTO)
16901 setup_preset(spec, &alc662_presets[board_config]);
16902
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016903 spec->stream_analog_playback = &alc662_pcm_analog_playback;
16904 spec->stream_analog_capture = &alc662_pcm_analog_capture;
16905
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016906 spec->stream_digital_playback = &alc662_pcm_digital_playback;
16907 spec->stream_digital_capture = &alc662_pcm_digital_capture;
16908
Takashi Iwaie1406342008-02-11 18:32:32 +010016909 spec->adc_nids = alc662_adc_nids;
16910 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
16911 spec->capsrc_nids = alc662_capsrc_nids;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016912 spec->capture_style = CAPT_MIX;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016913
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016914 if (!spec->cap_mixer)
16915 set_capture_mixer(spec);
Takashi Iwaib9591442009-03-16 15:25:00 +010016916 if (codec->vendor_id == 0x10ec0662)
16917 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
16918 else
16919 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016920
Takashi Iwai2134ea42008-01-10 16:53:55 +010016921 spec->vmaster_nid = 0x02;
16922
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016923 codec->patch_ops = alc_patch_ops;
16924 if (board_config == ALC662_AUTO)
16925 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020016926#ifdef CONFIG_SND_HDA_POWER_SAVE
16927 if (!spec->loopback.amplist)
16928 spec->loopback.amplist = alc662_loopbacks;
16929#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010016930 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016931
16932 return 0;
16933}
16934
16935/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070016936 * patch entries
16937 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010016938static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070016939 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010016940 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016941 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020016942 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016943 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020016944 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016945 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016946 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016947 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
16948 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
16949 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016950 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
16951 .patch = patch_alc883 },
16952 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
16953 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016954 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016955 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070016956 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016957 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Clive Messer669faba2008-09-30 15:49:13 +020016958 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
16959 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Takashi Iwaicb308f92008-04-16 14:13:29 +020016960 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai7943a8a2008-04-16 17:29:09 +020016961 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Kailang Yangdf694da2005-12-05 19:42:22 +010016962 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Kailang Yanga385a522008-10-15 11:20:21 +020016963 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc883 },
Kailang Yang44426082008-10-15 11:18:05 +020016964 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
16965 .patch = patch_alc883 },
Wu Fengguang3fea2cb2008-12-26 12:20:43 +080016966 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016967 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070016968 {} /* terminator */
16969};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010016970
16971MODULE_ALIAS("snd-hda-codec-id:10ec*");
16972
16973MODULE_LICENSE("GPL");
16974MODULE_DESCRIPTION("Realtek HD-audio codec");
16975
16976static struct hda_codec_preset_list realtek_list = {
16977 .preset = snd_hda_preset_realtek,
16978 .owner = THIS_MODULE,
16979};
16980
16981static int __init patch_realtek_init(void)
16982{
16983 return snd_hda_add_codec_preset(&realtek_list);
16984}
16985
16986static void __exit patch_realtek_exit(void)
16987{
16988 snd_hda_delete_codec_preset(&realtek_list);
16989}
16990
16991module_init(patch_realtek_init)
16992module_exit(patch_realtek_exit)