blob: 28a587353b1156f417d89384eb89ef0584b02c00 [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,
David Heidelberger64a8be72009-06-08 16:15:18 +0200223 ALC883_TARGA_8ch_DIG,
Vladimir Avdoninbab282b2006-08-22 13:31:58 +0200224 ALC883_ACER,
Tobin Davis2880a8672007-08-07 11:50:26 +0200225 ALC883_ACER_ASPIRE,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +0800226 ALC888_ACER_ASPIRE_4930G,
Tony Vroond2fd4b02009-06-21 00:40:10 +0100227 ALC888_ACER_ASPIRE_6530G,
Hector Martin3b315d72009-06-02 10:54:19 +0200228 ALC888_ACER_ASPIRE_8930G,
Tobin Davisc07584c2006-10-13 12:32:16 +0200229 ALC883_MEDION,
Kailang Yangea1fb292008-08-26 12:58:38 +0200230 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100231 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200232 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200233 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200234 ALC888_LENOVO_MS7195_DIG,
Kailang Yange2757d52008-08-26 13:17:46 +0200235 ALC888_LENOVO_SKY,
Kailang Yangea1fb292008-08-26 12:58:38 +0200236 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200237 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100238 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100239 ALC883_MITAC,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100240 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100241 ALC883_FUJITSU_PI2515,
Vincent Petryef8ef5f2008-11-23 11:31:41 +0800242 ALC888_FUJITSU_XA3530,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200243 ALC883_3ST_6ch_INTEL,
Kailang Yange2757d52008-08-26 13:17:46 +0200244 ALC888_ASUS_M90V,
245 ALC888_ASUS_EEE1601,
Torben Schulzeb4c41d2009-05-18 15:02:35 +0200246 ALC889A_MB31,
Wu Fengguang3ab90932008-11-17 09:51:09 +0100247 ALC1200_ASUS_P5Q,
Guido Günther3e1647c2009-06-05 00:47:26 +0200248 ALC883_SONY_VAIO_TT,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200249 ALC883_AUTO,
250 ALC883_MODEL_LAST,
251};
252
Kailang Yangdf694da2005-12-05 19:42:22 +0100253/* for GPIO Poll */
254#define GPIO_MASK 0x03
255
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200256/* extra amp-initialization sequence types */
257enum {
258 ALC_INIT_NONE,
259 ALC_INIT_DEFAULT,
260 ALC_INIT_GPIO1,
261 ALC_INIT_GPIO2,
262 ALC_INIT_GPIO3,
263};
264
Linus Torvalds1da177e2005-04-16 15:20:36 -0700265struct alc_spec {
266 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100267 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700268 unsigned int num_mixers;
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100269 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100270 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700271
Kailang Yangdf694da2005-12-05 19:42:22 +0100272 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200273 * don't forget NULL
274 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200275 */
276 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700277
Takashi Iwai812a2cc2009-05-16 10:00:49 +0200278 char stream_name_analog[16]; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700279 struct hda_pcm_stream *stream_analog_playback;
280 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100281 struct hda_pcm_stream *stream_analog_alt_playback;
282 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700283
Takashi Iwai812a2cc2009-05-16 10:00:49 +0200284 char stream_name_digital[16]; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700285 struct hda_pcm_stream *stream_digital_playback;
286 struct hda_pcm_stream *stream_digital_capture;
287
288 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200289 struct hda_multi_out multiout; /* playback set-up
290 * max_channels, dacs must be set
291 * dig_out_nid and hp_nid are optional
292 */
Takashi Iwai63300792008-01-24 15:31:36 +0100293 hda_nid_t alt_dac_nid;
Takashi Iwai6a05ac42009-02-13 11:19:09 +0100294 hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */
Takashi Iwai8c441982009-01-20 18:30:20 +0100295 int dig_out_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700296
297 /* capture */
298 unsigned int num_adc_nids;
299 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100300 hda_nid_t *capsrc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200301 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700302
303 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200304 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305 const struct hda_input_mux *input_mux;
306 unsigned int cur_mux[3];
307
308 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100309 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700310 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200311 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200312 int const_channel_count;
313 int ext_channel_count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700314
315 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100316 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200317
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200318 /* dynamic controls, init_verbs and input_mux */
319 struct auto_pin_cfg autocfg;
Takashi Iwai603c4012008-07-30 15:01:44 +0200320 struct snd_array kctls;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200321 struct hda_input_mux private_imux[3];
Takashi Iwai41923e42007-10-22 17:20:10 +0200322 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100323
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100324 /* hooks */
325 void (*init_hook)(struct hda_codec *codec);
326 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
327
Takashi Iwai834be882006-03-01 14:16:17 +0100328 /* for pin sensing */
329 unsigned int sense_updated: 1;
330 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100331 unsigned int master_sw: 1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200332
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100333 /* other flags */
334 unsigned int no_analog :1; /* digital I/O only */
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200335 int init_amp;
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100336
Takashi Iwai2134ea42008-01-10 16:53:55 +0100337 /* for virtual master */
338 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200339#ifdef CONFIG_SND_HDA_POWER_SAVE
340 struct hda_loopback_check loopback;
341#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200342
343 /* for PLL fix */
344 hda_nid_t pll_nid;
345 unsigned int pll_coef_idx, pll_coef_bit;
Kailang Yangdf694da2005-12-05 19:42:22 +0100346};
347
348/*
349 * configuration template - to be copied to the spec instance
350 */
351struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200352 struct snd_kcontrol_new *mixers[5]; /* should be identical size
353 * with spec
354 */
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100355 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Kailang Yangdf694da2005-12-05 19:42:22 +0100356 const struct hda_verb *init_verbs[5];
357 unsigned int num_dacs;
358 hda_nid_t *dac_nids;
359 hda_nid_t dig_out_nid; /* optional */
360 hda_nid_t hp_nid; /* optional */
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800361 hda_nid_t *slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100362 unsigned int num_adc_nids;
363 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100364 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100365 hda_nid_t dig_in_nid;
366 unsigned int num_channel_mode;
367 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200368 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200369 int const_channel_count;
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];
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200415 unsigned int type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700416
Takashi Iwaicd896c32008-11-18 12:36:33 +0100417 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
418 imux = &spec->input_mux[mux_idx];
419
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200420 type = (get_wcaps(codec, nid) & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
421 if (type == AC_WID_AUD_MIX) {
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100422 /* Matrix-mixer style (e.g. ALC882) */
423 unsigned int *cur_val = &spec->cur_mux[adc_idx];
424 unsigned int i, idx;
425
426 idx = ucontrol->value.enumerated.item[0];
427 if (idx >= imux->num_items)
428 idx = imux->num_items - 1;
429 if (*cur_val == idx)
430 return 0;
431 for (i = 0; i < imux->num_items; i++) {
432 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
433 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
434 imux->items[i].index,
435 HDA_AMP_MUTE, v);
436 }
437 *cur_val = idx;
438 return 1;
439 } else {
440 /* MUX style (e.g. ALC880) */
Takashi Iwaicd896c32008-11-18 12:36:33 +0100441 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100442 &spec->cur_mux[adc_idx]);
443 }
444}
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200445
Linus Torvalds1da177e2005-04-16 15:20:36 -0700446/*
447 * channel mode setting
448 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200449static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
450 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700451{
452 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
453 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100454 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
455 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700456}
457
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200458static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
459 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700460{
461 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
462 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100463 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200464 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200465 spec->ext_channel_count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700466}
467
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200468static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
469 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700470{
471 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
472 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200473 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
474 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200475 &spec->ext_channel_count);
476 if (err >= 0 && !spec->const_channel_count) {
477 spec->multiout.max_channels = spec->ext_channel_count;
478 if (spec->need_dac_fix)
479 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
480 }
Takashi Iwai4e195a72006-07-28 14:47:34 +0200481 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700482}
483
Linus Torvalds1da177e2005-04-16 15:20:36 -0700484/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100485 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200486 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100487 * being part of a format specifier. Maximum allowed length of a value is
488 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100489 *
490 * Note: some retasking pin complexes seem to ignore requests for input
491 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
492 * are requested. Therefore order this list so that this behaviour will not
493 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200494 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
495 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200496 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100497static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100498 "Mic 50pc bias", "Mic 80pc bias",
499 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100500};
501static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100502 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100503};
504/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200505 * in the pin being assumed to be exclusively an input or an output pin. In
506 * addition, "input" pins may or may not process the mic bias option
507 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
508 * accept requests for bias as of chip versions up to March 2006) and/or
509 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100510 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200511#define ALC_PIN_DIR_IN 0x00
512#define ALC_PIN_DIR_OUT 0x01
513#define ALC_PIN_DIR_INOUT 0x02
514#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
515#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100516
Kailang Yangea1fb292008-08-26 12:58:38 +0200517/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100518 * For each direction the minimum and maximum values are given.
519 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200520static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100521 { 0, 2 }, /* ALC_PIN_DIR_IN */
522 { 3, 4 }, /* ALC_PIN_DIR_OUT */
523 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200524 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
525 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100526};
527#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
528#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
529#define alc_pin_mode_n_items(_dir) \
530 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
531
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200532static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
533 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200534{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100535 unsigned int item_num = uinfo->value.enumerated.item;
536 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
537
538 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200539 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100540 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
541
542 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
543 item_num = alc_pin_mode_min(dir);
544 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200545 return 0;
546}
547
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200548static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
549 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200550{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100551 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200552 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
553 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100554 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200555 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200556 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
557 AC_VERB_GET_PIN_WIDGET_CONTROL,
558 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200559
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100560 /* Find enumerated value for current pinctl setting */
561 i = alc_pin_mode_min(dir);
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200562 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100563 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200564 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100565 return 0;
566}
567
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200568static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
569 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100570{
571 signed int change;
572 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
573 hda_nid_t nid = kcontrol->private_value & 0xffff;
574 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
575 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200576 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
577 AC_VERB_GET_PIN_WIDGET_CONTROL,
578 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100579
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200580 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100581 val = alc_pin_mode_min(dir);
582
583 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100584 if (change) {
585 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200586 snd_hda_codec_write_cache(codec, nid, 0,
587 AC_VERB_SET_PIN_WIDGET_CONTROL,
588 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100589
Kailang Yangea1fb292008-08-26 12:58:38 +0200590 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100591 * for the requested pin mode. Enum values of 2 or less are
592 * input modes.
593 *
594 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200595 * reduces noise slightly (particularly on input) so we'll
596 * do it. However, having both input and output buffers
597 * enabled simultaneously doesn't seem to be problematic if
598 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100599 */
600 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200601 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
602 HDA_AMP_MUTE, HDA_AMP_MUTE);
603 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
604 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100605 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200606 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
607 HDA_AMP_MUTE, HDA_AMP_MUTE);
608 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
609 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100610 }
611 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200612 return change;
613}
614
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100615#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200616 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100617 .info = alc_pin_mode_info, \
618 .get = alc_pin_mode_get, \
619 .put = alc_pin_mode_put, \
620 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100621
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100622/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
623 * together using a mask with more than one bit set. This control is
624 * currently used only by the ALC260 test model. At this stage they are not
625 * needed for any "production" models.
626 */
627#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200628#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200629
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200630static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
631 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100632{
633 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
634 hda_nid_t nid = kcontrol->private_value & 0xffff;
635 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
636 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200637 unsigned int val = snd_hda_codec_read(codec, nid, 0,
638 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100639
640 *valp = (val & mask) != 0;
641 return 0;
642}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200643static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
644 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100645{
646 signed int change;
647 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
648 hda_nid_t nid = kcontrol->private_value & 0xffff;
649 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
650 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200651 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
652 AC_VERB_GET_GPIO_DATA,
653 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100654
655 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200656 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
657 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100658 gpio_data &= ~mask;
659 else
660 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200661 snd_hda_codec_write_cache(codec, nid, 0,
662 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100663
664 return change;
665}
666#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
667 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
668 .info = alc_gpio_data_info, \
669 .get = alc_gpio_data_get, \
670 .put = alc_gpio_data_put, \
671 .private_value = nid | (mask<<16) }
672#endif /* CONFIG_SND_DEBUG */
673
Jonathan Woithe92621f12006-02-28 11:47:47 +0100674/* A switch control to allow the enabling of the digital IO pins on the
675 * ALC260. This is incredibly simplistic; the intention of this control is
676 * to provide something in the test model allowing digital outputs to be
677 * identified if present. If models are found which can utilise these
678 * outputs a more complete mixer control can be devised for those models if
679 * necessary.
680 */
681#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200682#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200683
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200684static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
685 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100686{
687 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
688 hda_nid_t nid = kcontrol->private_value & 0xffff;
689 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
690 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200691 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100692 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100693
694 *valp = (val & mask) != 0;
695 return 0;
696}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200697static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
698 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100699{
700 signed int change;
701 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
702 hda_nid_t nid = kcontrol->private_value & 0xffff;
703 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
704 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200705 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100706 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200707 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100708
709 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200710 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100711 if (val==0)
712 ctrl_data &= ~mask;
713 else
714 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200715 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
716 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100717
718 return change;
719}
720#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
721 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
722 .info = alc_spdif_ctrl_info, \
723 .get = alc_spdif_ctrl_get, \
724 .put = alc_spdif_ctrl_put, \
725 .private_value = nid | (mask<<16) }
726#endif /* CONFIG_SND_DEBUG */
727
Jonathan Woithef8225f62008-01-08 12:16:54 +0100728/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
729 * Again, this is only used in the ALC26x test models to help identify when
730 * the EAPD line must be asserted for features to work.
731 */
732#ifdef CONFIG_SND_DEBUG
733#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
734
735static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
736 struct snd_ctl_elem_value *ucontrol)
737{
738 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
739 hda_nid_t nid = kcontrol->private_value & 0xffff;
740 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
741 long *valp = ucontrol->value.integer.value;
742 unsigned int val = snd_hda_codec_read(codec, nid, 0,
743 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
744
745 *valp = (val & mask) != 0;
746 return 0;
747}
748
749static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
750 struct snd_ctl_elem_value *ucontrol)
751{
752 int change;
753 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
754 hda_nid_t nid = kcontrol->private_value & 0xffff;
755 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
756 long val = *ucontrol->value.integer.value;
757 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
758 AC_VERB_GET_EAPD_BTLENABLE,
759 0x00);
760
761 /* Set/unset the masked control bit(s) as needed */
762 change = (!val ? 0 : mask) != (ctrl_data & mask);
763 if (!val)
764 ctrl_data &= ~mask;
765 else
766 ctrl_data |= mask;
767 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
768 ctrl_data);
769
770 return change;
771}
772
773#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
774 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
775 .info = alc_eapd_ctrl_info, \
776 .get = alc_eapd_ctrl_get, \
777 .put = alc_eapd_ctrl_put, \
778 .private_value = nid | (mask<<16) }
779#endif /* CONFIG_SND_DEBUG */
780
Kailang Yangdf694da2005-12-05 19:42:22 +0100781/*
Takashi Iwai23f0c042009-02-26 13:03:58 +0100782 * set up the input pin config (depending on the given auto-pin type)
783 */
784static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
785 int auto_pin_type)
786{
787 unsigned int val = PIN_IN;
788
789 if (auto_pin_type <= AUTO_PIN_FRONT_MIC) {
790 unsigned int pincap;
Takashi Iwai1327a322009-03-23 13:07:47 +0100791 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai23f0c042009-02-26 13:03:58 +0100792 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
793 if (pincap & AC_PINCAP_VREF_80)
794 val = PIN_VREF80;
Takashi Iwai461c6c32009-05-25 08:06:02 +0200795 else if (pincap & AC_PINCAP_VREF_50)
796 val = PIN_VREF50;
797 else if (pincap & AC_PINCAP_VREF_100)
798 val = PIN_VREF100;
799 else if (pincap & AC_PINCAP_VREF_GRD)
800 val = PIN_VREFGRD;
Takashi Iwai23f0c042009-02-26 13:03:58 +0100801 }
802 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
803}
804
805/*
Takashi Iwaid88897e2008-10-31 15:01:37 +0100806 */
807static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
808{
809 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
810 return;
811 spec->mixers[spec->num_mixers++] = mix;
812}
813
814static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
815{
816 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
817 return;
818 spec->init_verbs[spec->num_init_verbs++] = verb;
819}
820
Takashi Iwaidaead532008-11-28 12:55:36 +0100821#ifdef CONFIG_PROC_FS
822/*
823 * hook for proc
824 */
825static void print_realtek_coef(struct snd_info_buffer *buffer,
826 struct hda_codec *codec, hda_nid_t nid)
827{
828 int coeff;
829
830 if (nid != 0x20)
831 return;
832 coeff = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PROC_COEF, 0);
833 snd_iprintf(buffer, " Processing Coefficient: 0x%02x\n", coeff);
834 coeff = snd_hda_codec_read(codec, nid, 0,
835 AC_VERB_GET_COEF_INDEX, 0);
836 snd_iprintf(buffer, " Coefficient Index: 0x%02x\n", coeff);
837}
838#else
839#define print_realtek_coef NULL
840#endif
841
Takashi Iwaid88897e2008-10-31 15:01:37 +0100842/*
Kailang Yangdf694da2005-12-05 19:42:22 +0100843 * set up from the preset table
844 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200845static void setup_preset(struct alc_spec *spec,
846 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100847{
848 int i;
849
850 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100851 add_mixer(spec, preset->mixers[i]);
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100852 spec->cap_mixer = preset->cap_mixer;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200853 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
854 i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100855 add_verb(spec, preset->init_verbs[i]);
Kailang Yangea1fb292008-08-26 12:58:38 +0200856
Kailang Yangdf694da2005-12-05 19:42:22 +0100857 spec->channel_mode = preset->channel_mode;
858 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200859 spec->need_dac_fix = preset->need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200860 spec->const_channel_count = preset->const_channel_count;
Kailang Yangdf694da2005-12-05 19:42:22 +0100861
Hector Martin3b315d72009-06-02 10:54:19 +0200862 if (preset->const_channel_count)
863 spec->multiout.max_channels = preset->const_channel_count;
864 else
865 spec->multiout.max_channels = spec->channel_mode[0].channels;
866 spec->ext_channel_count = spec->channel_mode[0].channels;
Kailang Yangdf694da2005-12-05 19:42:22 +0100867
868 spec->multiout.num_dacs = preset->num_dacs;
869 spec->multiout.dac_nids = preset->dac_nids;
870 spec->multiout.dig_out_nid = preset->dig_out_nid;
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800871 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100872 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200873
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200874 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200875 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200876 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100877 spec->input_mux = preset->input_mux;
878
879 spec->num_adc_nids = preset->num_adc_nids;
880 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100881 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100882 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100883
884 spec->unsol_event = preset->unsol_event;
885 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200886#ifdef CONFIG_SND_HDA_POWER_SAVE
887 spec->loopback.amplist = preset->loopbacks;
888#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100889}
890
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200891/* Enable GPIO mask and set output */
892static struct hda_verb alc_gpio1_init_verbs[] = {
893 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
894 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
895 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
896 { }
897};
898
899static struct hda_verb alc_gpio2_init_verbs[] = {
900 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
901 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
902 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
903 { }
904};
905
Kailang Yangbdd148a2007-05-08 15:19:08 +0200906static struct hda_verb alc_gpio3_init_verbs[] = {
907 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
908 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
909 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
910 { }
911};
912
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200913/*
914 * Fix hardware PLL issue
915 * On some codecs, the analog PLL gating control must be off while
916 * the default value is 1.
917 */
918static void alc_fix_pll(struct hda_codec *codec)
919{
920 struct alc_spec *spec = codec->spec;
921 unsigned int val;
922
923 if (!spec->pll_nid)
924 return;
925 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
926 spec->pll_coef_idx);
927 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
928 AC_VERB_GET_PROC_COEF, 0);
929 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
930 spec->pll_coef_idx);
931 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
932 val & ~(1 << spec->pll_coef_bit));
933}
934
935static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
936 unsigned int coef_idx, unsigned int coef_bit)
937{
938 struct alc_spec *spec = codec->spec;
939 spec->pll_nid = nid;
940 spec->pll_coef_idx = coef_idx;
941 spec->pll_coef_bit = coef_bit;
942 alc_fix_pll(codec);
943}
944
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200945static void alc_automute_pin(struct hda_codec *codec)
Kailang Yangc9b58002007-10-16 14:30:01 +0200946{
947 struct alc_spec *spec = codec->spec;
Kailang Yangc9b58002007-10-16 14:30:01 +0200948 unsigned int present;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200949 unsigned int nid = spec->autocfg.hp_pins[0];
950 int i;
Kailang Yangc9b58002007-10-16 14:30:01 +0200951
952 /* need to execute and sync at first */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200953 snd_hda_codec_read(codec, nid, 0, AC_VERB_SET_PIN_SENSE, 0);
954 present = snd_hda_codec_read(codec, nid, 0,
Kailang Yangc9b58002007-10-16 14:30:01 +0200955 AC_VERB_GET_PIN_SENSE, 0);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200956 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
957 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
958 nid = spec->autocfg.speaker_pins[i];
959 if (!nid)
960 break;
961 snd_hda_codec_write(codec, nid, 0,
962 AC_VERB_SET_PIN_WIDGET_CONTROL,
963 spec->jack_present ? 0 : PIN_OUT);
964 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200965}
966
Sasha Alexandrdef319f2009-06-16 16:00:15 -0400967#if 0 /* it's broken in some cases -- temporarily disabled */
Kailang Yang7fb0d782008-10-15 11:12:35 +0200968static void alc_mic_automute(struct hda_codec *codec)
969{
970 struct alc_spec *spec = codec->spec;
971 unsigned int present;
972 unsigned int mic_nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
973 unsigned int fmic_nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
974 unsigned int mix_nid = spec->capsrc_nids[0];
975 unsigned int capsrc_idx_mic, capsrc_idx_fmic;
976
977 capsrc_idx_mic = mic_nid - 0x18;
978 capsrc_idx_fmic = fmic_nid - 0x18;
979 present = snd_hda_codec_read(codec, mic_nid, 0,
980 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
981 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
982 0x7000 | (capsrc_idx_mic << 8) | (present ? 0 : 0x80));
983 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
984 0x7000 | (capsrc_idx_fmic << 8) | (present ? 0x80 : 0));
985 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, capsrc_idx_fmic,
986 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
987}
Takashi Iwai4605b712008-10-31 14:18:24 +0100988#else
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100989#define alc_mic_automute(codec) do {} while(0) /* NOP */
Takashi Iwai4605b712008-10-31 14:18:24 +0100990#endif /* disabled */
Kailang Yang7fb0d782008-10-15 11:12:35 +0200991
Kailang Yangc9b58002007-10-16 14:30:01 +0200992/* unsolicited event for HP jack sensing */
993static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
994{
995 if (codec->vendor_id == 0x10ec0880)
996 res >>= 28;
997 else
998 res >>= 26;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200999 switch (res) {
1000 case ALC880_HP_EVENT:
1001 alc_automute_pin(codec);
1002 break;
1003 case ALC880_MIC_EVENT:
Kailang Yang7fb0d782008-10-15 11:12:35 +02001004 alc_mic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001005 break;
1006 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001007}
1008
1009static void alc_inithook(struct hda_codec *codec)
1010{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001011 alc_automute_pin(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +02001012 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001013}
1014
Kailang Yangf9423e72008-05-27 12:32:25 +02001015/* additional initialization for ALC888 variants */
1016static void alc888_coef_init(struct hda_codec *codec)
1017{
1018 unsigned int tmp;
1019
1020 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1021 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1022 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
Takashi Iwai37db6232009-03-05 09:40:16 +01001023 if ((tmp & 0xf0) == 0x20)
Kailang Yangf9423e72008-05-27 12:32:25 +02001024 /* alc888S-VC */
1025 snd_hda_codec_read(codec, 0x20, 0,
1026 AC_VERB_SET_PROC_COEF, 0x830);
1027 else
1028 /* alc888-VB */
1029 snd_hda_codec_read(codec, 0x20, 0,
1030 AC_VERB_SET_PROC_COEF, 0x3030);
1031}
1032
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001033static void alc_auto_init_amp(struct hda_codec *codec, int type)
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001034{
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001035 unsigned int tmp;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001036
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001037 switch (type) {
1038 case ALC_INIT_GPIO1:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001039 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1040 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001041 case ALC_INIT_GPIO2:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001042 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1043 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001044 case ALC_INIT_GPIO3:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001045 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1046 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001047 case ALC_INIT_DEFAULT:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001048 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001049 case 0x10ec0260:
1050 snd_hda_codec_write(codec, 0x0f, 0,
1051 AC_VERB_SET_EAPD_BTLENABLE, 2);
1052 snd_hda_codec_write(codec, 0x10, 0,
1053 AC_VERB_SET_EAPD_BTLENABLE, 2);
1054 break;
1055 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001056 case 0x10ec0267:
1057 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001058 case 0x10ec0269:
Takashi Iwaic6e8f2d2009-02-06 12:45:52 +01001059 case 0x10ec0272:
Kailang Yangf9423e72008-05-27 12:32:25 +02001060 case 0x10ec0660:
1061 case 0x10ec0662:
1062 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001063 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001064 case 0x10ec0889:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001065 snd_hda_codec_write(codec, 0x14, 0,
1066 AC_VERB_SET_EAPD_BTLENABLE, 2);
1067 snd_hda_codec_write(codec, 0x15, 0,
1068 AC_VERB_SET_EAPD_BTLENABLE, 2);
Kailang Yangc9b58002007-10-16 14:30:01 +02001069 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001070 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001071 switch (codec->vendor_id) {
1072 case 0x10ec0260:
1073 snd_hda_codec_write(codec, 0x1a, 0,
1074 AC_VERB_SET_COEF_INDEX, 7);
1075 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1076 AC_VERB_GET_PROC_COEF, 0);
1077 snd_hda_codec_write(codec, 0x1a, 0,
1078 AC_VERB_SET_COEF_INDEX, 7);
1079 snd_hda_codec_write(codec, 0x1a, 0,
1080 AC_VERB_SET_PROC_COEF,
1081 tmp | 0x2010);
1082 break;
1083 case 0x10ec0262:
1084 case 0x10ec0880:
1085 case 0x10ec0882:
1086 case 0x10ec0883:
1087 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001088 case 0x10ec0887:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001089 case 0x10ec0889:
Kailang Yangc9b58002007-10-16 14:30:01 +02001090 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 | 0x2010);
1099 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001100 case 0x10ec0888:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001101 alc888_coef_init(codec);
Kailang Yangf9423e72008-05-27 12:32:25 +02001102 break;
Kailang Yangc9b58002007-10-16 14:30:01 +02001103 case 0x10ec0267:
1104 case 0x10ec0268:
1105 snd_hda_codec_write(codec, 0x20, 0,
1106 AC_VERB_SET_COEF_INDEX, 7);
1107 tmp = snd_hda_codec_read(codec, 0x20, 0,
1108 AC_VERB_GET_PROC_COEF, 0);
1109 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001110 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001111 snd_hda_codec_write(codec, 0x20, 0,
1112 AC_VERB_SET_PROC_COEF,
1113 tmp | 0x3000);
1114 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001115 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001116 break;
1117 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001118}
Kailang Yangea1fb292008-08-26 12:58:38 +02001119
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001120static void alc_init_auto_hp(struct hda_codec *codec)
1121{
1122 struct alc_spec *spec = codec->spec;
1123
1124 if (!spec->autocfg.hp_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +02001125 return;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001126
Kailang Yangc9b58002007-10-16 14:30:01 +02001127 if (!spec->autocfg.speaker_pins[0]) {
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001128 if (spec->autocfg.line_out_pins[0] &&
1129 spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT)
Kailang Yangc9b58002007-10-16 14:30:01 +02001130 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +01001131 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +02001132 else
1133 return;
1134 }
1135
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001136 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1137 spec->autocfg.hp_pins[0]);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001138 snd_hda_codec_write_cache(codec, spec->autocfg.hp_pins[0], 0,
1139 AC_VERB_SET_UNSOLICITED_ENABLE,
1140 AC_USRSP_EN | ALC880_HP_EVENT);
1141 spec->unsol_event = alc_sku_unsol_event;
1142}
1143
1144/* check subsystem ID and set up device-specific initialization;
1145 * return 1 if initialized, 0 if invalid SSID
1146 */
1147/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1148 * 31 ~ 16 : Manufacture ID
1149 * 15 ~ 8 : SKU ID
1150 * 7 ~ 0 : Assembly ID
1151 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1152 */
1153static int alc_subsystem_id(struct hda_codec *codec,
1154 hda_nid_t porta, hda_nid_t porte,
1155 hda_nid_t portd)
1156{
1157 unsigned int ass, tmp, i;
1158 unsigned nid;
1159 struct alc_spec *spec = codec->spec;
1160
1161 ass = codec->subsystem_id & 0xffff;
1162 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1163 goto do_sku;
1164
1165 /* invalid SSID, check the special NID pin defcfg instead */
1166 /*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04001167 * 31~30 : port connectivity
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001168 * 29~21 : reserve
1169 * 20 : PCBEEP input
1170 * 19~16 : Check sum (15:1)
1171 * 15~1 : Custom
1172 * 0 : override
1173 */
1174 nid = 0x1d;
1175 if (codec->vendor_id == 0x10ec0260)
1176 nid = 0x17;
1177 ass = snd_hda_codec_get_pincfg(codec, nid);
1178 snd_printd("realtek: No valid SSID, "
1179 "checking pincfg 0x%08x for NID 0x%x\n",
Takashi Iwaicb6605c2009-04-28 13:03:19 +02001180 ass, nid);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001181 if (!(ass & 1) && !(ass & 0x100000))
1182 return 0;
1183 if ((ass >> 30) != 1) /* no physical connection */
1184 return 0;
1185
1186 /* check sum */
1187 tmp = 0;
1188 for (i = 1; i < 16; i++) {
1189 if ((ass >> i) & 1)
1190 tmp++;
1191 }
1192 if (((ass >> 16) & 0xf) != tmp)
1193 return 0;
1194do_sku:
1195 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1196 ass & 0xffff, codec->vendor_id);
1197 /*
1198 * 0 : override
1199 * 1 : Swap Jack
1200 * 2 : 0 --> Desktop, 1 --> Laptop
1201 * 3~5 : External Amplifier control
1202 * 7~6 : Reserved
1203 */
1204 tmp = (ass & 0x38) >> 3; /* external Amp control */
1205 switch (tmp) {
1206 case 1:
1207 spec->init_amp = ALC_INIT_GPIO1;
1208 break;
1209 case 3:
1210 spec->init_amp = ALC_INIT_GPIO2;
1211 break;
1212 case 7:
1213 spec->init_amp = ALC_INIT_GPIO3;
1214 break;
1215 case 5:
1216 spec->init_amp = ALC_INIT_DEFAULT;
1217 break;
1218 }
1219
1220 /* is laptop or Desktop and enable the function "Mute internal speaker
1221 * when the external headphone out jack is plugged"
1222 */
1223 if (!(ass & 0x8000))
1224 return 1;
1225 /*
1226 * 10~8 : Jack location
1227 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1228 * 14~13: Resvered
1229 * 15 : 1 --> enable the function "Mute internal speaker
1230 * when the external headphone out jack is plugged"
1231 */
Kailang Yangc9b58002007-10-16 14:30:01 +02001232 if (!spec->autocfg.hp_pins[0]) {
1233 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1234 if (tmp == 0)
1235 spec->autocfg.hp_pins[0] = porta;
1236 else if (tmp == 1)
1237 spec->autocfg.hp_pins[0] = porte;
1238 else if (tmp == 2)
1239 spec->autocfg.hp_pins[0] = portd;
1240 else
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001241 return 1;
Kailang Yangc9b58002007-10-16 14:30:01 +02001242 }
1243
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001244 alc_init_auto_hp(codec);
1245 return 1;
1246}
Kailang Yangea1fb292008-08-26 12:58:38 +02001247
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001248static void alc_ssid_check(struct hda_codec *codec,
1249 hda_nid_t porta, hda_nid_t porte, hda_nid_t portd)
1250{
1251 if (!alc_subsystem_id(codec, porta, porte, portd)) {
1252 struct alc_spec *spec = codec->spec;
1253 snd_printd("realtek: "
1254 "Enable default setup for auto mode as fallback\n");
1255 spec->init_amp = ALC_INIT_DEFAULT;
1256 alc_init_auto_hp(codec);
1257 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001258}
1259
Takashi Iwai41e41f12005-06-08 14:48:49 +02001260/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02001261 * Fix-up pin default configurations
1262 */
1263
1264struct alc_pincfg {
1265 hda_nid_t nid;
1266 u32 val;
1267};
1268
1269static void alc_fix_pincfg(struct hda_codec *codec,
1270 const struct snd_pci_quirk *quirk,
1271 const struct alc_pincfg **pinfix)
1272{
1273 const struct alc_pincfg *cfg;
1274
1275 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1276 if (!quirk)
1277 return;
1278
1279 cfg = pinfix[quirk->value];
Takashi Iwai0e8a21b2009-02-20 14:13:06 +01001280 for (; cfg->nid; cfg++)
1281 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
Takashi Iwaif95474e2007-07-10 00:47:43 +02001282}
1283
1284/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001285 * ALC888
1286 */
1287
1288/*
1289 * 2ch mode
1290 */
1291static struct hda_verb alc888_4ST_ch2_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 Line in */
1296 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1297 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1298/* Line-Out as Front */
1299 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1300 { } /* end */
1301};
1302
1303/*
1304 * 4ch mode
1305 */
1306static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1307/* Mic-in jack as mic in */
1308 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1309 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
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 Front */
1314 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1315 { } /* end */
1316};
1317
1318/*
1319 * 6ch mode
1320 */
1321static struct hda_verb alc888_4ST_ch6_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 CLFE (workaround because Mic-in is not loud enough) */
1329 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1330 { } /* end */
1331};
1332
1333/*
1334 * 8ch mode
1335 */
1336static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1337/* Mic-in jack as CLFE */
1338 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1339 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1340/* Line-in jack as Surround */
1341 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1342 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1343/* Line-Out as Side */
1344 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1345 { } /* end */
1346};
1347
1348static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1349 { 2, alc888_4ST_ch2_intel_init },
1350 { 4, alc888_4ST_ch4_intel_init },
1351 { 6, alc888_4ST_ch6_intel_init },
1352 { 8, alc888_4ST_ch8_intel_init },
1353};
1354
1355/*
1356 * ALC888 Fujitsu Siemens Amillo xa3530
1357 */
1358
1359static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1360/* Front Mic: set to PIN_IN (empty by default) */
1361 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1362/* Connect Internal HP to Front */
1363 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1364 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1365 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1366/* Connect Bass HP to Front */
1367 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1368 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1369 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1370/* Connect Line-Out side jack (SPDIF) to Side */
1371 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1372 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1373 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1374/* Connect Mic jack to CLFE */
1375 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1376 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1377 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1378/* Connect Line-in jack to Surround */
1379 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1380 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1381 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1382/* Connect HP out jack to Front */
1383 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1384 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1385 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1386/* Enable unsolicited event for HP jack and Line-out jack */
1387 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1388 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1389 {}
1390};
1391
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001392static void alc_automute_amp(struct hda_codec *codec)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001393{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001394 struct alc_spec *spec = codec->spec;
1395 unsigned int val, mute;
1396 hda_nid_t nid;
1397 int i;
1398
1399 spec->jack_present = 0;
1400 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1401 nid = spec->autocfg.hp_pins[i];
1402 if (!nid)
1403 break;
1404 val = snd_hda_codec_read(codec, nid, 0,
1405 AC_VERB_GET_PIN_SENSE, 0);
1406 if (val & AC_PINSENSE_PRESENCE) {
1407 spec->jack_present = 1;
1408 break;
1409 }
1410 }
1411
1412 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001413 /* Toggle internal speakers muting */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001414 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1415 nid = spec->autocfg.speaker_pins[i];
1416 if (!nid)
1417 break;
1418 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1419 HDA_AMP_MUTE, mute);
1420 }
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001421}
1422
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001423static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1424 unsigned int res)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001425{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001426 if (codec->vendor_id == 0x10ec0880)
1427 res >>= 28;
1428 else
1429 res >>= 26;
1430 if (res == ALC880_HP_EVENT)
1431 alc_automute_amp(codec);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001432}
1433
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001434static void alc888_fujitsu_xa3530_init_hook(struct hda_codec *codec)
1435{
1436 struct alc_spec *spec = codec->spec;
1437
1438 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1439 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1440 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1441 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
1442 alc_automute_amp(codec);
1443}
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001444
1445/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001446 * ALC888 Acer Aspire 4930G model
1447 */
1448
1449static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1450/* Front Mic: set to PIN_IN (empty by default) */
1451 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1452/* Unselect Front Mic by default in input mixer 3 */
1453 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001454/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001455 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1456/* Connect Internal HP to front */
1457 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1458 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1459 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1460/* Connect HP out to front */
1461 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1462 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1463 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1464 { }
1465};
1466
Hector Martin3b315d72009-06-02 10:54:19 +02001467/*
Tony Vroond2fd4b02009-06-21 00:40:10 +01001468 * ALC888 Acer Aspire 6530G model
1469 */
1470
1471static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
1472/* Bias voltage on for external mic port */
1473 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
1474/* Enable unsolicited event for HP jack */
1475 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1476/* Enable speaker output */
1477 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1478 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1479/* Enable headphone output */
1480 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
1481 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1482 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1483 { }
1484};
1485
1486/*
Hector Martin018df412009-06-04 00:13:40 +02001487 * ALC889 Acer Aspire 8930G model
Hector Martin3b315d72009-06-02 10:54:19 +02001488 */
1489
Hector Martin018df412009-06-04 00:13:40 +02001490static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
Hector Martin3b315d72009-06-02 10:54:19 +02001491/* Front Mic: set to PIN_IN (empty by default) */
1492 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1493/* Unselect Front Mic by default in input mixer 3 */
1494 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1495/* Enable unsolicited event for HP jack */
1496 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1497/* Connect Internal Front to Front */
1498 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1499 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1500 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1501/* Connect Internal Rear to Rear */
1502 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1503 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1504 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
1505/* Connect Internal CLFE to CLFE */
1506 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1507 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1508 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
1509/* Connect HP out to Front */
Hector Martin018df412009-06-04 00:13:40 +02001510 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
Hector Martin3b315d72009-06-02 10:54:19 +02001511 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1512 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1513/* Enable all DACs */
1514/* DAC DISABLE/MUTE 1? */
1515/* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
1516 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
1517 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1518/* DAC DISABLE/MUTE 2? */
1519/* some bit here disables the other DACs. Init=0x4900 */
1520 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
1521 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1522/* Enable amplifiers */
1523 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
1524 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
Hector Martin018df412009-06-04 00:13:40 +02001525/* DMIC fix
1526 * This laptop has a stereo digital microphone. The mics are only 1cm apart
1527 * which makes the stereo useless. However, either the mic or the ALC889
1528 * makes the signal become a difference/sum signal instead of standard
1529 * stereo, which is annoying. So instead we flip this bit which makes the
1530 * codec replicate the sum signal to both channels, turning it into a
1531 * normal mono mic.
1532 */
1533/* DMIC_CONTROL? Init value = 0x0001 */
1534 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
1535 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
Hector Martin3b315d72009-06-02 10:54:19 +02001536 { }
1537};
1538
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001539static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001540 /* Front mic only available on one ADC */
1541 {
1542 .num_items = 4,
1543 .items = {
1544 { "Mic", 0x0 },
1545 { "Line", 0x2 },
1546 { "CD", 0x4 },
1547 { "Front Mic", 0xb },
1548 },
1549 },
1550 {
1551 .num_items = 3,
1552 .items = {
1553 { "Mic", 0x0 },
1554 { "Line", 0x2 },
1555 { "CD", 0x4 },
1556 },
1557 }
1558};
1559
Tony Vroond2fd4b02009-06-21 00:40:10 +01001560static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
1561 /* Interal mic only available on one ADC */
1562 {
1563 .num_items = 3,
1564 .items = {
1565 { "Ext Mic", 0x0 },
1566 { "CD", 0x4 },
1567 { "Int Mic", 0xb },
1568 },
1569 },
1570 {
1571 .num_items = 2,
1572 .items = {
1573 { "Ext Mic", 0x0 },
1574 { "CD", 0x4 },
1575 },
1576 }
1577};
1578
Hector Martin018df412009-06-04 00:13:40 +02001579static struct hda_input_mux alc889_capture_sources[3] = {
1580 /* Digital mic only available on first "ADC" */
1581 {
1582 .num_items = 5,
1583 .items = {
1584 { "Mic", 0x0 },
1585 { "Line", 0x2 },
1586 { "CD", 0x4 },
1587 { "Front Mic", 0xb },
1588 { "Input Mix", 0xa },
1589 },
1590 },
1591 {
1592 .num_items = 4,
1593 .items = {
1594 { "Mic", 0x0 },
1595 { "Line", 0x2 },
1596 { "CD", 0x4 },
1597 { "Input Mix", 0xa },
1598 },
1599 },
1600 {
1601 .num_items = 4,
1602 .items = {
1603 { "Mic", 0x0 },
1604 { "Line", 0x2 },
1605 { "CD", 0x4 },
1606 { "Input Mix", 0xa },
1607 },
1608 }
1609};
1610
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001611static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001612 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1613 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1614 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1615 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1616 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1617 HDA_OUTPUT),
1618 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1619 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1620 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1621 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1622 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1623 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1624 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1625 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1626 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1627 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1628 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1629 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001630 { } /* end */
1631};
1632
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001633static void alc888_acer_aspire_4930g_init_hook(struct hda_codec *codec)
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001634{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001635 struct alc_spec *spec = codec->spec;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001636
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001637 spec->autocfg.hp_pins[0] = 0x15;
1638 spec->autocfg.speaker_pins[0] = 0x14;
1639 alc_automute_amp(codec);
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001640}
1641
Hector Martin018df412009-06-04 00:13:40 +02001642static void alc889_acer_aspire_8930g_init_hook(struct hda_codec *codec)
Hector Martin3b315d72009-06-02 10:54:19 +02001643{
1644 struct alc_spec *spec = codec->spec;
1645
1646 spec->autocfg.hp_pins[0] = 0x15;
1647 spec->autocfg.speaker_pins[0] = 0x14;
1648 spec->autocfg.speaker_pins[1] = 0x16;
1649 spec->autocfg.speaker_pins[2] = 0x1b;
1650 alc_automute_amp(codec);
1651}
1652
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001653/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001654 * ALC880 3-stack model
1655 *
1656 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001657 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1658 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07001659 */
1660
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001661static hda_nid_t alc880_dac_nids[4] = {
1662 /* front, rear, clfe, rear_surr */
1663 0x02, 0x05, 0x04, 0x03
1664};
1665
1666static hda_nid_t alc880_adc_nids[3] = {
1667 /* ADC0-2 */
1668 0x07, 0x08, 0x09,
1669};
1670
1671/* The datasheet says the node 0x07 is connected from inputs,
1672 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01001673 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07001674 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001675static hda_nid_t alc880_adc_nids_alt[2] = {
1676 /* ADC1-2 */
1677 0x08, 0x09,
1678};
1679
1680#define ALC880_DIGOUT_NID 0x06
1681#define ALC880_DIGIN_NID 0x0a
1682
1683static struct hda_input_mux alc880_capture_source = {
1684 .num_items = 4,
1685 .items = {
1686 { "Mic", 0x0 },
1687 { "Front Mic", 0x3 },
1688 { "Line", 0x2 },
1689 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001690 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001691};
1692
1693/* channel source setting (2/6 channel selection for 3-stack) */
1694/* 2ch mode */
1695static struct hda_verb alc880_threestack_ch2_init[] = {
1696 /* set line-in to input, mute it */
1697 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1698 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1699 /* set mic-in to input vref 80%, mute it */
1700 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1701 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001702 { } /* end */
1703};
1704
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001705/* 6ch mode */
1706static struct hda_verb alc880_threestack_ch6_init[] = {
1707 /* set line-in to output, unmute it */
1708 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1709 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1710 /* set mic-in to output, unmute it */
1711 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1712 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1713 { } /* end */
1714};
1715
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001716static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001717 { 2, alc880_threestack_ch2_init },
1718 { 6, alc880_threestack_ch6_init },
1719};
1720
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001721static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001722 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001723 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001724 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001725 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001726 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1727 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001728 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1729 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001730 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1731 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1732 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1733 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1734 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1735 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1736 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1737 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001738 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001739 {
1740 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1741 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001742 .info = alc_ch_mode_info,
1743 .get = alc_ch_mode_get,
1744 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001745 },
1746 { } /* end */
1747};
1748
1749/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001750static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1751 struct snd_ctl_elem_info *uinfo)
1752{
1753 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1754 struct alc_spec *spec = codec->spec;
1755 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001756
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001757 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001758 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1759 HDA_INPUT);
1760 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001761 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001762 return err;
1763}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001764
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001765static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1766 unsigned int size, unsigned int __user *tlv)
1767{
1768 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1769 struct alc_spec *spec = codec->spec;
1770 int err;
1771
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001772 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001773 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1774 HDA_INPUT);
1775 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001776 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001777 return err;
1778}
1779
1780typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1781 struct snd_ctl_elem_value *ucontrol);
1782
1783static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1784 struct snd_ctl_elem_value *ucontrol,
1785 getput_call_t func)
1786{
1787 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1788 struct alc_spec *spec = codec->spec;
1789 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1790 int err;
1791
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001792 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001793 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
1794 3, 0, HDA_INPUT);
1795 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001796 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001797 return err;
1798}
1799
1800static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
1801 struct snd_ctl_elem_value *ucontrol)
1802{
1803 return alc_cap_getput_caller(kcontrol, ucontrol,
1804 snd_hda_mixer_amp_volume_get);
1805}
1806
1807static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
1808 struct snd_ctl_elem_value *ucontrol)
1809{
1810 return alc_cap_getput_caller(kcontrol, ucontrol,
1811 snd_hda_mixer_amp_volume_put);
1812}
1813
1814/* capture mixer elements */
1815#define alc_cap_sw_info snd_ctl_boolean_stereo_info
1816
1817static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
1818 struct snd_ctl_elem_value *ucontrol)
1819{
1820 return alc_cap_getput_caller(kcontrol, ucontrol,
1821 snd_hda_mixer_amp_switch_get);
1822}
1823
1824static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
1825 struct snd_ctl_elem_value *ucontrol)
1826{
1827 return alc_cap_getput_caller(kcontrol, ucontrol,
1828 snd_hda_mixer_amp_switch_put);
1829}
1830
Takashi Iwaia23b6882009-03-23 15:21:36 +01001831#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001832 { \
1833 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1834 .name = "Capture Switch", \
1835 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1836 .count = num, \
1837 .info = alc_cap_sw_info, \
1838 .get = alc_cap_sw_get, \
1839 .put = alc_cap_sw_put, \
1840 }, \
1841 { \
1842 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1843 .name = "Capture Volume", \
1844 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1845 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1846 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
1847 .count = num, \
1848 .info = alc_cap_vol_info, \
1849 .get = alc_cap_vol_get, \
1850 .put = alc_cap_vol_put, \
1851 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01001852 }
1853
1854#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01001855 { \
1856 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1857 /* .name = "Capture Source", */ \
1858 .name = "Input Source", \
1859 .count = num, \
1860 .info = alc_mux_enum_info, \
1861 .get = alc_mux_enum_get, \
1862 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01001863 }
1864
1865#define DEFINE_CAPMIX(num) \
1866static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
1867 _DEFINE_CAPMIX(num), \
1868 _DEFINE_CAPSRC(num), \
1869 { } /* end */ \
1870}
1871
1872#define DEFINE_CAPMIX_NOSRC(num) \
1873static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
1874 _DEFINE_CAPMIX(num), \
1875 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001876}
1877
1878/* up to three ADCs */
1879DEFINE_CAPMIX(1);
1880DEFINE_CAPMIX(2);
1881DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01001882DEFINE_CAPMIX_NOSRC(1);
1883DEFINE_CAPMIX_NOSRC(2);
1884DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001885
1886/*
1887 * ALC880 5-stack model
1888 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001889 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
1890 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001891 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
1892 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
1893 */
1894
1895/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001896static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001897 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001898 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001899 { } /* end */
1900};
1901
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001902/* channel source setting (6/8 channel selection for 5-stack) */
1903/* 6ch mode */
1904static struct hda_verb alc880_fivestack_ch6_init[] = {
1905 /* set line-in to input, mute it */
1906 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1907 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001908 { } /* end */
1909};
1910
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001911/* 8ch mode */
1912static struct hda_verb alc880_fivestack_ch8_init[] = {
1913 /* set line-in to output, unmute it */
1914 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1915 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1916 { } /* end */
1917};
1918
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001919static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001920 { 6, alc880_fivestack_ch6_init },
1921 { 8, alc880_fivestack_ch8_init },
1922};
1923
1924
1925/*
1926 * ALC880 6-stack model
1927 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001928 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
1929 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001930 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
1931 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
1932 */
1933
1934static hda_nid_t alc880_6st_dac_nids[4] = {
1935 /* front, rear, clfe, rear_surr */
1936 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001937};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001938
1939static struct hda_input_mux alc880_6stack_capture_source = {
1940 .num_items = 4,
1941 .items = {
1942 { "Mic", 0x0 },
1943 { "Front Mic", 0x1 },
1944 { "Line", 0x2 },
1945 { "CD", 0x4 },
1946 },
1947};
1948
1949/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001950static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001951 { 8, NULL },
1952};
1953
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001954static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001955 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001956 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001957 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001958 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001959 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1960 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001961 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1962 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001963 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001964 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001965 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1966 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1967 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1968 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1969 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1970 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1971 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1972 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001973 {
1974 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1975 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001976 .info = alc_ch_mode_info,
1977 .get = alc_ch_mode_get,
1978 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001979 },
1980 { } /* end */
1981};
1982
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001983
1984/*
1985 * ALC880 W810 model
1986 *
1987 * W810 has rear IO for:
1988 * Front (DAC 02)
1989 * Surround (DAC 03)
1990 * Center/LFE (DAC 04)
1991 * Digital out (06)
1992 *
1993 * The system also has a pair of internal speakers, and a headphone jack.
1994 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02001995 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001996 * There is a variable resistor to control the speaker or headphone
1997 * volume. This is a hardware-only device without a software API.
1998 *
1999 * Plugging headphones in will disable the internal speakers. This is
2000 * implemented in hardware, not via the driver using jack sense. In
2001 * a similar fashion, plugging into the rear socket marked "front" will
2002 * disable both the speakers and headphones.
2003 *
2004 * For input, there's a microphone jack, and an "audio in" jack.
2005 * These may not do anything useful with this driver yet, because I
2006 * haven't setup any initialization verbs for these yet...
2007 */
2008
2009static hda_nid_t alc880_w810_dac_nids[3] = {
2010 /* front, rear/surround, clfe */
2011 0x02, 0x03, 0x04
2012};
2013
2014/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002015static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002016 { 6, NULL }
2017};
2018
2019/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002020static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002021 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002022 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002023 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002024 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002025 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2026 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002027 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2028 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002029 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2030 { } /* end */
2031};
2032
2033
2034/*
2035 * Z710V model
2036 *
2037 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002038 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2039 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002040 */
2041
2042static hda_nid_t alc880_z71v_dac_nids[1] = {
2043 0x02
2044};
2045#define ALC880_Z71V_HP_DAC 0x03
2046
2047/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002048static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002049 { 2, NULL }
2050};
2051
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002052static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002053 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002054 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002055 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002056 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002057 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2058 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2059 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2060 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2061 { } /* end */
2062};
2063
2064
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002065/*
2066 * ALC880 F1734 model
2067 *
2068 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2069 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2070 */
2071
2072static hda_nid_t alc880_f1734_dac_nids[1] = {
2073 0x03
2074};
2075#define ALC880_F1734_HP_DAC 0x02
2076
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002077static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002078 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002079 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01002080 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2081 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002082 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2083 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01002084 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2085 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002086 { } /* end */
2087};
2088
Takashi Iwai937b4162008-02-11 14:52:36 +01002089static struct hda_input_mux alc880_f1734_capture_source = {
2090 .num_items = 2,
2091 .items = {
2092 { "Mic", 0x1 },
2093 { "CD", 0x4 },
2094 },
2095};
2096
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002097
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002098/*
2099 * ALC880 ASUS model
2100 *
2101 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2102 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2103 * Mic = 0x18, Line = 0x1a
2104 */
2105
2106#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2107#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2108
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002109static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002110 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002111 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002112 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002113 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002114 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2115 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002116 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2117 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002118 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2119 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2120 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2121 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2122 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2123 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002124 {
2125 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2126 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002127 .info = alc_ch_mode_info,
2128 .get = alc_ch_mode_get,
2129 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002130 },
2131 { } /* end */
2132};
2133
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002134/*
2135 * ALC880 ASUS W1V model
2136 *
2137 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2138 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2139 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2140 */
2141
2142/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002143static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002144 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2145 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002146 { } /* end */
2147};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002148
Kailang Yangdf694da2005-12-05 19:42:22 +01002149/* TCL S700 */
2150static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2151 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2152 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2153 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2154 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2155 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2156 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2157 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2158 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2159 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002160 { } /* end */
2161};
2162
Kailang Yangccc656c2006-10-17 12:32:26 +02002163/* Uniwill */
2164static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002165 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2166 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2167 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2168 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002169 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2170 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2171 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2172 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2173 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2174 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2175 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2176 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2177 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2178 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2179 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2180 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002181 {
2182 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2183 .name = "Channel Mode",
2184 .info = alc_ch_mode_info,
2185 .get = alc_ch_mode_get,
2186 .put = alc_ch_mode_put,
2187 },
2188 { } /* end */
2189};
2190
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002191static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2192 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2193 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2194 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2195 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2196 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2197 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2198 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2199 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2200 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2201 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2202 { } /* end */
2203};
2204
Kailang Yangccc656c2006-10-17 12:32:26 +02002205static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002206 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2207 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2208 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2209 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002210 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2211 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2212 { } /* end */
2213};
2214
Linus Torvalds1da177e2005-04-16 15:20:36 -07002215/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01002216 * virtual master controls
2217 */
2218
2219/*
2220 * slave controls for virtual master
2221 */
2222static const char *alc_slave_vols[] = {
2223 "Front Playback Volume",
2224 "Surround Playback Volume",
2225 "Center Playback Volume",
2226 "LFE Playback Volume",
2227 "Side Playback Volume",
2228 "Headphone Playback Volume",
2229 "Speaker Playback Volume",
2230 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002231 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01002232 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002233 NULL,
2234};
2235
2236static const char *alc_slave_sws[] = {
2237 "Front Playback Switch",
2238 "Surround Playback Switch",
2239 "Center Playback Switch",
2240 "LFE Playback Switch",
2241 "Side Playback Switch",
2242 "Headphone Playback Switch",
2243 "Speaker Playback Switch",
2244 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01002245 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002246 NULL,
2247};
2248
2249/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002250 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002251 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002252
2253static void alc_free_kctls(struct hda_codec *codec);
2254
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002255/* additional beep mixers; the actual parameters are overwritten at build */
2256static struct snd_kcontrol_new alc_beep_mixer[] = {
2257 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
2258 HDA_CODEC_MUTE("Beep Playback Switch", 0, 0, HDA_INPUT),
2259 { } /* end */
2260};
2261
Linus Torvalds1da177e2005-04-16 15:20:36 -07002262static int alc_build_controls(struct hda_codec *codec)
2263{
2264 struct alc_spec *spec = codec->spec;
2265 int err;
2266 int i;
2267
2268 for (i = 0; i < spec->num_mixers; i++) {
2269 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2270 if (err < 0)
2271 return err;
2272 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002273 if (spec->cap_mixer) {
2274 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2275 if (err < 0)
2276 return err;
2277 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002278 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002279 err = snd_hda_create_spdif_out_ctls(codec,
2280 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002281 if (err < 0)
2282 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002283 if (!spec->no_analog) {
2284 err = snd_hda_create_spdif_share_sw(codec,
2285 &spec->multiout);
2286 if (err < 0)
2287 return err;
2288 spec->multiout.share_spdif = 1;
2289 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002290 }
2291 if (spec->dig_in_nid) {
2292 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2293 if (err < 0)
2294 return err;
2295 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002296
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002297 /* create beep controls if needed */
2298 if (spec->beep_amp) {
2299 struct snd_kcontrol_new *knew;
2300 for (knew = alc_beep_mixer; knew->name; knew++) {
2301 struct snd_kcontrol *kctl;
2302 kctl = snd_ctl_new1(knew, codec);
2303 if (!kctl)
2304 return -ENOMEM;
2305 kctl->private_value = spec->beep_amp;
2306 err = snd_hda_ctl_add(codec, kctl);
2307 if (err < 0)
2308 return err;
2309 }
2310 }
2311
Takashi Iwai2134ea42008-01-10 16:53:55 +01002312 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002313 if (!spec->no_analog &&
2314 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002315 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002316 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002317 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002318 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002319 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002320 if (err < 0)
2321 return err;
2322 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002323 if (!spec->no_analog &&
2324 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002325 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2326 NULL, alc_slave_sws);
2327 if (err < 0)
2328 return err;
2329 }
2330
Takashi Iwai603c4012008-07-30 15:01:44 +02002331 alc_free_kctls(codec); /* no longer needed */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002332 return 0;
2333}
2334
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002335
Linus Torvalds1da177e2005-04-16 15:20:36 -07002336/*
2337 * initialize the codec volumes, etc
2338 */
2339
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002340/*
2341 * generic initialization of ADC, input mixers and output mixers
2342 */
2343static struct hda_verb alc880_volume_init_verbs[] = {
2344 /*
2345 * Unmute ADC0-2 and set the default input to mic-in
2346 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002347 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002348 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002349 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002350 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002351 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002352 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002353
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002354 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2355 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002356 * Note: PASD motherboards uses the Line In 2 as the input for front
2357 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002358 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002359 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02002360 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2361 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2362 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2363 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2364 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2365 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2366 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002367
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002368 /*
2369 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002370 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002371 /* set vol=0 to output mixers */
2372 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2373 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2374 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2375 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2376 /* set up input amps for analog loopback */
2377 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002378 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2379 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002380 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2381 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002382 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2383 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002384 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2385 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002386
2387 { }
2388};
2389
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002390/*
2391 * 3-stack pin configuration:
2392 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2393 */
2394static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2395 /*
2396 * preset connection lists of input pins
2397 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2398 */
2399 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2400 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2401 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2402
2403 /*
2404 * Set pin mode and muting
2405 */
2406 /* set front pin widgets 0x14 for output */
2407 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2408 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2409 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2410 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2411 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2412 /* Mic2 (as headphone out) for HP output */
2413 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2414 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2415 /* Line In pin widget for input */
2416 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2417 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2418 /* Line2 (as front mic) pin widget for input and vref at 80% */
2419 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2420 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2421 /* CD pin widget for input */
2422 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2423
2424 { }
2425};
2426
2427/*
2428 * 5-stack pin configuration:
2429 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2430 * line-in/side = 0x1a, f-mic = 0x1b
2431 */
2432static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2433 /*
2434 * preset connection lists of input pins
2435 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2436 */
2437 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2438 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2439
2440 /*
2441 * Set pin mode and muting
2442 */
2443 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02002444 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2445 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2446 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2447 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002448 /* unmute pins for output (no gain on this amp) */
2449 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2450 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2451 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2452 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2453
Linus Torvalds1da177e2005-04-16 15:20:36 -07002454 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02002455 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002456 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2457 /* Mic2 (as headphone out) for HP output */
2458 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002459 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002460 /* Line In pin widget for input */
2461 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2462 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2463 /* Line2 (as front mic) pin widget for input and vref at 80% */
2464 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2465 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2466 /* CD pin widget for input */
2467 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002468
2469 { }
2470};
2471
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002472/*
2473 * W810 pin configuration:
2474 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2475 */
2476static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002477 /* hphone/speaker input selector: front DAC */
2478 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2479
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002480 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2481 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2482 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2483 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2484 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2485 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2486
2487 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002488 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002489
Linus Torvalds1da177e2005-04-16 15:20:36 -07002490 { }
2491};
2492
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002493/*
2494 * Z71V pin configuration:
2495 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2496 */
2497static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002498 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002499 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02002500 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002501 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002502
Takashi Iwai16ded522005-06-10 19:58:24 +02002503 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002504 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002505 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002506 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002507
2508 { }
2509};
2510
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002511/*
2512 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002513 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2514 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002515 */
2516static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2517 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2518
Takashi Iwai16ded522005-06-10 19:58:24 +02002519 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002520 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002521 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002522 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002523 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002524 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002525 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002526 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2527
Takashi Iwai16ded522005-06-10 19:58:24 +02002528 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002529 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002530 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002531 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002532 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002533 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002534 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02002535 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002536 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002537
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002538 { }
2539};
Takashi Iwai16ded522005-06-10 19:58:24 +02002540
Kailang Yangccc656c2006-10-17 12:32:26 +02002541/*
2542 * Uniwill pin configuration:
2543 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2544 * line = 0x1a
2545 */
2546static struct hda_verb alc880_uniwill_init_verbs[] = {
2547 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2548
2549 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2550 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2551 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2552 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2553 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2554 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2555 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2556 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2557 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2558 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2559 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2560 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2561 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2562 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2563
2564 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2565 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2566 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2567 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2568 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2569 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2570 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2571 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2572 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2573
2574 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2575 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2576
2577 { }
2578};
2579
2580/*
2581* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02002582* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02002583 */
2584static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2585 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2586
2587 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2588 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2589 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2590 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2591 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2592 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2593 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2594 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2595 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2596 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2597 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2598 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2599
2600 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2601 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2602 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2603 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2604 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2605 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2606
2607 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2608 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2609
2610 { }
2611};
2612
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002613static struct hda_verb alc880_beep_init_verbs[] = {
2614 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2615 { }
2616};
2617
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002618/* auto-toggle front mic */
2619static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2620{
2621 unsigned int present;
2622 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002623
2624 present = snd_hda_codec_read(codec, 0x18, 0,
2625 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002626 bits = present ? HDA_AMP_MUTE : 0;
2627 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002628}
2629
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002630static void alc880_uniwill_init_hook(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002631{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002632 struct alc_spec *spec = codec->spec;
2633
2634 spec->autocfg.hp_pins[0] = 0x14;
2635 spec->autocfg.speaker_pins[0] = 0x15;
2636 spec->autocfg.speaker_pins[0] = 0x16;
2637 alc_automute_amp(codec);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002638 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002639}
2640
2641static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2642 unsigned int res)
2643{
2644 /* Looks like the unsol event is incompatible with the standard
2645 * definition. 4bit tag is placed at 28 bit!
2646 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002647 switch (res >> 28) {
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002648 case ALC880_MIC_EVENT:
2649 alc880_uniwill_mic_automute(codec);
2650 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002651 default:
2652 alc_automute_amp_unsol_event(codec, res);
2653 break;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002654 }
Kailang Yangccc656c2006-10-17 12:32:26 +02002655}
2656
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002657static void alc880_uniwill_p53_init_hook(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02002658{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002659 struct alc_spec *spec = codec->spec;
Kailang Yangccc656c2006-10-17 12:32:26 +02002660
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002661 spec->autocfg.hp_pins[0] = 0x14;
2662 spec->autocfg.speaker_pins[0] = 0x15;
2663 alc_automute_amp(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002664}
2665
2666static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2667{
2668 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02002669
Kailang Yangccc656c2006-10-17 12:32:26 +02002670 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02002671 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2672 present &= HDA_AMP_VOLMASK;
2673 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2674 HDA_AMP_VOLMASK, present);
2675 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2676 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02002677}
Takashi Iwai47fd8302007-08-10 17:11:07 +02002678
Kailang Yangccc656c2006-10-17 12:32:26 +02002679static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2680 unsigned int res)
2681{
2682 /* Looks like the unsol event is incompatible with the standard
2683 * definition. 4bit tag is placed at 28 bit!
2684 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002685 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02002686 alc880_uniwill_p53_dcvol_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002687 else
2688 alc_automute_amp_unsol_event(codec, res);
Kailang Yangccc656c2006-10-17 12:32:26 +02002689}
2690
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002691/*
2692 * F1734 pin configuration:
2693 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2694 */
2695static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01002696 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002697 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2698 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2699 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2700 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2701
2702 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2703 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2704 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2705 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2706
2707 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2708 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01002709 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002710 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2711 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2712 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2713 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2714 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2715 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002716
Takashi Iwai937b4162008-02-11 14:52:36 +01002717 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2718 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2719
Takashi Iwai16ded522005-06-10 19:58:24 +02002720 { }
2721};
2722
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002723/*
2724 * ASUS pin configuration:
2725 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2726 */
2727static struct hda_verb alc880_pin_asus_init_verbs[] = {
2728 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2729 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2730 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2731 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2732
2733 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2734 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2735 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2736 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2737 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2738 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2739 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2740 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2741
2742 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2743 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2744 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2745 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2746 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2747 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2748 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2749 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2750 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002751
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002752 { }
2753};
2754
2755/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02002756#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2757#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
David Heidelberger64a8be72009-06-08 16:15:18 +02002758#define alc880_gpio3_init_verbs alc_gpio3_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002759
Kailang Yangdf694da2005-12-05 19:42:22 +01002760/* Clevo m520g init */
2761static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2762 /* headphone output */
2763 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2764 /* line-out */
2765 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2766 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2767 /* Line-in */
2768 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2769 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2770 /* CD */
2771 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2772 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2773 /* Mic1 (rear panel) */
2774 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2775 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2776 /* Mic2 (front panel) */
2777 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2778 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2779 /* headphone */
2780 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2781 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2782 /* change to EAPD mode */
2783 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2784 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2785
2786 { }
2787};
2788
2789static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002790 /* change to EAPD mode */
2791 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2792 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2793
Kailang Yangdf694da2005-12-05 19:42:22 +01002794 /* Headphone output */
2795 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2796 /* Front output*/
2797 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2798 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2799
2800 /* Line In pin widget for input */
2801 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2802 /* CD pin widget for input */
2803 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2804 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2805 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2806
2807 /* change to EAPD mode */
2808 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2809 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2810
2811 { }
2812};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002813
2814/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002815 * LG m1 express dual
2816 *
2817 * Pin assignment:
2818 * Rear Line-In/Out (blue): 0x14
2819 * Build-in Mic-In: 0x15
2820 * Speaker-out: 0x17
2821 * HP-Out (green): 0x1b
2822 * Mic-In/Out (red): 0x19
2823 * SPDIF-Out: 0x1e
2824 */
2825
2826/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2827static hda_nid_t alc880_lg_dac_nids[3] = {
2828 0x05, 0x02, 0x03
2829};
2830
2831/* seems analog CD is not working */
2832static struct hda_input_mux alc880_lg_capture_source = {
2833 .num_items = 3,
2834 .items = {
2835 { "Mic", 0x1 },
2836 { "Line", 0x5 },
2837 { "Internal Mic", 0x6 },
2838 },
2839};
2840
2841/* 2,4,6 channel modes */
2842static struct hda_verb alc880_lg_ch2_init[] = {
2843 /* set line-in and mic-in to input */
2844 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2845 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2846 { }
2847};
2848
2849static struct hda_verb alc880_lg_ch4_init[] = {
2850 /* set line-in to out and mic-in to input */
2851 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2852 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2853 { }
2854};
2855
2856static struct hda_verb alc880_lg_ch6_init[] = {
2857 /* set line-in and mic-in to output */
2858 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2859 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2860 { }
2861};
2862
2863static struct hda_channel_mode alc880_lg_ch_modes[3] = {
2864 { 2, alc880_lg_ch2_init },
2865 { 4, alc880_lg_ch4_init },
2866 { 6, alc880_lg_ch6_init },
2867};
2868
2869static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002870 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2871 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002872 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2873 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
2874 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
2875 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
2876 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
2877 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
2878 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2879 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2880 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
2881 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
2882 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
2883 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
2884 {
2885 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2886 .name = "Channel Mode",
2887 .info = alc_ch_mode_info,
2888 .get = alc_ch_mode_get,
2889 .put = alc_ch_mode_put,
2890 },
2891 { } /* end */
2892};
2893
2894static struct hda_verb alc880_lg_init_verbs[] = {
2895 /* set capture source to mic-in */
2896 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2897 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2898 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2899 /* mute all amp mixer inputs */
2900 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002901 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2902 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002903 /* line-in to input */
2904 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2905 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2906 /* built-in mic */
2907 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2908 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2909 /* speaker-out */
2910 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2911 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2912 /* mic-in to input */
2913 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2914 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2915 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2916 /* HP-out */
2917 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
2918 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2919 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2920 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002921 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002922 { }
2923};
2924
2925/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002926static void alc880_lg_init_hook(struct hda_codec *codec)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002927{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002928 struct alc_spec *spec = codec->spec;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002929
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002930 spec->autocfg.hp_pins[0] = 0x1b;
2931 spec->autocfg.speaker_pins[0] = 0x17;
2932 alc_automute_amp(codec);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002933}
2934
2935/*
Takashi Iwaid6815182006-03-23 16:06:23 +01002936 * LG LW20
2937 *
2938 * Pin assignment:
2939 * Speaker-out: 0x14
2940 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002941 * Built-in Mic-In: 0x19
2942 * Line-In: 0x1b
2943 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01002944 * SPDIF-Out: 0x1e
2945 */
2946
Takashi Iwaid6815182006-03-23 16:06:23 +01002947static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002948 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01002949 .items = {
2950 { "Mic", 0x0 },
2951 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002952 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002953 },
2954};
2955
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002956#define alc880_lg_lw_modes alc880_threestack_modes
2957
Takashi Iwaid6815182006-03-23 16:06:23 +01002958static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002959 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2960 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2961 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2962 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2963 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2964 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2965 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2966 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2967 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2968 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01002969 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2970 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2971 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
2972 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002973 {
2974 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2975 .name = "Channel Mode",
2976 .info = alc_ch_mode_info,
2977 .get = alc_ch_mode_get,
2978 .put = alc_ch_mode_put,
2979 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002980 { } /* end */
2981};
2982
2983static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002984 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2985 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2986 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2987
Takashi Iwaid6815182006-03-23 16:06:23 +01002988 /* set capture source to mic-in */
2989 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2990 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2991 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002992 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01002993 /* speaker-out */
2994 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2995 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2996 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01002997 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2998 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2999 /* mic-in to input */
3000 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3001 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3002 /* built-in mic */
3003 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3004 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3005 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003006 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaid6815182006-03-23 16:06:23 +01003007 { }
3008};
3009
3010/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003011static void alc880_lg_lw_init_hook(struct hda_codec *codec)
Takashi Iwaid6815182006-03-23 16:06:23 +01003012{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003013 struct alc_spec *spec = codec->spec;
Takashi Iwaid6815182006-03-23 16:06:23 +01003014
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003015 spec->autocfg.hp_pins[0] = 0x1b;
3016 spec->autocfg.speaker_pins[0] = 0x14;
3017 alc_automute_amp(codec);
Takashi Iwaid6815182006-03-23 16:06:23 +01003018}
3019
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003020static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3021 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3022 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3023 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3024 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3025 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3026 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3027 { } /* end */
3028};
3029
3030static struct hda_input_mux alc880_medion_rim_capture_source = {
3031 .num_items = 2,
3032 .items = {
3033 { "Mic", 0x0 },
3034 { "Internal Mic", 0x1 },
3035 },
3036};
3037
3038static struct hda_verb alc880_medion_rim_init_verbs[] = {
3039 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3040
3041 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3042 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3043
3044 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3045 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3046 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3047 /* Mic2 (as headphone out) for HP output */
3048 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3049 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3050 /* Internal Speaker */
3051 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3052 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3053
3054 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3055 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3056
3057 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3058 { }
3059};
3060
3061/* toggle speaker-output according to the hp-jack state */
3062static void alc880_medion_rim_automute(struct hda_codec *codec)
3063{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003064 struct alc_spec *spec = codec->spec;
3065 alc_automute_amp(codec);
3066 /* toggle EAPD */
3067 if (spec->jack_present)
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003068 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3069 else
3070 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3071}
3072
3073static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3074 unsigned int res)
3075{
3076 /* Looks like the unsol event is incompatible with the standard
3077 * definition. 4bit tag is placed at 28 bit!
3078 */
3079 if ((res >> 28) == ALC880_HP_EVENT)
3080 alc880_medion_rim_automute(codec);
3081}
3082
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003083static void alc880_medion_rim_init_hook(struct hda_codec *codec)
3084{
3085 struct alc_spec *spec = codec->spec;
3086
3087 spec->autocfg.hp_pins[0] = 0x14;
3088 spec->autocfg.speaker_pins[0] = 0x1b;
3089 alc880_medion_rim_automute(codec);
3090}
3091
Takashi Iwaicb53c622007-08-10 17:21:45 +02003092#ifdef CONFIG_SND_HDA_POWER_SAVE
3093static struct hda_amp_list alc880_loopbacks[] = {
3094 { 0x0b, HDA_INPUT, 0 },
3095 { 0x0b, HDA_INPUT, 1 },
3096 { 0x0b, HDA_INPUT, 2 },
3097 { 0x0b, HDA_INPUT, 3 },
3098 { 0x0b, HDA_INPUT, 4 },
3099 { } /* end */
3100};
3101
3102static struct hda_amp_list alc880_lg_loopbacks[] = {
3103 { 0x0b, HDA_INPUT, 1 },
3104 { 0x0b, HDA_INPUT, 6 },
3105 { 0x0b, HDA_INPUT, 7 },
3106 { } /* end */
3107};
3108#endif
3109
Takashi Iwaid6815182006-03-23 16:06:23 +01003110/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003111 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003112 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003113
Linus Torvalds1da177e2005-04-16 15:20:36 -07003114static int alc_init(struct hda_codec *codec)
3115{
3116 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003117 unsigned int i;
3118
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003119 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02003120 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003121
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003122 for (i = 0; i < spec->num_init_verbs; i++)
3123 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003124
3125 if (spec->init_hook)
3126 spec->init_hook(codec);
3127
Linus Torvalds1da177e2005-04-16 15:20:36 -07003128 return 0;
3129}
3130
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003131static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3132{
3133 struct alc_spec *spec = codec->spec;
3134
3135 if (spec->unsol_event)
3136 spec->unsol_event(codec, res);
3137}
3138
Takashi Iwaicb53c622007-08-10 17:21:45 +02003139#ifdef CONFIG_SND_HDA_POWER_SAVE
3140static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3141{
3142 struct alc_spec *spec = codec->spec;
3143 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3144}
3145#endif
3146
Linus Torvalds1da177e2005-04-16 15:20:36 -07003147/*
3148 * Analog playback callbacks
3149 */
3150static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3151 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003152 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003153{
3154 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01003155 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3156 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003157}
3158
3159static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3160 struct hda_codec *codec,
3161 unsigned int stream_tag,
3162 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003163 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003164{
3165 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003166 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3167 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003168}
3169
3170static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3171 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003172 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003173{
3174 struct alc_spec *spec = codec->spec;
3175 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3176}
3177
3178/*
3179 * Digital out
3180 */
3181static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3182 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003183 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003184{
3185 struct alc_spec *spec = codec->spec;
3186 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3187}
3188
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003189static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3190 struct hda_codec *codec,
3191 unsigned int stream_tag,
3192 unsigned int format,
3193 struct snd_pcm_substream *substream)
3194{
3195 struct alc_spec *spec = codec->spec;
3196 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3197 stream_tag, format, substream);
3198}
3199
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003200static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3201 struct hda_codec *codec,
3202 struct snd_pcm_substream *substream)
3203{
3204 struct alc_spec *spec = codec->spec;
3205 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3206}
3207
Linus Torvalds1da177e2005-04-16 15:20:36 -07003208static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3209 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003210 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003211{
3212 struct alc_spec *spec = codec->spec;
3213 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3214}
3215
3216/*
3217 * Analog capture
3218 */
Takashi Iwai63300792008-01-24 15:31:36 +01003219static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003220 struct hda_codec *codec,
3221 unsigned int stream_tag,
3222 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003223 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003224{
3225 struct alc_spec *spec = codec->spec;
3226
Takashi Iwai63300792008-01-24 15:31:36 +01003227 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07003228 stream_tag, 0, format);
3229 return 0;
3230}
3231
Takashi Iwai63300792008-01-24 15:31:36 +01003232static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003233 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003234 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003235{
3236 struct alc_spec *spec = codec->spec;
3237
Takashi Iwai888afa12008-03-18 09:57:50 +01003238 snd_hda_codec_cleanup_stream(codec,
3239 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003240 return 0;
3241}
3242
3243
3244/*
3245 */
3246static struct hda_pcm_stream alc880_pcm_analog_playback = {
3247 .substreams = 1,
3248 .channels_min = 2,
3249 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003250 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003251 .ops = {
3252 .open = alc880_playback_pcm_open,
3253 .prepare = alc880_playback_pcm_prepare,
3254 .cleanup = alc880_playback_pcm_cleanup
3255 },
3256};
3257
3258static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01003259 .substreams = 1,
3260 .channels_min = 2,
3261 .channels_max = 2,
3262 /* NID is set in alc_build_pcms */
3263};
3264
3265static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3266 .substreams = 1,
3267 .channels_min = 2,
3268 .channels_max = 2,
3269 /* NID is set in alc_build_pcms */
3270};
3271
3272static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3273 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003274 .channels_min = 2,
3275 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003276 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003277 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01003278 .prepare = alc880_alt_capture_pcm_prepare,
3279 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003280 },
3281};
3282
3283static struct hda_pcm_stream alc880_pcm_digital_playback = {
3284 .substreams = 1,
3285 .channels_min = 2,
3286 .channels_max = 2,
3287 /* NID is set in alc_build_pcms */
3288 .ops = {
3289 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003290 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003291 .prepare = alc880_dig_playback_pcm_prepare,
3292 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003293 },
3294};
3295
3296static struct hda_pcm_stream alc880_pcm_digital_capture = {
3297 .substreams = 1,
3298 .channels_min = 2,
3299 .channels_max = 2,
3300 /* NID is set in alc_build_pcms */
3301};
3302
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003303/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01003304static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003305 .substreams = 0,
3306 .channels_min = 0,
3307 .channels_max = 0,
3308};
3309
Linus Torvalds1da177e2005-04-16 15:20:36 -07003310static int alc_build_pcms(struct hda_codec *codec)
3311{
3312 struct alc_spec *spec = codec->spec;
3313 struct hda_pcm *info = spec->pcm_rec;
3314 int i;
3315
3316 codec->num_pcms = 1;
3317 codec->pcm_info = info;
3318
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003319 if (spec->no_analog)
3320 goto skip_analog;
3321
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003322 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
3323 "%s Analog", codec->chip_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003324 info->name = spec->stream_name_analog;
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003325
Takashi Iwai4a471b72005-12-07 13:56:29 +01003326 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003327 if (snd_BUG_ON(!spec->multiout.dac_nids))
3328 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003329 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3330 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3331 }
3332 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003333 if (snd_BUG_ON(!spec->adc_nids))
3334 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003335 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3336 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3337 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003338
Takashi Iwai4a471b72005-12-07 13:56:29 +01003339 if (spec->channel_mode) {
3340 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3341 for (i = 0; i < spec->num_channel_mode; i++) {
3342 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3343 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3344 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003345 }
3346 }
3347
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003348 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02003349 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003350 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003351 snprintf(spec->stream_name_digital,
3352 sizeof(spec->stream_name_digital),
3353 "%s Digital", codec->chip_name);
Takashi Iwaie08a0072006-09-07 17:52:14 +02003354 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08003355 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003356 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003357 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01003358 if (spec->dig_out_type)
3359 info->pcm_type = spec->dig_out_type;
3360 else
3361 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003362 if (spec->multiout.dig_out_nid &&
3363 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003364 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
3365 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3366 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01003367 if (spec->dig_in_nid &&
3368 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003369 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
3370 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3371 }
Takashi Iwai963f8032008-08-11 10:04:40 +02003372 /* FIXME: do we need this for all Realtek codec models? */
3373 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003374 }
3375
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003376 if (spec->no_analog)
3377 return 0;
3378
Takashi Iwaie08a0072006-09-07 17:52:14 +02003379 /* If the use of more than one ADC is requested for the current
3380 * model, configure a second analog capture-only PCM.
3381 */
3382 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01003383 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
3384 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003385 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003386 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003387 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01003388 if (spec->alt_dac_nid) {
3389 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3390 *spec->stream_analog_alt_playback;
3391 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3392 spec->alt_dac_nid;
3393 } else {
3394 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3395 alc_pcm_null_stream;
3396 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
3397 }
3398 if (spec->num_adc_nids > 1) {
3399 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3400 *spec->stream_analog_alt_capture;
3401 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
3402 spec->adc_nids[1];
3403 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
3404 spec->num_adc_nids - 1;
3405 } else {
3406 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3407 alc_pcm_null_stream;
3408 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003409 }
3410 }
3411
Linus Torvalds1da177e2005-04-16 15:20:36 -07003412 return 0;
3413}
3414
Takashi Iwai603c4012008-07-30 15:01:44 +02003415static void alc_free_kctls(struct hda_codec *codec)
3416{
3417 struct alc_spec *spec = codec->spec;
3418
3419 if (spec->kctls.list) {
3420 struct snd_kcontrol_new *kctl = spec->kctls.list;
3421 int i;
3422 for (i = 0; i < spec->kctls.used; i++)
3423 kfree(kctl[i].name);
3424 }
3425 snd_array_free(&spec->kctls);
3426}
3427
Linus Torvalds1da177e2005-04-16 15:20:36 -07003428static void alc_free(struct hda_codec *codec)
3429{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003430 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003431
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003432 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003433 return;
3434
Takashi Iwai603c4012008-07-30 15:01:44 +02003435 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003436 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09003437 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003438}
3439
Takashi Iwaie044c392008-10-27 16:56:24 +01003440#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01003441static int alc_resume(struct hda_codec *codec)
3442{
Takashi Iwaie044c392008-10-27 16:56:24 +01003443 codec->patch_ops.init(codec);
3444 snd_hda_codec_resume_amp(codec);
3445 snd_hda_codec_resume_cache(codec);
3446 return 0;
3447}
Takashi Iwaie044c392008-10-27 16:56:24 +01003448#endif
3449
Linus Torvalds1da177e2005-04-16 15:20:36 -07003450/*
3451 */
3452static struct hda_codec_ops alc_patch_ops = {
3453 .build_controls = alc_build_controls,
3454 .build_pcms = alc_build_pcms,
3455 .init = alc_init,
3456 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003457 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01003458#ifdef SND_HDA_NEEDS_RESUME
3459 .resume = alc_resume,
3460#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02003461#ifdef CONFIG_SND_HDA_POWER_SAVE
3462 .check_power_status = alc_check_power_status,
3463#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003464};
3465
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003466
3467/*
3468 * Test configuration for debugging
3469 *
3470 * Almost all inputs/outputs are enabled. I/O pins can be configured via
3471 * enum controls.
3472 */
3473#ifdef CONFIG_SND_DEBUG
3474static hda_nid_t alc880_test_dac_nids[4] = {
3475 0x02, 0x03, 0x04, 0x05
3476};
3477
3478static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003479 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003480 .items = {
3481 { "In-1", 0x0 },
3482 { "In-2", 0x1 },
3483 { "In-3", 0x2 },
3484 { "In-4", 0x3 },
3485 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003486 { "Front", 0x5 },
3487 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003488 },
3489};
3490
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003491static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003492 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003493 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003494 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003495 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003496};
3497
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003498static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
3499 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003500{
3501 static char *texts[] = {
3502 "N/A", "Line Out", "HP Out",
3503 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
3504 };
3505 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3506 uinfo->count = 1;
3507 uinfo->value.enumerated.items = 8;
3508 if (uinfo->value.enumerated.item >= 8)
3509 uinfo->value.enumerated.item = 7;
3510 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3511 return 0;
3512}
3513
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003514static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
3515 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003516{
3517 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3518 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3519 unsigned int pin_ctl, item = 0;
3520
3521 pin_ctl = snd_hda_codec_read(codec, nid, 0,
3522 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3523 if (pin_ctl & AC_PINCTL_OUT_EN) {
3524 if (pin_ctl & AC_PINCTL_HP_EN)
3525 item = 2;
3526 else
3527 item = 1;
3528 } else if (pin_ctl & AC_PINCTL_IN_EN) {
3529 switch (pin_ctl & AC_PINCTL_VREFEN) {
3530 case AC_PINCTL_VREF_HIZ: item = 3; break;
3531 case AC_PINCTL_VREF_50: item = 4; break;
3532 case AC_PINCTL_VREF_GRD: item = 5; break;
3533 case AC_PINCTL_VREF_80: item = 6; break;
3534 case AC_PINCTL_VREF_100: item = 7; break;
3535 }
3536 }
3537 ucontrol->value.enumerated.item[0] = item;
3538 return 0;
3539}
3540
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003541static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
3542 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003543{
3544 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3545 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3546 static unsigned int ctls[] = {
3547 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
3548 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
3549 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
3550 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
3551 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
3552 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
3553 };
3554 unsigned int old_ctl, new_ctl;
3555
3556 old_ctl = snd_hda_codec_read(codec, nid, 0,
3557 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3558 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
3559 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003560 int val;
3561 snd_hda_codec_write_cache(codec, nid, 0,
3562 AC_VERB_SET_PIN_WIDGET_CONTROL,
3563 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003564 val = ucontrol->value.enumerated.item[0] >= 3 ?
3565 HDA_AMP_MUTE : 0;
3566 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3567 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003568 return 1;
3569 }
3570 return 0;
3571}
3572
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003573static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
3574 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003575{
3576 static char *texts[] = {
3577 "Front", "Surround", "CLFE", "Side"
3578 };
3579 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3580 uinfo->count = 1;
3581 uinfo->value.enumerated.items = 4;
3582 if (uinfo->value.enumerated.item >= 4)
3583 uinfo->value.enumerated.item = 3;
3584 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3585 return 0;
3586}
3587
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003588static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
3589 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003590{
3591 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3592 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3593 unsigned int sel;
3594
3595 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
3596 ucontrol->value.enumerated.item[0] = sel & 3;
3597 return 0;
3598}
3599
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003600static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
3601 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003602{
3603 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3604 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3605 unsigned int sel;
3606
3607 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
3608 if (ucontrol->value.enumerated.item[0] != sel) {
3609 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003610 snd_hda_codec_write_cache(codec, nid, 0,
3611 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003612 return 1;
3613 }
3614 return 0;
3615}
3616
3617#define PIN_CTL_TEST(xname,nid) { \
3618 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3619 .name = xname, \
3620 .info = alc_test_pin_ctl_info, \
3621 .get = alc_test_pin_ctl_get, \
3622 .put = alc_test_pin_ctl_put, \
3623 .private_value = nid \
3624 }
3625
3626#define PIN_SRC_TEST(xname,nid) { \
3627 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3628 .name = xname, \
3629 .info = alc_test_pin_src_info, \
3630 .get = alc_test_pin_src_get, \
3631 .put = alc_test_pin_src_put, \
3632 .private_value = nid \
3633 }
3634
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003635static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003636 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3637 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3638 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
3639 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003640 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3641 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
3642 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
3643 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003644 PIN_CTL_TEST("Front Pin Mode", 0x14),
3645 PIN_CTL_TEST("Surround Pin Mode", 0x15),
3646 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
3647 PIN_CTL_TEST("Side Pin Mode", 0x17),
3648 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
3649 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
3650 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
3651 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
3652 PIN_SRC_TEST("In-1 Pin Source", 0x18),
3653 PIN_SRC_TEST("In-2 Pin Source", 0x19),
3654 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
3655 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
3656 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
3657 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
3658 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
3659 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
3660 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
3661 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
3662 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
3663 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
3664 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
3665 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003666 {
3667 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3668 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01003669 .info = alc_ch_mode_info,
3670 .get = alc_ch_mode_get,
3671 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003672 },
3673 { } /* end */
3674};
3675
3676static struct hda_verb alc880_test_init_verbs[] = {
3677 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003678 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3679 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3680 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3681 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3682 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3683 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3684 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3685 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003686 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003687 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3688 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3689 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3690 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003691 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003692 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3693 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3694 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3695 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003696 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003697 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3698 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3699 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3700 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003701 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02003702 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3703 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02003704 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3705 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3706 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003707 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02003708 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3709 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3710 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3711 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003712 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02003713 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003714 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003715 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003716 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003717 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003718 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003719 /* Analog input/passthru */
3720 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3721 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3722 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3723 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3724 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003725 { }
3726};
3727#endif
3728
Linus Torvalds1da177e2005-04-16 15:20:36 -07003729/*
3730 */
3731
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003732static const char *alc880_models[ALC880_MODEL_LAST] = {
3733 [ALC880_3ST] = "3stack",
3734 [ALC880_TCL_S700] = "tcl",
3735 [ALC880_3ST_DIG] = "3stack-digout",
3736 [ALC880_CLEVO] = "clevo",
3737 [ALC880_5ST] = "5stack",
3738 [ALC880_5ST_DIG] = "5stack-digout",
3739 [ALC880_W810] = "w810",
3740 [ALC880_Z71V] = "z71v",
3741 [ALC880_6ST] = "6stack",
3742 [ALC880_6ST_DIG] = "6stack-digout",
3743 [ALC880_ASUS] = "asus",
3744 [ALC880_ASUS_W1V] = "asus-w1v",
3745 [ALC880_ASUS_DIG] = "asus-dig",
3746 [ALC880_ASUS_DIG2] = "asus-dig2",
3747 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003748 [ALC880_UNIWILL_P53] = "uniwill-p53",
3749 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003750 [ALC880_F1734] = "F1734",
3751 [ALC880_LG] = "lg",
3752 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003753 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003754#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003755 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003756#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003757 [ALC880_AUTO] = "auto",
3758};
3759
3760static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003761 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003762 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
3763 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
3764 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
3765 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
3766 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
3767 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
3768 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
3769 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003770 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
3771 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003772 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
3773 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
3774 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
3775 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
3776 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
3777 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
3778 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
3779 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
3780 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
3781 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02003782 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003783 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
3784 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
3785 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01003786 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003787 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003788 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
3789 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003790 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
3791 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003792 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
3793 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
3794 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
3795 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003796 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
3797 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003798 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003799 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003800 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003801 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003802 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
3803 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003804 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003805 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003806 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003807 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003808 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02003809 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003810 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003811 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003812 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003813 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
3814 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003815 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003816 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
3817 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
3818 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
3819 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003820 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
3821 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003822 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003823 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003824 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
3825 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003826 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
3827 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
3828 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01003829 /* default Intel */
3830 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003831 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
3832 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003833 {}
3834};
3835
Takashi Iwai16ded522005-06-10 19:58:24 +02003836/*
Kailang Yangdf694da2005-12-05 19:42:22 +01003837 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02003838 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003839static struct alc_config_preset alc880_presets[] = {
3840 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003841 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003842 .init_verbs = { alc880_volume_init_verbs,
3843 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003844 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003845 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003846 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3847 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003848 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003849 .input_mux = &alc880_capture_source,
3850 },
3851 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003852 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003853 .init_verbs = { alc880_volume_init_verbs,
3854 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003855 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003856 .dac_nids = alc880_dac_nids,
3857 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003858 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3859 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003860 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003861 .input_mux = &alc880_capture_source,
3862 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003863 [ALC880_TCL_S700] = {
3864 .mixers = { alc880_tcl_s700_mixer },
3865 .init_verbs = { alc880_volume_init_verbs,
3866 alc880_pin_tcl_S700_init_verbs,
3867 alc880_gpio2_init_verbs },
3868 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3869 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01003870 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
3871 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01003872 .hp_nid = 0x03,
3873 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3874 .channel_mode = alc880_2_jack_modes,
3875 .input_mux = &alc880_capture_source,
3876 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003877 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003878 .mixers = { alc880_three_stack_mixer,
3879 alc880_five_stack_mixer},
3880 .init_verbs = { alc880_volume_init_verbs,
3881 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003882 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3883 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003884 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3885 .channel_mode = alc880_fivestack_modes,
3886 .input_mux = &alc880_capture_source,
3887 },
3888 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003889 .mixers = { alc880_three_stack_mixer,
3890 alc880_five_stack_mixer },
3891 .init_verbs = { alc880_volume_init_verbs,
3892 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003893 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3894 .dac_nids = alc880_dac_nids,
3895 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003896 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3897 .channel_mode = alc880_fivestack_modes,
3898 .input_mux = &alc880_capture_source,
3899 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003900 [ALC880_6ST] = {
3901 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003902 .init_verbs = { alc880_volume_init_verbs,
3903 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003904 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3905 .dac_nids = alc880_6st_dac_nids,
3906 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3907 .channel_mode = alc880_sixstack_modes,
3908 .input_mux = &alc880_6stack_capture_source,
3909 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003910 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003911 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003912 .init_verbs = { alc880_volume_init_verbs,
3913 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003914 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3915 .dac_nids = alc880_6st_dac_nids,
3916 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003917 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3918 .channel_mode = alc880_sixstack_modes,
3919 .input_mux = &alc880_6stack_capture_source,
3920 },
3921 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003922 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003923 .init_verbs = { alc880_volume_init_verbs,
3924 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003925 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003926 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
3927 .dac_nids = alc880_w810_dac_nids,
3928 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003929 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3930 .channel_mode = alc880_w810_modes,
3931 .input_mux = &alc880_capture_source,
3932 },
3933 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003934 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003935 .init_verbs = { alc880_volume_init_verbs,
3936 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003937 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
3938 .dac_nids = alc880_z71v_dac_nids,
3939 .dig_out_nid = ALC880_DIGOUT_NID,
3940 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003941 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3942 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02003943 .input_mux = &alc880_capture_source,
3944 },
3945 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003946 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003947 .init_verbs = { alc880_volume_init_verbs,
3948 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003949 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
3950 .dac_nids = alc880_f1734_dac_nids,
3951 .hp_nid = 0x02,
3952 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3953 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01003954 .input_mux = &alc880_f1734_capture_source,
3955 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003956 .init_hook = alc880_uniwill_p53_init_hook,
Takashi Iwai16ded522005-06-10 19:58:24 +02003957 },
3958 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003959 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003960 .init_verbs = { alc880_volume_init_verbs,
3961 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003962 alc880_gpio1_init_verbs },
3963 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3964 .dac_nids = alc880_asus_dac_nids,
3965 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3966 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003967 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003968 .input_mux = &alc880_capture_source,
3969 },
3970 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003971 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003972 .init_verbs = { alc880_volume_init_verbs,
3973 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003974 alc880_gpio1_init_verbs },
3975 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3976 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003977 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003978 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3979 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003980 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003981 .input_mux = &alc880_capture_source,
3982 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003983 [ALC880_ASUS_DIG2] = {
3984 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003985 .init_verbs = { alc880_volume_init_verbs,
3986 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01003987 alc880_gpio2_init_verbs }, /* use GPIO2 */
3988 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3989 .dac_nids = alc880_asus_dac_nids,
3990 .dig_out_nid = ALC880_DIGOUT_NID,
3991 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3992 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003993 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003994 .input_mux = &alc880_capture_source,
3995 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003996 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003997 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003998 .init_verbs = { alc880_volume_init_verbs,
3999 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004000 alc880_gpio1_init_verbs },
4001 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4002 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004003 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004004 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4005 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004006 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004007 .input_mux = &alc880_capture_source,
4008 },
4009 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004010 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02004011 .init_verbs = { alc880_volume_init_verbs,
4012 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004013 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4014 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004015 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004016 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4017 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004018 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004019 .input_mux = &alc880_capture_source,
4020 },
Kailang Yangccc656c2006-10-17 12:32:26 +02004021 [ALC880_UNIWILL] = {
4022 .mixers = { alc880_uniwill_mixer },
4023 .init_verbs = { alc880_volume_init_verbs,
4024 alc880_uniwill_init_verbs },
4025 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4026 .dac_nids = alc880_asus_dac_nids,
4027 .dig_out_nid = ALC880_DIGOUT_NID,
4028 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4029 .channel_mode = alc880_threestack_modes,
4030 .need_dac_fix = 1,
4031 .input_mux = &alc880_capture_source,
4032 .unsol_event = alc880_uniwill_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004033 .init_hook = alc880_uniwill_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004034 },
4035 [ALC880_UNIWILL_P53] = {
4036 .mixers = { alc880_uniwill_p53_mixer },
4037 .init_verbs = { alc880_volume_init_verbs,
4038 alc880_uniwill_p53_init_verbs },
4039 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4040 .dac_nids = alc880_asus_dac_nids,
4041 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004042 .channel_mode = alc880_threestack_modes,
4043 .input_mux = &alc880_capture_source,
4044 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004045 .init_hook = alc880_uniwill_p53_init_hook,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004046 },
4047 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004048 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004049 .init_verbs = { alc880_volume_init_verbs,
4050 alc880_uniwill_p53_init_verbs,
4051 alc880_beep_init_verbs },
4052 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4053 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02004054 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004055 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4056 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02004057 .input_mux = &alc880_capture_source,
4058 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004059 .init_hook = alc880_uniwill_p53_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004060 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004061 [ALC880_CLEVO] = {
4062 .mixers = { alc880_three_stack_mixer },
4063 .init_verbs = { alc880_volume_init_verbs,
4064 alc880_pin_clevo_init_verbs },
4065 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4066 .dac_nids = alc880_dac_nids,
4067 .hp_nid = 0x03,
4068 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4069 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004070 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004071 .input_mux = &alc880_capture_source,
4072 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004073 [ALC880_LG] = {
4074 .mixers = { alc880_lg_mixer },
4075 .init_verbs = { alc880_volume_init_verbs,
4076 alc880_lg_init_verbs },
4077 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
4078 .dac_nids = alc880_lg_dac_nids,
4079 .dig_out_nid = ALC880_DIGOUT_NID,
4080 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
4081 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004082 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004083 .input_mux = &alc880_lg_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004084 .unsol_event = alc_automute_amp_unsol_event,
4085 .init_hook = alc880_lg_init_hook,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004086#ifdef CONFIG_SND_HDA_POWER_SAVE
4087 .loopbacks = alc880_lg_loopbacks,
4088#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004089 },
Takashi Iwaid6815182006-03-23 16:06:23 +01004090 [ALC880_LG_LW] = {
4091 .mixers = { alc880_lg_lw_mixer },
4092 .init_verbs = { alc880_volume_init_verbs,
4093 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004094 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01004095 .dac_nids = alc880_dac_nids,
4096 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004097 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
4098 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01004099 .input_mux = &alc880_lg_lw_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004100 .unsol_event = alc_automute_amp_unsol_event,
4101 .init_hook = alc880_lg_lw_init_hook,
Takashi Iwaid6815182006-03-23 16:06:23 +01004102 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004103 [ALC880_MEDION_RIM] = {
4104 .mixers = { alc880_medion_rim_mixer },
4105 .init_verbs = { alc880_volume_init_verbs,
4106 alc880_medion_rim_init_verbs,
4107 alc_gpio2_init_verbs },
4108 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4109 .dac_nids = alc880_dac_nids,
4110 .dig_out_nid = ALC880_DIGOUT_NID,
4111 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4112 .channel_mode = alc880_2_jack_modes,
4113 .input_mux = &alc880_medion_rim_capture_source,
4114 .unsol_event = alc880_medion_rim_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004115 .init_hook = alc880_medion_rim_init_hook,
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004116 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004117#ifdef CONFIG_SND_DEBUG
4118 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004119 .mixers = { alc880_test_mixer },
4120 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004121 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
4122 .dac_nids = alc880_test_dac_nids,
4123 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004124 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
4125 .channel_mode = alc880_test_modes,
4126 .input_mux = &alc880_test_capture_source,
4127 },
4128#endif
4129};
4130
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004131/*
4132 * Automatic parse of I/O pins from the BIOS configuration
4133 */
4134
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004135enum {
4136 ALC_CTL_WIDGET_VOL,
4137 ALC_CTL_WIDGET_MUTE,
4138 ALC_CTL_BIND_MUTE,
4139};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004140static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004141 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
4142 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01004143 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004144};
4145
4146/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004147static int add_control(struct alc_spec *spec, int type, const char *name,
4148 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004149{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004150 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004151
Takashi Iwai603c4012008-07-30 15:01:44 +02004152 snd_array_init(&spec->kctls, sizeof(*knew), 32);
4153 knew = snd_array_new(&spec->kctls);
4154 if (!knew)
4155 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004156 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07004157 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004158 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004159 return -ENOMEM;
4160 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004161 return 0;
4162}
4163
4164#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
4165#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
4166#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
4167#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
4168#define alc880_is_input_pin(nid) ((nid) >= 0x18)
4169#define alc880_input_pin_idx(nid) ((nid) - 0x18)
4170#define alc880_idx_to_dac(nid) ((nid) + 0x02)
4171#define alc880_dac_to_idx(nid) ((nid) - 0x02)
4172#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
4173#define alc880_idx_to_selector(nid) ((nid) + 0x10)
4174#define ALC880_PIN_CD_NID 0x1c
4175
4176/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004177static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
4178 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004179{
4180 hda_nid_t nid;
4181 int assigned[4];
4182 int i, j;
4183
4184 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004185 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004186
4187 /* check the pins hardwired to audio widget */
4188 for (i = 0; i < cfg->line_outs; i++) {
4189 nid = cfg->line_out_pins[i];
4190 if (alc880_is_fixed_pin(nid)) {
4191 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01004192 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004193 assigned[idx] = 1;
4194 }
4195 }
4196 /* left pins can be connect to any audio widget */
4197 for (i = 0; i < cfg->line_outs; i++) {
4198 nid = cfg->line_out_pins[i];
4199 if (alc880_is_fixed_pin(nid))
4200 continue;
4201 /* search for an empty channel */
4202 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004203 if (!assigned[j]) {
4204 spec->multiout.dac_nids[i] =
4205 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004206 assigned[j] = 1;
4207 break;
4208 }
4209 }
4210 }
4211 spec->multiout.num_dacs = cfg->line_outs;
4212 return 0;
4213}
4214
4215/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01004216static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
4217 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004218{
4219 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004220 static const char *chname[4] = {
4221 "Front", "Surround", NULL /*CLFE*/, "Side"
4222 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004223 hda_nid_t nid;
4224 int i, err;
4225
4226 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004227 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004228 continue;
4229 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4230 if (i == 2) {
4231 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004232 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4233 "Center Playback Volume",
4234 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
4235 HDA_OUTPUT));
4236 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004237 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004238 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4239 "LFE Playback Volume",
4240 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
4241 HDA_OUTPUT));
4242 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004243 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004244 err = add_control(spec, ALC_CTL_BIND_MUTE,
4245 "Center Playback Switch",
4246 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
4247 HDA_INPUT));
4248 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004249 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004250 err = add_control(spec, ALC_CTL_BIND_MUTE,
4251 "LFE Playback Switch",
4252 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
4253 HDA_INPUT));
4254 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004255 return err;
4256 } else {
4257 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004258 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4259 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4260 HDA_OUTPUT));
4261 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004262 return err;
4263 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004264 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4265 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4266 HDA_INPUT));
4267 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004268 return err;
4269 }
4270 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004271 return 0;
4272}
4273
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004274/* add playback controls for speaker and HP outputs */
4275static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
4276 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004277{
4278 hda_nid_t nid;
4279 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004280 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004281
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004282 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004283 return 0;
4284
4285 if (alc880_is_fixed_pin(pin)) {
4286 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01004287 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004288 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004289 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004290 else
4291 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004292 /* control HP volume/switch on the output mixer amp */
4293 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004294 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004295 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4296 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
4297 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004298 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004299 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004300 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4301 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
4302 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004303 return err;
4304 } else if (alc880_is_multi_pin(pin)) {
4305 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004306 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004307 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004308 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4309 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
4310 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004311 return err;
4312 }
4313 return 0;
4314}
4315
4316/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004317static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4318 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01004319 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004320{
4321 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01004322 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004323
4324 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004325 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4326 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4327 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004328 return err;
4329 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004330 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4331 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4332 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004333 return err;
4334 return 0;
4335}
4336
4337/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01004338static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
4339 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004340{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004341 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004342 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004343
4344 for (i = 0; i < AUTO_PIN_LAST; i++) {
4345 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01004346 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01004347 err = new_analog_input(spec, cfg->input_pins[i],
4348 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01004349 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004350 if (err < 0)
4351 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004352 imux->items[imux->num_items].label =
4353 auto_pin_cfg_labels[i];
4354 imux->items[imux->num_items].index =
4355 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004356 imux->num_items++;
4357 }
4358 }
4359 return 0;
4360}
4361
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004362static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
4363 unsigned int pin_type)
4364{
4365 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4366 pin_type);
4367 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01004368 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4369 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004370}
4371
Kailang Yangdf694da2005-12-05 19:42:22 +01004372static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
4373 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004374 int dac_idx)
4375{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004376 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004377 /* need the manual connection? */
4378 if (alc880_is_multi_pin(nid)) {
4379 struct alc_spec *spec = codec->spec;
4380 int idx = alc880_multi_pin_idx(nid);
4381 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
4382 AC_VERB_SET_CONNECT_SEL,
4383 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
4384 }
4385}
4386
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004387static int get_pin_type(int line_out_type)
4388{
4389 if (line_out_type == AUTO_PIN_HP_OUT)
4390 return PIN_HP;
4391 else
4392 return PIN_OUT;
4393}
4394
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004395static void alc880_auto_init_multi_out(struct hda_codec *codec)
4396{
4397 struct alc_spec *spec = codec->spec;
4398 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02004399
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004400 for (i = 0; i < spec->autocfg.line_outs; i++) {
4401 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004402 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4403 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004404 }
4405}
4406
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004407static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004408{
4409 struct alc_spec *spec = codec->spec;
4410 hda_nid_t pin;
4411
Takashi Iwai82bc9552006-03-21 11:24:42 +01004412 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004413 if (pin) /* connect to front */
4414 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004415 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004416 if (pin) /* connect to front */
4417 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
4418}
4419
4420static void alc880_auto_init_analog_input(struct hda_codec *codec)
4421{
4422 struct alc_spec *spec = codec->spec;
4423 int i;
4424
4425 for (i = 0; i < AUTO_PIN_LAST; i++) {
4426 hda_nid_t nid = spec->autocfg.input_pins[i];
4427 if (alc880_is_input_pin(nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01004428 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01004429 if (nid != ALC880_PIN_CD_NID &&
4430 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004431 snd_hda_codec_write(codec, nid, 0,
4432 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004433 AMP_OUT_MUTE);
4434 }
4435 }
4436}
4437
4438/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004439/* return 1 if successful, 0 if the proper config is not found,
4440 * or a negative error code
4441 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004442static int alc880_parse_auto_config(struct hda_codec *codec)
4443{
4444 struct alc_spec *spec = codec->spec;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004445 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +01004446 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004447
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004448 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4449 alc880_ignore);
4450 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004451 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004452 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004453 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01004454
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004455 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
4456 if (err < 0)
4457 return err;
4458 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
4459 if (err < 0)
4460 return err;
4461 err = alc880_auto_create_extra_out(spec,
4462 spec->autocfg.speaker_pins[0],
4463 "Speaker");
4464 if (err < 0)
4465 return err;
4466 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
4467 "Headphone");
4468 if (err < 0)
4469 return err;
4470 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
4471 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004472 return err;
4473
4474 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4475
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004476 /* check multiple SPDIF-out (for recent codecs) */
4477 for (i = 0; i < spec->autocfg.dig_outs; i++) {
4478 hda_nid_t dig_nid;
4479 err = snd_hda_get_connections(codec,
4480 spec->autocfg.dig_out_pins[i],
4481 &dig_nid, 1);
4482 if (err < 0)
4483 continue;
4484 if (!i)
4485 spec->multiout.dig_out_nid = dig_nid;
4486 else {
4487 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
4488 spec->slave_dig_outs[i - 1] = dig_nid;
4489 if (i == ARRAY_SIZE(spec->slave_dig_outs) - 1)
4490 break;
4491 }
4492 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004493 if (spec->autocfg.dig_in_pin)
4494 spec->dig_in_nid = ALC880_DIGIN_NID;
4495
Takashi Iwai603c4012008-07-30 15:01:44 +02004496 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01004497 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004498
Takashi Iwaid88897e2008-10-31 15:01:37 +01004499 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004500
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004501 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004502 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004503
Takashi Iwai4a79ba32009-04-22 16:31:35 +02004504 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
4505
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004506 return 1;
4507}
4508
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004509/* additional initialization for auto-configuration model */
4510static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004511{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004512 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004513 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004514 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004515 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004516 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02004517 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004518}
4519
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004520static void set_capture_mixer(struct alc_spec *spec)
4521{
Takashi Iwaia23b6882009-03-23 15:21:36 +01004522 static struct snd_kcontrol_new *caps[2][3] = {
4523 { alc_capture_mixer_nosrc1,
4524 alc_capture_mixer_nosrc2,
4525 alc_capture_mixer_nosrc3 },
4526 { alc_capture_mixer1,
4527 alc_capture_mixer2,
4528 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004529 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01004530 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
4531 int mux;
4532 if (spec->input_mux && spec->input_mux->num_items > 1)
4533 mux = 1;
4534 else
4535 mux = 0;
4536 spec->cap_mixer = caps[mux][spec->num_adc_nids - 1];
4537 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004538}
4539
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004540#define set_beep_amp(spec, nid, idx, dir) \
4541 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
4542
4543/*
4544 * OK, here we have finally the patch for ALC880
4545 */
4546
Linus Torvalds1da177e2005-04-16 15:20:36 -07004547static int patch_alc880(struct hda_codec *codec)
4548{
4549 struct alc_spec *spec;
4550 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01004551 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004552
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004553 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004554 if (spec == NULL)
4555 return -ENOMEM;
4556
4557 codec->spec = spec;
4558
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004559 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
4560 alc880_models,
4561 alc880_cfg_tbl);
4562 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +02004563 printk(KERN_INFO "hda_codec: Unknown model for %s, "
4564 "trying auto-probe from BIOS...\n", codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004565 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004566 }
4567
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004568 if (board_config == ALC880_AUTO) {
4569 /* automatic parse from the BIOS config */
4570 err = alc880_parse_auto_config(codec);
4571 if (err < 0) {
4572 alc_free(codec);
4573 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004574 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004575 printk(KERN_INFO
4576 "hda_codec: Cannot set up configuration "
4577 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004578 board_config = ALC880_3ST;
4579 }
4580 }
4581
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09004582 err = snd_hda_attach_beep_device(codec, 0x1);
4583 if (err < 0) {
4584 alc_free(codec);
4585 return err;
4586 }
4587
Kailang Yangdf694da2005-12-05 19:42:22 +01004588 if (board_config != ALC880_AUTO)
4589 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004590
Linus Torvalds1da177e2005-04-16 15:20:36 -07004591 spec->stream_analog_playback = &alc880_pcm_analog_playback;
4592 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01004593 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004594
Linus Torvalds1da177e2005-04-16 15:20:36 -07004595 spec->stream_digital_playback = &alc880_pcm_digital_playback;
4596 spec->stream_digital_capture = &alc880_pcm_digital_capture;
4597
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004598 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004599 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01004600 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004601 /* get type */
4602 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004603 if (wcap != AC_WID_AUD_IN) {
4604 spec->adc_nids = alc880_adc_nids_alt;
4605 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004606 } else {
4607 spec->adc_nids = alc880_adc_nids;
4608 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004609 }
4610 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004611 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004612 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004613
Takashi Iwai2134ea42008-01-10 16:53:55 +01004614 spec->vmaster_nid = 0x0c;
4615
Linus Torvalds1da177e2005-04-16 15:20:36 -07004616 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004617 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004618 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02004619#ifdef CONFIG_SND_HDA_POWER_SAVE
4620 if (!spec->loopback.amplist)
4621 spec->loopback.amplist = alc880_loopbacks;
4622#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01004623 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004624
4625 return 0;
4626}
4627
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004628
Linus Torvalds1da177e2005-04-16 15:20:36 -07004629/*
4630 * ALC260 support
4631 */
4632
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004633static hda_nid_t alc260_dac_nids[1] = {
4634 /* front */
4635 0x02,
4636};
4637
4638static hda_nid_t alc260_adc_nids[1] = {
4639 /* ADC0 */
4640 0x04,
4641};
4642
Kailang Yangdf694da2005-12-05 19:42:22 +01004643static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004644 /* ADC1 */
4645 0x05,
4646};
4647
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004648/* NIDs used when simultaneous access to both ADCs makes sense. Note that
4649 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
4650 */
4651static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004652 /* ADC0, ADC1 */
4653 0x04, 0x05
4654};
4655
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004656#define ALC260_DIGOUT_NID 0x03
4657#define ALC260_DIGIN_NID 0x06
4658
4659static struct hda_input_mux alc260_capture_source = {
4660 .num_items = 4,
4661 .items = {
4662 { "Mic", 0x0 },
4663 { "Front Mic", 0x1 },
4664 { "Line", 0x2 },
4665 { "CD", 0x4 },
4666 },
4667};
4668
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004669/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004670 * headphone jack and the internal CD lines since these are the only pins at
4671 * which audio can appear. For flexibility, also allow the option of
4672 * recording the mixer output on the second ADC (ADC0 doesn't have a
4673 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004674 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004675static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
4676 {
4677 .num_items = 3,
4678 .items = {
4679 { "Mic/Line", 0x0 },
4680 { "CD", 0x4 },
4681 { "Headphone", 0x2 },
4682 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004683 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004684 {
4685 .num_items = 4,
4686 .items = {
4687 { "Mic/Line", 0x0 },
4688 { "CD", 0x4 },
4689 { "Headphone", 0x2 },
4690 { "Mixer", 0x5 },
4691 },
4692 },
4693
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004694};
4695
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004696/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
4697 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004698 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004699static struct hda_input_mux alc260_acer_capture_sources[2] = {
4700 {
4701 .num_items = 4,
4702 .items = {
4703 { "Mic", 0x0 },
4704 { "Line", 0x2 },
4705 { "CD", 0x4 },
4706 { "Headphone", 0x5 },
4707 },
4708 },
4709 {
4710 .num_items = 5,
4711 .items = {
4712 { "Mic", 0x0 },
4713 { "Line", 0x2 },
4714 { "CD", 0x4 },
4715 { "Headphone", 0x6 },
4716 { "Mixer", 0x5 },
4717 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004718 },
4719};
Michael Schwingencc959482009-02-22 18:58:45 +01004720
4721/* Maxdata Favorit 100XS */
4722static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
4723 {
4724 .num_items = 2,
4725 .items = {
4726 { "Line/Mic", 0x0 },
4727 { "CD", 0x4 },
4728 },
4729 },
4730 {
4731 .num_items = 3,
4732 .items = {
4733 { "Line/Mic", 0x0 },
4734 { "CD", 0x4 },
4735 { "Mixer", 0x5 },
4736 },
4737 },
4738};
4739
Linus Torvalds1da177e2005-04-16 15:20:36 -07004740/*
4741 * This is just place-holder, so there's something for alc_build_pcms to look
4742 * at when it calculates the maximum number of channels. ALC260 has no mixer
4743 * element which allows changing the channel mode, so the verb list is
4744 * never used.
4745 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004746static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004747 { 2, NULL },
4748};
4749
Kailang Yangdf694da2005-12-05 19:42:22 +01004750
4751/* Mixer combinations
4752 *
4753 * basic: base_output + input + pc_beep + capture
4754 * HP: base_output + input + capture_alt
4755 * HP_3013: hp_3013 + input + capture
4756 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004757 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01004758 */
4759
4760static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004761 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004762 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004763 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4764 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4765 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4766 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4767 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004768};
Kailang Yangdf694da2005-12-05 19:42:22 +01004769
4770static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004771 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4772 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4773 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4774 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4775 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4776 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4777 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
4778 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004779 { } /* end */
4780};
4781
Takashi Iwaibec15c32008-01-28 18:16:30 +01004782/* update HP, line and mono out pins according to the master switch */
4783static void alc260_hp_master_update(struct hda_codec *codec,
4784 hda_nid_t hp, hda_nid_t line,
4785 hda_nid_t mono)
4786{
4787 struct alc_spec *spec = codec->spec;
4788 unsigned int val = spec->master_sw ? PIN_HP : 0;
4789 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004790 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004791 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004792 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004793 val);
4794 /* mono (speaker) depending on the HP jack sense */
4795 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004796 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004797 val);
4798}
4799
4800static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
4801 struct snd_ctl_elem_value *ucontrol)
4802{
4803 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4804 struct alc_spec *spec = codec->spec;
4805 *ucontrol->value.integer.value = spec->master_sw;
4806 return 0;
4807}
4808
4809static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
4810 struct snd_ctl_elem_value *ucontrol)
4811{
4812 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4813 struct alc_spec *spec = codec->spec;
4814 int val = !!*ucontrol->value.integer.value;
4815 hda_nid_t hp, line, mono;
4816
4817 if (val == spec->master_sw)
4818 return 0;
4819 spec->master_sw = val;
4820 hp = (kcontrol->private_value >> 16) & 0xff;
4821 line = (kcontrol->private_value >> 8) & 0xff;
4822 mono = kcontrol->private_value & 0xff;
4823 alc260_hp_master_update(codec, hp, line, mono);
4824 return 1;
4825}
4826
4827static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
4828 {
4829 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4830 .name = "Master Playback Switch",
4831 .info = snd_ctl_boolean_mono_info,
4832 .get = alc260_hp_master_sw_get,
4833 .put = alc260_hp_master_sw_put,
4834 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
4835 },
4836 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4837 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
4838 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4839 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4840 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
4841 HDA_OUTPUT),
4842 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4843 { } /* end */
4844};
4845
4846static struct hda_verb alc260_hp_unsol_verbs[] = {
4847 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4848 {},
4849};
4850
4851static void alc260_hp_automute(struct hda_codec *codec)
4852{
4853 struct alc_spec *spec = codec->spec;
4854 unsigned int present;
4855
4856 present = snd_hda_codec_read(codec, 0x10, 0,
4857 AC_VERB_GET_PIN_SENSE, 0);
4858 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4859 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
4860}
4861
4862static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
4863{
4864 if ((res >> 26) == ALC880_HP_EVENT)
4865 alc260_hp_automute(codec);
4866}
4867
Kailang Yangdf694da2005-12-05 19:42:22 +01004868static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01004869 {
4870 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4871 .name = "Master Playback Switch",
4872 .info = snd_ctl_boolean_mono_info,
4873 .get = alc260_hp_master_sw_get,
4874 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004875 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01004876 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004877 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4878 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4879 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
4880 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
4881 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4882 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01004883 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4884 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02004885 { } /* end */
4886};
4887
Kailang Yang3f878302008-08-26 13:02:23 +02004888static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
4889 .ops = &snd_hda_bind_vol,
4890 .values = {
4891 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
4892 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
4893 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
4894 0
4895 },
4896};
4897
4898static struct hda_bind_ctls alc260_dc7600_bind_switch = {
4899 .ops = &snd_hda_bind_sw,
4900 .values = {
4901 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
4902 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
4903 0
4904 },
4905};
4906
4907static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
4908 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
4909 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
4910 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
4911 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4912 { } /* end */
4913};
4914
Takashi Iwaibec15c32008-01-28 18:16:30 +01004915static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
4916 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4917 {},
4918};
4919
4920static void alc260_hp_3013_automute(struct hda_codec *codec)
4921{
4922 struct alc_spec *spec = codec->spec;
4923 unsigned int present;
4924
4925 present = snd_hda_codec_read(codec, 0x15, 0,
4926 AC_VERB_GET_PIN_SENSE, 0);
4927 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004928 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01004929}
4930
4931static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
4932 unsigned int res)
4933{
4934 if ((res >> 26) == ALC880_HP_EVENT)
4935 alc260_hp_3013_automute(codec);
4936}
4937
Kailang Yang3f878302008-08-26 13:02:23 +02004938static void alc260_hp_3012_automute(struct hda_codec *codec)
4939{
4940 unsigned int present, bits;
4941
4942 present = snd_hda_codec_read(codec, 0x10, 0,
4943 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
4944
4945 bits = present ? 0 : PIN_OUT;
4946 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4947 bits);
4948 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4949 bits);
4950 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4951 bits);
4952}
4953
4954static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
4955 unsigned int res)
4956{
4957 if ((res >> 26) == ALC880_HP_EVENT)
4958 alc260_hp_3012_automute(codec);
4959}
4960
4961/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004962 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
4963 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004964static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004965 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004966 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004967 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004968 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4969 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4970 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
4971 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004972 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004973 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4974 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004975 { } /* end */
4976};
4977
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004978/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
4979 * versions of the ALC260 don't act on requests to enable mic bias from NID
4980 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
4981 * datasheet doesn't mention this restriction. At this stage it's not clear
4982 * whether this behaviour is intentional or is a hardware bug in chip
4983 * revisions available in early 2006. Therefore for now allow the
4984 * "Headphone Jack Mode" control to span all choices, but if it turns out
4985 * that the lack of mic bias for this NID is intentional we could change the
4986 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4987 *
4988 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
4989 * don't appear to make the mic bias available from the "line" jack, even
4990 * though the NID used for this jack (0x14) can supply it. The theory is
4991 * that perhaps Acer have included blocking capacitors between the ALC260
4992 * and the output jack. If this turns out to be the case for all such
4993 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
4994 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01004995 *
4996 * The C20x Tablet series have a mono internal speaker which is controlled
4997 * via the chip's Mono sum widget and pin complex, so include the necessary
4998 * controls for such models. On models without a "mono speaker" the control
4999 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005000 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005001static struct snd_kcontrol_new alc260_acer_mixer[] = {
5002 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5003 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005004 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005005 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01005006 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005007 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01005008 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005009 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5010 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5011 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5012 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5013 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5014 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5015 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5016 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005017 { } /* end */
5018};
5019
Michael Schwingencc959482009-02-22 18:58:45 +01005020/* Maxdata Favorit 100XS: one output and one input (0x12) jack
5021 */
5022static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
5023 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5024 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
5025 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
5026 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5027 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5028 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5029 { } /* end */
5030};
5031
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005032/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
5033 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
5034 */
5035static struct snd_kcontrol_new alc260_will_mixer[] = {
5036 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5037 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5038 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5039 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5040 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5041 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5042 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5043 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5044 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5045 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005046 { } /* end */
5047};
5048
5049/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
5050 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
5051 */
5052static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
5053 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5054 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5055 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5056 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5057 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5058 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
5059 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
5060 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5061 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5062 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5063 { } /* end */
5064};
5065
Kailang Yangdf694da2005-12-05 19:42:22 +01005066/*
5067 * initialization verbs
5068 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07005069static struct hda_verb alc260_init_verbs[] = {
5070 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005071 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005072 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005073 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005074 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005075 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005076 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005077 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005078 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02005079 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005080 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01005081 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005082 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02005083 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005084 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02005085 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005086 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02005087 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5088 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02005089 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005090 /* set connection select to line in (default select for this ADC) */
5091 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02005092 /* mute capture amp left and right */
5093 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5094 /* set connection select to line in (default select for this ADC) */
5095 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02005096 /* set vol=0 Line-Out mixer amp left and right */
5097 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5098 /* unmute pin widget amp left and right (no gain on this amp) */
5099 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5100 /* set vol=0 HP mixer amp left and right */
5101 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5102 /* unmute pin widget amp left and right (no gain on this amp) */
5103 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5104 /* set vol=0 Mono mixer amp left and right */
5105 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5106 /* unmute pin widget amp left and right (no gain on this amp) */
5107 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5108 /* unmute LINE-2 out pin */
5109 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005110 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5111 * Line In 2 = 0x03
5112 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005113 /* mute analog inputs */
5114 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5115 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5116 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5117 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5118 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005119 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005120 /* mute Front out path */
5121 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5122 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5123 /* mute Headphone out path */
5124 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5125 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5126 /* mute Mono out path */
5127 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5128 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005129 { }
5130};
5131
Takashi Iwai474167d2006-05-17 17:17:43 +02005132#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01005133static struct hda_verb alc260_hp_init_verbs[] = {
5134 /* Headphone and output */
5135 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5136 /* mono output */
5137 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5138 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5139 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5140 /* Mic2 (front panel) pin widget for input and vref at 80% */
5141 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5142 /* Line In pin widget for input */
5143 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5144 /* Line-2 pin widget for output */
5145 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5146 /* CD pin widget for input */
5147 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5148 /* unmute amp left and right */
5149 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5150 /* set connection select to line in (default select for this ADC) */
5151 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5152 /* unmute Line-Out mixer amp left and right (volume = 0) */
5153 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5154 /* mute pin widget amp left and right (no gain on this amp) */
5155 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5156 /* unmute HP mixer amp left and right (volume = 0) */
5157 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5158 /* mute pin widget amp left and right (no gain on this amp) */
5159 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005160 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5161 * Line In 2 = 0x03
5162 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005163 /* mute analog inputs */
5164 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5165 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5166 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5167 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5168 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005169 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5170 /* Unmute Front out path */
5171 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5172 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5173 /* Unmute Headphone out path */
5174 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5175 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5176 /* Unmute Mono out path */
5177 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5178 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5179 { }
5180};
Takashi Iwai474167d2006-05-17 17:17:43 +02005181#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005182
5183static struct hda_verb alc260_hp_3013_init_verbs[] = {
5184 /* Line out and output */
5185 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5186 /* mono output */
5187 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5188 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5189 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5190 /* Mic2 (front panel) pin widget for input and vref at 80% */
5191 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5192 /* Line In pin widget for input */
5193 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5194 /* Headphone pin widget for output */
5195 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5196 /* CD pin widget for input */
5197 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5198 /* unmute amp left and right */
5199 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5200 /* set connection select to line in (default select for this ADC) */
5201 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5202 /* unmute Line-Out mixer amp left and right (volume = 0) */
5203 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5204 /* mute pin widget amp left and right (no gain on this amp) */
5205 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5206 /* unmute HP mixer amp left and right (volume = 0) */
5207 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5208 /* mute pin widget amp left and right (no gain on this amp) */
5209 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005210 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5211 * Line In 2 = 0x03
5212 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005213 /* mute analog inputs */
5214 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5215 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5216 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5217 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5218 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005219 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5220 /* Unmute Front out path */
5221 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5222 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5223 /* Unmute Headphone out path */
5224 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5225 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5226 /* Unmute Mono out path */
5227 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5228 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5229 { }
5230};
5231
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005232/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005233 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
5234 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005235 */
5236static struct hda_verb alc260_fujitsu_init_verbs[] = {
5237 /* Disable all GPIOs */
5238 {0x01, AC_VERB_SET_GPIO_MASK, 0},
5239 /* Internal speaker is connected to headphone pin */
5240 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5241 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
5242 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005243 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
5244 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5245 /* Ensure all other unused pins are disabled and muted. */
5246 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5247 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005248 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005249 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005250 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005251 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5252 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5253 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005254
Jonathan Woithef7ace402006-02-28 11:46:14 +01005255 /* Disable digital (SPDIF) pins */
5256 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5257 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005258
Kailang Yangea1fb292008-08-26 12:58:38 +02005259 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01005260 * when acting as an output.
5261 */
5262 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5263
5264 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01005265 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5266 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5267 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5268 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5269 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5270 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5271 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5272 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5273 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005274
Jonathan Woithef7ace402006-02-28 11:46:14 +01005275 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
5276 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5277 /* Unmute Line1 pin widget output buffer since it starts as an output.
5278 * If the pin mode is changed by the user the pin mode control will
5279 * take care of enabling the pin's input/output buffers as needed.
5280 * Therefore there's no need to enable the input buffer at this
5281 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005282 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005283 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02005284 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005285 * mixer ctrl)
5286 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005287 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005288
Jonathan Woithef7ace402006-02-28 11:46:14 +01005289 /* Mute capture amp left and right */
5290 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005291 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01005292 * in (on mic1 pin)
5293 */
5294 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005295
Jonathan Woithef7ace402006-02-28 11:46:14 +01005296 /* Do the same for the second ADC: mute capture input amp and
5297 * set ADC connection to line in (on mic1 pin)
5298 */
5299 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5300 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005301
Jonathan Woithef7ace402006-02-28 11:46:14 +01005302 /* Mute all inputs to mixer widget (even unconnected ones) */
5303 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5304 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5305 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5306 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5307 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5308 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5309 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5310 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005311
5312 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005313};
5314
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005315/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
5316 * similar laptops (adapted from Fujitsu init verbs).
5317 */
5318static struct hda_verb alc260_acer_init_verbs[] = {
5319 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
5320 * the headphone jack. Turn this on and rely on the standard mute
5321 * methods whenever the user wants to turn these outputs off.
5322 */
5323 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5324 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5325 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5326 /* Internal speaker/Headphone jack is connected to Line-out pin */
5327 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5328 /* Internal microphone/Mic jack is connected to Mic1 pin */
5329 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5330 /* Line In jack is connected to Line1 pin */
5331 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01005332 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
5333 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005334 /* Ensure all other unused pins are disabled and muted. */
5335 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5336 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005337 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5338 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5339 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5340 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5341 /* Disable digital (SPDIF) pins */
5342 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5343 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5344
Kailang Yangea1fb292008-08-26 12:58:38 +02005345 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005346 * bus when acting as outputs.
5347 */
5348 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5349 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5350
5351 /* Start with output sum widgets muted and their output gains at min */
5352 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5353 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5354 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5355 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5356 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5357 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5358 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5359 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5360 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5361
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005362 /* Unmute Line-out pin widget amp left and right
5363 * (no equiv mixer ctrl)
5364 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005365 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01005366 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
5367 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005368 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5369 * inputs. If the pin mode is changed by the user the pin mode control
5370 * will take care of enabling the pin's input/output buffers as needed.
5371 * Therefore there's no need to enable the input buffer at this
5372 * stage.
5373 */
5374 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5375 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5376
5377 /* Mute capture amp left and right */
5378 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5379 /* Set ADC connection select to match default mixer setting - mic
5380 * (on mic1 pin)
5381 */
5382 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5383
5384 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005385 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005386 */
5387 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005388 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005389
5390 /* Mute all inputs to mixer widget (even unconnected ones) */
5391 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5392 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5393 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5394 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5395 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5396 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5397 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5398 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5399
5400 { }
5401};
5402
Michael Schwingencc959482009-02-22 18:58:45 +01005403/* Initialisation sequence for Maxdata Favorit 100XS
5404 * (adapted from Acer init verbs).
5405 */
5406static struct hda_verb alc260_favorit100_init_verbs[] = {
5407 /* GPIO 0 enables the output jack.
5408 * Turn this on and rely on the standard mute
5409 * methods whenever the user wants to turn these outputs off.
5410 */
5411 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5412 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5413 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5414 /* Line/Mic input jack is connected to Mic1 pin */
5415 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5416 /* Ensure all other unused pins are disabled and muted. */
5417 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5418 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5419 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5420 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5421 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5422 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5423 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5424 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5425 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5426 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5427 /* Disable digital (SPDIF) pins */
5428 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5429 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5430
5431 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
5432 * bus when acting as outputs.
5433 */
5434 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5435 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5436
5437 /* Start with output sum widgets muted and their output gains at min */
5438 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5439 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5440 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5441 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5442 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5443 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5444 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5445 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5446 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5447
5448 /* Unmute Line-out pin widget amp left and right
5449 * (no equiv mixer ctrl)
5450 */
5451 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5452 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5453 * inputs. If the pin mode is changed by the user the pin mode control
5454 * will take care of enabling the pin's input/output buffers as needed.
5455 * Therefore there's no need to enable the input buffer at this
5456 * stage.
5457 */
5458 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5459
5460 /* Mute capture amp left and right */
5461 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5462 /* Set ADC connection select to match default mixer setting - mic
5463 * (on mic1 pin)
5464 */
5465 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5466
5467 /* Do similar with the second ADC: mute capture input amp and
5468 * set ADC connection to mic to match ALSA's default state.
5469 */
5470 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5471 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5472
5473 /* Mute all inputs to mixer widget (even unconnected ones) */
5474 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5475 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5476 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5477 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5478 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5479 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5480 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5481 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5482
5483 { }
5484};
5485
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005486static struct hda_verb alc260_will_verbs[] = {
5487 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5488 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
5489 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
5490 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5491 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5492 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
5493 {}
5494};
5495
5496static struct hda_verb alc260_replacer_672v_verbs[] = {
5497 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5498 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5499 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
5500
5501 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5502 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5503 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5504
5505 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5506 {}
5507};
5508
5509/* toggle speaker-output according to the hp-jack state */
5510static void alc260_replacer_672v_automute(struct hda_codec *codec)
5511{
5512 unsigned int present;
5513
5514 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
5515 present = snd_hda_codec_read(codec, 0x0f, 0,
5516 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5517 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005518 snd_hda_codec_write_cache(codec, 0x01, 0,
5519 AC_VERB_SET_GPIO_DATA, 1);
5520 snd_hda_codec_write_cache(codec, 0x0f, 0,
5521 AC_VERB_SET_PIN_WIDGET_CONTROL,
5522 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005523 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005524 snd_hda_codec_write_cache(codec, 0x01, 0,
5525 AC_VERB_SET_GPIO_DATA, 0);
5526 snd_hda_codec_write_cache(codec, 0x0f, 0,
5527 AC_VERB_SET_PIN_WIDGET_CONTROL,
5528 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005529 }
5530}
5531
5532static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
5533 unsigned int res)
5534{
5535 if ((res >> 26) == ALC880_HP_EVENT)
5536 alc260_replacer_672v_automute(codec);
5537}
5538
Kailang Yang3f878302008-08-26 13:02:23 +02005539static struct hda_verb alc260_hp_dc7600_verbs[] = {
5540 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
5541 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5542 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5543 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5544 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5545 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5546 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5547 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5548 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5549 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5550 {}
5551};
5552
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005553/* Test configuration for debugging, modelled after the ALC880 test
5554 * configuration.
5555 */
5556#ifdef CONFIG_SND_DEBUG
5557static hda_nid_t alc260_test_dac_nids[1] = {
5558 0x02,
5559};
5560static hda_nid_t alc260_test_adc_nids[2] = {
5561 0x04, 0x05,
5562};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005563/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02005564 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005565 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005566 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005567static struct hda_input_mux alc260_test_capture_sources[2] = {
5568 {
5569 .num_items = 7,
5570 .items = {
5571 { "MIC1 pin", 0x0 },
5572 { "MIC2 pin", 0x1 },
5573 { "LINE1 pin", 0x2 },
5574 { "LINE2 pin", 0x3 },
5575 { "CD pin", 0x4 },
5576 { "LINE-OUT pin", 0x5 },
5577 { "HP-OUT pin", 0x6 },
5578 },
5579 },
5580 {
5581 .num_items = 8,
5582 .items = {
5583 { "MIC1 pin", 0x0 },
5584 { "MIC2 pin", 0x1 },
5585 { "LINE1 pin", 0x2 },
5586 { "LINE2 pin", 0x3 },
5587 { "CD pin", 0x4 },
5588 { "Mixer", 0x5 },
5589 { "LINE-OUT pin", 0x6 },
5590 { "HP-OUT pin", 0x7 },
5591 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005592 },
5593};
5594static struct snd_kcontrol_new alc260_test_mixer[] = {
5595 /* Output driver widgets */
5596 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5597 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5598 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5599 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
5600 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5601 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
5602
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005603 /* Modes for retasking pin widgets
5604 * Note: the ALC260 doesn't seem to act on requests to enable mic
5605 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
5606 * mention this restriction. At this stage it's not clear whether
5607 * this behaviour is intentional or is a hardware bug in chip
5608 * revisions available at least up until early 2006. Therefore for
5609 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
5610 * choices, but if it turns out that the lack of mic bias for these
5611 * NIDs is intentional we could change their modes from
5612 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5613 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005614 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
5615 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
5616 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
5617 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
5618 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
5619 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
5620
5621 /* Loopback mixer controls */
5622 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
5623 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
5624 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
5625 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
5626 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
5627 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
5628 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
5629 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
5630 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5631 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005632 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
5633 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
5634 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
5635 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005636
5637 /* Controls for GPIO pins, assuming they are configured as outputs */
5638 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
5639 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
5640 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
5641 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
5642
Jonathan Woithe92621f12006-02-28 11:47:47 +01005643 /* Switches to allow the digital IO pins to be enabled. The datasheet
5644 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02005645 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01005646 */
5647 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
5648 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
5649
Jonathan Woithef8225f62008-01-08 12:16:54 +01005650 /* A switch allowing EAPD to be enabled. Some laptops seem to use
5651 * this output to turn on an external amplifier.
5652 */
5653 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
5654 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
5655
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005656 { } /* end */
5657};
5658static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005659 /* Enable all GPIOs as outputs with an initial value of 0 */
5660 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
5661 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5662 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
5663
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005664 /* Enable retasking pins as output, initially without power amp */
5665 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5666 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5667 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5668 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5669 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5670 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5671
Jonathan Woithe92621f12006-02-28 11:47:47 +01005672 /* Disable digital (SPDIF) pins initially, but users can enable
5673 * them via a mixer switch. In the case of SPDIF-out, this initverb
5674 * payload also sets the generation to 0, output to be in "consumer"
5675 * PCM format, copyright asserted, no pre-emphasis and no validity
5676 * control.
5677 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005678 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5679 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5680
Kailang Yangea1fb292008-08-26 12:58:38 +02005681 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005682 * OUT1 sum bus when acting as an output.
5683 */
5684 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5685 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
5686 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5687 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
5688
5689 /* Start with output sum widgets muted and their output gains at min */
5690 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5691 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5692 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5693 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5694 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5695 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5696 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5697 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5698 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5699
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005700 /* Unmute retasking pin widget output buffers since the default
5701 * state appears to be output. As the pin mode is changed by the
5702 * user the pin mode control will take care of enabling the pin's
5703 * input/output buffers as needed.
5704 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005705 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5706 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5707 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5708 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5709 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5710 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5711 /* Also unmute the mono-out pin widget */
5712 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5713
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005714 /* Mute capture amp left and right */
5715 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005716 /* Set ADC connection select to match default mixer setting (mic1
5717 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005718 */
5719 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5720
5721 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01005722 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005723 */
5724 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5725 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5726
5727 /* Mute all inputs to mixer widget (even unconnected ones) */
5728 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5729 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5730 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5731 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5732 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5733 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5734 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5735 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5736
5737 { }
5738};
5739#endif
5740
Takashi Iwai63300792008-01-24 15:31:36 +01005741#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
5742#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07005743
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005744#define alc260_pcm_digital_playback alc880_pcm_digital_playback
5745#define alc260_pcm_digital_capture alc880_pcm_digital_capture
5746
Kailang Yangdf694da2005-12-05 19:42:22 +01005747/*
5748 * for BIOS auto-configuration
5749 */
5750
5751static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02005752 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01005753{
5754 hda_nid_t nid_vol;
5755 unsigned long vol_val, sw_val;
5756 char name[32];
5757 int err;
5758
5759 if (nid >= 0x0f && nid < 0x11) {
5760 nid_vol = nid - 0x7;
5761 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5762 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5763 } else if (nid == 0x11) {
5764 nid_vol = nid - 0x7;
5765 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
5766 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
5767 } else if (nid >= 0x12 && nid <= 0x15) {
5768 nid_vol = 0x08;
5769 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5770 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5771 } else
5772 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02005773
Takashi Iwai863b4512008-10-21 17:01:47 +02005774 if (!(*vol_bits & (1 << nid_vol))) {
5775 /* first control for the volume widget */
5776 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
5777 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
5778 if (err < 0)
5779 return err;
5780 *vol_bits |= (1 << nid_vol);
5781 }
Kailang Yangdf694da2005-12-05 19:42:22 +01005782 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005783 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
5784 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005785 return err;
5786 return 1;
5787}
5788
5789/* add playback controls from the parsed DAC table */
5790static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
5791 const struct auto_pin_cfg *cfg)
5792{
5793 hda_nid_t nid;
5794 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02005795 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005796
5797 spec->multiout.num_dacs = 1;
5798 spec->multiout.dac_nids = spec->private_dac_nids;
5799 spec->multiout.dac_nids[0] = 0x02;
5800
5801 nid = cfg->line_out_pins[0];
5802 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005803 err = alc260_add_playback_controls(spec, nid, "Front", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005804 if (err < 0)
5805 return err;
5806 }
5807
Takashi Iwai82bc9552006-03-21 11:24:42 +01005808 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005809 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005810 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005811 if (err < 0)
5812 return err;
5813 }
5814
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005815 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005816 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005817 err = alc260_add_playback_controls(spec, nid, "Headphone",
5818 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005819 if (err < 0)
5820 return err;
5821 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005822 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005823}
5824
5825/* create playback/capture controls for input pins */
5826static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
5827 const struct auto_pin_cfg *cfg)
5828{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005829 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005830 int i, err, idx;
5831
5832 for (i = 0; i < AUTO_PIN_LAST; i++) {
5833 if (cfg->input_pins[i] >= 0x12) {
5834 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005835 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005836 auto_pin_cfg_labels[i], idx,
5837 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005838 if (err < 0)
5839 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005840 imux->items[imux->num_items].label =
5841 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005842 imux->items[imux->num_items].index = idx;
5843 imux->num_items++;
5844 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005845 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01005846 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005847 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005848 auto_pin_cfg_labels[i], idx,
5849 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005850 if (err < 0)
5851 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005852 imux->items[imux->num_items].label =
5853 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005854 imux->items[imux->num_items].index = idx;
5855 imux->num_items++;
5856 }
5857 }
5858 return 0;
5859}
5860
5861static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
5862 hda_nid_t nid, int pin_type,
5863 int sel_idx)
5864{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005865 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01005866 /* need the manual connection? */
5867 if (nid >= 0x12) {
5868 int idx = nid - 0x12;
5869 snd_hda_codec_write(codec, idx + 0x0b, 0,
5870 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01005871 }
5872}
5873
5874static void alc260_auto_init_multi_out(struct hda_codec *codec)
5875{
5876 struct alc_spec *spec = codec->spec;
5877 hda_nid_t nid;
5878
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005879 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005880 if (nid) {
5881 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5882 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
5883 }
Kailang Yangea1fb292008-08-26 12:58:38 +02005884
Takashi Iwai82bc9552006-03-21 11:24:42 +01005885 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005886 if (nid)
5887 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
5888
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005889 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005890 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005891 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005892}
Kailang Yangdf694da2005-12-05 19:42:22 +01005893
5894#define ALC260_PIN_CD_NID 0x16
5895static void alc260_auto_init_analog_input(struct hda_codec *codec)
5896{
5897 struct alc_spec *spec = codec->spec;
5898 int i;
5899
5900 for (i = 0; i < AUTO_PIN_LAST; i++) {
5901 hda_nid_t nid = spec->autocfg.input_pins[i];
5902 if (nid >= 0x12) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01005903 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01005904 if (nid != ALC260_PIN_CD_NID &&
5905 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005906 snd_hda_codec_write(codec, nid, 0,
5907 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01005908 AMP_OUT_MUTE);
5909 }
5910 }
5911}
5912
5913/*
5914 * generic initialization of ADC, input mixers and output mixers
5915 */
5916static struct hda_verb alc260_volume_init_verbs[] = {
5917 /*
5918 * Unmute ADC0-1 and set the default input to mic-in
5919 */
5920 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5921 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5922 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5923 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005924
Kailang Yangdf694da2005-12-05 19:42:22 +01005925 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5926 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005927 * Note: PASD motherboards uses the Line In 2 as the input for
5928 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01005929 */
5930 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005931 /* mute analog inputs */
5932 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5933 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5934 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5935 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5936 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005937
5938 /*
5939 * Set up output mixers (0x08 - 0x0a)
5940 */
5941 /* set vol=0 to output mixers */
5942 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5943 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5944 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5945 /* set up input amps for analog loopback */
5946 /* Amp Indices: DAC = 0, mixer = 1 */
5947 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5948 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5949 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5950 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5951 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5952 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005953
Kailang Yangdf694da2005-12-05 19:42:22 +01005954 { }
5955};
5956
5957static int alc260_parse_auto_config(struct hda_codec *codec)
5958{
5959 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005960 int err;
5961 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
5962
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005963 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5964 alc260_ignore);
5965 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005966 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005967 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
5968 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01005969 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02005970 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01005971 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005972 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
5973 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005974 return err;
5975
5976 spec->multiout.max_channels = 2;
5977
Takashi Iwai0852d7a2009-02-11 11:35:15 +01005978 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01005979 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02005980 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01005981 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01005982
Takashi Iwaid88897e2008-10-31 15:01:37 +01005983 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01005984
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005985 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005986 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005987
Takashi Iwai4a79ba32009-04-22 16:31:35 +02005988 alc_ssid_check(codec, 0x10, 0x15, 0x0f);
5989
Kailang Yangdf694da2005-12-05 19:42:22 +01005990 return 1;
5991}
5992
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005993/* additional initialization for auto-configuration model */
5994static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01005995{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005996 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005997 alc260_auto_init_multi_out(codec);
5998 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005999 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02006000 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006001}
6002
Takashi Iwaicb53c622007-08-10 17:21:45 +02006003#ifdef CONFIG_SND_HDA_POWER_SAVE
6004static struct hda_amp_list alc260_loopbacks[] = {
6005 { 0x07, HDA_INPUT, 0 },
6006 { 0x07, HDA_INPUT, 1 },
6007 { 0x07, HDA_INPUT, 2 },
6008 { 0x07, HDA_INPUT, 3 },
6009 { 0x07, HDA_INPUT, 4 },
6010 { } /* end */
6011};
6012#endif
6013
Kailang Yangdf694da2005-12-05 19:42:22 +01006014/*
6015 * ALC260 configurations
6016 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006017static const char *alc260_models[ALC260_MODEL_LAST] = {
6018 [ALC260_BASIC] = "basic",
6019 [ALC260_HP] = "hp",
6020 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02006021 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006022 [ALC260_FUJITSU_S702X] = "fujitsu",
6023 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006024 [ALC260_WILL] = "will",
6025 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01006026 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006027#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006028 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006029#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006030 [ALC260_AUTO] = "auto",
6031};
6032
6033static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01006034 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006035 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01006036 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01006037 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01006038 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006039 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02006040 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02006041 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006042 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
6043 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
6044 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
6045 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
6046 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
6047 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
6048 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
6049 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
6050 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006051 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006052 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02006053 {}
6054};
6055
Kailang Yangdf694da2005-12-05 19:42:22 +01006056static struct alc_config_preset alc260_presets[] = {
6057 [ALC260_BASIC] = {
6058 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006059 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006060 .init_verbs = { alc260_init_verbs },
6061 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6062 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006063 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Kailang Yangdf694da2005-12-05 19:42:22 +01006064 .adc_nids = alc260_adc_nids,
6065 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6066 .channel_mode = alc260_modes,
6067 .input_mux = &alc260_capture_source,
6068 },
6069 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01006070 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006071 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006072 .init_verbs = { alc260_init_verbs,
6073 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006074 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6075 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006076 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6077 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006078 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6079 .channel_mode = alc260_modes,
6080 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006081 .unsol_event = alc260_hp_unsol_event,
6082 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006083 },
Kailang Yang3f878302008-08-26 13:02:23 +02006084 [ALC260_HP_DC7600] = {
6085 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006086 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02006087 .init_verbs = { alc260_init_verbs,
6088 alc260_hp_dc7600_verbs },
6089 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6090 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006091 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6092 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02006093 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6094 .channel_mode = alc260_modes,
6095 .input_mux = &alc260_capture_source,
6096 .unsol_event = alc260_hp_3012_unsol_event,
6097 .init_hook = alc260_hp_3012_automute,
6098 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006099 [ALC260_HP_3013] = {
6100 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006101 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006102 .init_verbs = { alc260_hp_3013_init_verbs,
6103 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006104 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6105 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006106 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6107 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006108 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6109 .channel_mode = alc260_modes,
6110 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006111 .unsol_event = alc260_hp_3013_unsol_event,
6112 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006113 },
6114 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006115 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006116 .init_verbs = { alc260_fujitsu_init_verbs },
6117 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6118 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01006119 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6120 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01006121 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6122 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006123 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
6124 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01006125 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006126 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006127 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006128 .init_verbs = { alc260_acer_init_verbs },
6129 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6130 .dac_nids = alc260_dac_nids,
6131 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6132 .adc_nids = alc260_dual_adc_nids,
6133 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6134 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006135 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
6136 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006137 },
Michael Schwingencc959482009-02-22 18:58:45 +01006138 [ALC260_FAVORIT100] = {
6139 .mixers = { alc260_favorit100_mixer },
6140 .init_verbs = { alc260_favorit100_init_verbs },
6141 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6142 .dac_nids = alc260_dac_nids,
6143 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6144 .adc_nids = alc260_dual_adc_nids,
6145 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6146 .channel_mode = alc260_modes,
6147 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
6148 .input_mux = alc260_favorit100_capture_sources,
6149 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006150 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006151 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006152 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
6153 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6154 .dac_nids = alc260_dac_nids,
6155 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6156 .adc_nids = alc260_adc_nids,
6157 .dig_out_nid = ALC260_DIGOUT_NID,
6158 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6159 .channel_mode = alc260_modes,
6160 .input_mux = &alc260_capture_source,
6161 },
6162 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006163 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006164 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
6165 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6166 .dac_nids = alc260_dac_nids,
6167 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6168 .adc_nids = alc260_adc_nids,
6169 .dig_out_nid = ALC260_DIGOUT_NID,
6170 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6171 .channel_mode = alc260_modes,
6172 .input_mux = &alc260_capture_source,
6173 .unsol_event = alc260_replacer_672v_unsol_event,
6174 .init_hook = alc260_replacer_672v_automute,
6175 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006176#ifdef CONFIG_SND_DEBUG
6177 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006178 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006179 .init_verbs = { alc260_test_init_verbs },
6180 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
6181 .dac_nids = alc260_test_dac_nids,
6182 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
6183 .adc_nids = alc260_test_adc_nids,
6184 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6185 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006186 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
6187 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006188 },
6189#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006190};
6191
Linus Torvalds1da177e2005-04-16 15:20:36 -07006192static int patch_alc260(struct hda_codec *codec)
6193{
6194 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006195 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006196
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006197 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006198 if (spec == NULL)
6199 return -ENOMEM;
6200
6201 codec->spec = spec;
6202
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006203 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
6204 alc260_models,
6205 alc260_cfg_tbl);
6206 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +02006207 snd_printd(KERN_INFO "hda_codec: Unknown model for %s, "
6208 "trying auto-probe from BIOS...\n",
6209 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01006210 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02006211 }
6212
Kailang Yangdf694da2005-12-05 19:42:22 +01006213 if (board_config == ALC260_AUTO) {
6214 /* automatic parse from the BIOS config */
6215 err = alc260_parse_auto_config(codec);
6216 if (err < 0) {
6217 alc_free(codec);
6218 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006219 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006220 printk(KERN_INFO
6221 "hda_codec: Cannot set up configuration "
6222 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006223 board_config = ALC260_BASIC;
6224 }
Takashi Iwai16ded522005-06-10 19:58:24 +02006225 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006226
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09006227 err = snd_hda_attach_beep_device(codec, 0x1);
6228 if (err < 0) {
6229 alc_free(codec);
6230 return err;
6231 }
6232
Kailang Yangdf694da2005-12-05 19:42:22 +01006233 if (board_config != ALC260_AUTO)
6234 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006235
Linus Torvalds1da177e2005-04-16 15:20:36 -07006236 spec->stream_analog_playback = &alc260_pcm_analog_playback;
6237 spec->stream_analog_capture = &alc260_pcm_analog_capture;
6238
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006239 spec->stream_digital_playback = &alc260_pcm_digital_playback;
6240 spec->stream_digital_capture = &alc260_pcm_digital_capture;
6241
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006242 if (!spec->adc_nids && spec->input_mux) {
6243 /* check whether NID 0x04 is valid */
6244 unsigned int wcap = get_wcaps(codec, 0x04);
6245 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
6246 /* get type */
6247 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
6248 spec->adc_nids = alc260_adc_nids_alt;
6249 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
6250 } else {
6251 spec->adc_nids = alc260_adc_nids;
6252 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
6253 }
6254 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006255 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006256 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006257
Takashi Iwai2134ea42008-01-10 16:53:55 +01006258 spec->vmaster_nid = 0x08;
6259
Linus Torvalds1da177e2005-04-16 15:20:36 -07006260 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006261 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006262 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006263#ifdef CONFIG_SND_HDA_POWER_SAVE
6264 if (!spec->loopback.amplist)
6265 spec->loopback.amplist = alc260_loopbacks;
6266#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01006267 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006268
6269 return 0;
6270}
6271
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006272
Linus Torvalds1da177e2005-04-16 15:20:36 -07006273/*
6274 * ALC882 support
6275 *
6276 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
6277 * configuration. Each pin widget can choose any input DACs and a mixer.
6278 * Each ADC is connected from a mixer of all inputs. This makes possible
6279 * 6-channel independent captures.
6280 *
6281 * In addition, an independent DAC for the multi-playback (not used in this
6282 * driver yet).
6283 */
Kailang Yangdf694da2005-12-05 19:42:22 +01006284#define ALC882_DIGOUT_NID 0x06
6285#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07006286
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01006287static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07006288 { 8, NULL }
6289};
6290
6291static hda_nid_t alc882_dac_nids[4] = {
6292 /* front, rear, clfe, rear_surr */
6293 0x02, 0x03, 0x04, 0x05
6294};
6295
Kailang Yangdf694da2005-12-05 19:42:22 +01006296/* identical with ALC880 */
6297#define alc882_adc_nids alc880_adc_nids
6298#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07006299
Takashi Iwaie1406342008-02-11 18:32:32 +01006300static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
6301static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
6302
Linus Torvalds1da177e2005-04-16 15:20:36 -07006303/* input MUX */
6304/* FIXME: should be a matrix-type input source selection */
6305
6306static struct hda_input_mux alc882_capture_source = {
6307 .num_items = 4,
6308 .items = {
6309 { "Mic", 0x0 },
6310 { "Front Mic", 0x1 },
6311 { "Line", 0x2 },
6312 { "CD", 0x4 },
6313 },
6314};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006315
6316static struct hda_input_mux mb5_capture_source = {
6317 .num_items = 3,
6318 .items = {
6319 { "Mic", 0x1 },
6320 { "Line", 0x2 },
6321 { "CD", 0x4 },
6322 },
6323};
6324
Kailang Yangdf694da2005-12-05 19:42:22 +01006325/*
Kailang Yang272a5272007-05-14 11:00:38 +02006326 * 2ch mode
6327 */
6328static struct hda_verb alc882_3ST_ch2_init[] = {
6329 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6330 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6331 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6332 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6333 { } /* end */
6334};
6335
6336/*
6337 * 6ch mode
6338 */
6339static struct hda_verb alc882_3ST_ch6_init[] = {
6340 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6341 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6342 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6343 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6344 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6345 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6346 { } /* end */
6347};
6348
6349static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
6350 { 2, alc882_3ST_ch2_init },
6351 { 6, alc882_3ST_ch6_init },
6352};
6353
6354/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006355 * 6ch mode
6356 */
6357static struct hda_verb alc882_sixstack_ch6_init[] = {
6358 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6359 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6360 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6361 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6362 { } /* end */
6363};
6364
6365/*
6366 * 8ch mode
6367 */
6368static struct hda_verb alc882_sixstack_ch8_init[] = {
6369 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6370 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6371 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6372 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6373 { } /* end */
6374};
6375
6376static struct hda_channel_mode alc882_sixstack_modes[2] = {
6377 { 6, alc882_sixstack_ch6_init },
6378 { 8, alc882_sixstack_ch8_init },
6379};
6380
Takashi Iwai87350ad2007-08-16 18:19:38 +02006381/*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04006382 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
Takashi Iwai87350ad2007-08-16 18:19:38 +02006383 */
6384
6385/*
6386 * 2ch mode
6387 */
6388static struct hda_verb alc885_mbp_ch2_init[] = {
6389 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6390 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6391 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6392 { } /* end */
6393};
6394
6395/*
6396 * 6ch mode
6397 */
6398static struct hda_verb alc885_mbp_ch6_init[] = {
6399 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6400 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6401 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6402 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6403 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6404 { } /* end */
6405};
6406
6407static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
6408 { 2, alc885_mbp_ch2_init },
6409 { 6, alc885_mbp_ch6_init },
6410};
6411
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006412/*
6413 * 2ch
6414 * Speakers/Woofer/HP = Front
6415 * LineIn = Input
6416 */
6417static struct hda_verb alc885_mb5_ch2_init[] = {
6418 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6419 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6420 { } /* end */
6421};
6422
6423/*
6424 * 6ch mode
6425 * Speakers/HP = Front
6426 * Woofer = LFE
6427 * LineIn = Surround
6428 */
6429static struct hda_verb alc885_mb5_ch6_init[] = {
6430 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6431 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6432 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6433 { } /* end */
6434};
6435
6436static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
6437 { 2, alc885_mb5_ch2_init },
6438 { 6, alc885_mb5_ch6_init },
6439};
Takashi Iwai87350ad2007-08-16 18:19:38 +02006440
Linus Torvalds1da177e2005-04-16 15:20:36 -07006441/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6442 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6443 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01006444static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02006445 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006446 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006447 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006448 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006449 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6450 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006451 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6452 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006453 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006454 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006455 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6456 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6457 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6458 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6459 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6460 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006461 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006462 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6463 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006464 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006465 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006466 { } /* end */
6467};
6468
Takashi Iwai87350ad2007-08-16 18:19:38 +02006469static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01006470 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6471 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
6472 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
6473 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
6474 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6475 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006476 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
6477 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01006478 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006479 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
6480 { } /* end */
6481};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006482
6483static struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006484 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6485 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
6486 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
6487 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
6488 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
6489 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
6490 HDA_CODEC_VOLUME("HP Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
6491 HDA_BIND_MUTE ("HP Playback Switch", 0x0f, 0x02, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006492 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6493 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6494 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
6495 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
6496 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
6497 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0x00, HDA_INPUT),
6498 { } /* end */
6499};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006500
Kailang Yangbdd148a2007-05-08 15:19:08 +02006501static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
6502 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6503 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6504 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6505 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6506 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6507 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6508 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6509 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6510 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02006511 { } /* end */
6512};
6513
Kailang Yang272a5272007-05-14 11:00:38 +02006514static struct snd_kcontrol_new alc882_targa_mixer[] = {
6515 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6516 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6517 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6518 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6519 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6520 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6521 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6522 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6523 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006524 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006525 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6526 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006527 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006528 { } /* end */
6529};
6530
6531/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
6532 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
6533 */
6534static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
6535 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6536 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6537 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6538 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
6539 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6540 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6541 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6542 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6543 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
6544 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
6545 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6546 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006547 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006548 { } /* end */
6549};
6550
Takashi Iwai914759b2007-09-06 14:52:04 +02006551static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
6552 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6553 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6554 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6555 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6556 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6557 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6558 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6559 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6560 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6561 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02006562 { } /* end */
6563};
6564
Kailang Yangdf694da2005-12-05 19:42:22 +01006565static struct snd_kcontrol_new alc882_chmode_mixer[] = {
6566 {
6567 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6568 .name = "Channel Mode",
6569 .info = alc_ch_mode_info,
6570 .get = alc_ch_mode_get,
6571 .put = alc_ch_mode_put,
6572 },
6573 { } /* end */
6574};
6575
Linus Torvalds1da177e2005-04-16 15:20:36 -07006576static struct hda_verb alc882_init_verbs[] = {
6577 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006578 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6579 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6580 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006581 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006582 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6583 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6584 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006585 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006586 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6587 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6588 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006589 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006590 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6591 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6592 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006593
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006594 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006595 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006596 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006597 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006598 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006599 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006600 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006601 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006602 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006603 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006604 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006605 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006606 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006607 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006608 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006609 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006610 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006611 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006612 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6613 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006614 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006615 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6616 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006617 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006618 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6619 /* Line-2 In: Headphone output (output 0 - 0x0c) */
6620 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6621 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6622 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006623 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006624 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006625
6626 /* FIXME: use matrix-type input source selection */
6627 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6628 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02006629 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6630 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6631 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6632 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006633 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006634 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6635 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6636 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6637 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006638 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006639 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6640 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6641 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6642 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6643 /* ADC1: mute amp left and right */
6644 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006645 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02006646 /* ADC2: mute amp left and right */
6647 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006648 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02006649 /* ADC3: mute amp left and right */
6650 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006651 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006652
6653 { }
6654};
6655
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006656static struct hda_verb alc882_eapd_verbs[] = {
6657 /* change to EAPD mode */
6658 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006659 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006660 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006661};
6662
Tobin Davis9102cd12006-12-15 10:02:12 +01006663/* Mac Pro test */
6664static struct snd_kcontrol_new alc882_macpro_mixer[] = {
6665 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6666 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6667 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
6668 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
6669 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006670 /* FIXME: this looks suspicious...
Tobin Davis9102cd12006-12-15 10:02:12 +01006671 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
6672 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006673 */
Tobin Davis9102cd12006-12-15 10:02:12 +01006674 { } /* end */
6675};
6676
6677static struct hda_verb alc882_macpro_init_verbs[] = {
6678 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6679 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6680 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6681 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6682 /* Front Pin: output 0 (0x0c) */
6683 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6684 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6685 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6686 /* Front Mic pin: input vref at 80% */
6687 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6688 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6689 /* Speaker: output */
6690 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6691 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6692 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
6693 /* Headphone output (output 0 - 0x0c) */
6694 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6695 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6696 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6697
6698 /* FIXME: use matrix-type input source selection */
6699 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6700 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6701 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6702 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6703 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6704 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6705 /* Input mixer2 */
6706 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6707 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6708 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6709 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6710 /* Input mixer3 */
6711 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6712 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6713 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6714 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6715 /* ADC1: mute amp left and right */
6716 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6717 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6718 /* ADC2: mute amp left and right */
6719 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6720 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6721 /* ADC3: mute amp left and right */
6722 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6723 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6724
6725 { }
6726};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006727
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006728/* Macbook 5,1 */
6729static struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006730 /* DACs */
6731 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6732 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6733 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6734 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006735 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006736 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6737 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6738 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006739 /* Surround mixer */
6740 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6741 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6742 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6743 /* LFE mixer */
6744 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6745 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6746 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6747 /* HP mixer */
6748 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6749 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6750 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6751 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006752 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
6753 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006754 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6755 /* LFE Pin (0x0e) */
6756 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
6757 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6758 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
6759 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006760 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6761 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006762 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006763 /* Front Mic pin: input vref at 80% */
6764 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6765 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6766 /* Line In pin */
6767 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6768 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6769
6770 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6771 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6772 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6773 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6774 { }
6775};
6776
Takashi Iwai87350ad2007-08-16 18:19:38 +02006777/* Macbook Pro rev3 */
6778static struct hda_verb alc885_mbp3_init_verbs[] = {
6779 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6780 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6781 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6782 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6783 /* Rear mixer */
6784 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6785 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6786 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6787 /* Front Pin: output 0 (0x0c) */
6788 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6789 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6790 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6791 /* HP Pin: output 0 (0x0d) */
6792 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
6793 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6794 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6795 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6796 /* Mic (rear) pin: input vref at 80% */
6797 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6798 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6799 /* Front Mic pin: input vref at 80% */
6800 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6801 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6802 /* Line In pin: use output 1 when in LineOut mode */
6803 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6804 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6805 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
6806
6807 /* FIXME: use matrix-type input source selection */
6808 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6809 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6810 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6811 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6812 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6813 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6814 /* Input mixer2 */
6815 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6816 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6817 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6818 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6819 /* Input mixer3 */
6820 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6821 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6822 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6823 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6824 /* ADC1: mute amp left and right */
6825 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6826 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6827 /* ADC2: mute amp left and right */
6828 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6829 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6830 /* ADC3: mute amp left and right */
6831 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6832 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6833
6834 { }
6835};
6836
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006837/* iMac 24 mixer. */
6838static struct snd_kcontrol_new alc885_imac24_mixer[] = {
6839 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6840 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
6841 { } /* end */
6842};
6843
6844/* iMac 24 init verbs. */
6845static struct hda_verb alc885_imac24_init_verbs[] = {
6846 /* Internal speakers: output 0 (0x0c) */
6847 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6848 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6849 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6850 /* Internal speakers: output 0 (0x0c) */
6851 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6852 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6853 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
6854 /* Headphone: output 0 (0x0c) */
6855 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6856 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6857 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6858 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6859 /* Front Mic: input vref at 80% */
6860 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6861 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6862 { }
6863};
6864
6865/* Toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006866static void alc885_imac24_automute_init_hook(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006867{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006868 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006869
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006870 spec->autocfg.hp_pins[0] = 0x14;
6871 spec->autocfg.speaker_pins[0] = 0x18;
6872 spec->autocfg.speaker_pins[1] = 0x1a;
6873 alc_automute_amp(codec);
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006874}
6875
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006876static void alc885_mbp3_init_hook(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006877{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006878 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006879
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006880 spec->autocfg.hp_pins[0] = 0x15;
6881 spec->autocfg.speaker_pins[0] = 0x14;
6882 alc_automute_amp(codec);
Takashi Iwai87350ad2007-08-16 18:19:38 +02006883}
6884
6885
Kailang Yang272a5272007-05-14 11:00:38 +02006886static struct hda_verb alc882_targa_verbs[] = {
6887 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6888 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6889
6890 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6891 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006892
Kailang Yang272a5272007-05-14 11:00:38 +02006893 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6894 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6895 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6896
6897 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6898 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
6899 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
6900 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
6901 { } /* end */
6902};
6903
6904/* toggle speaker-output according to the hp-jack state */
6905static void alc882_targa_automute(struct hda_codec *codec)
6906{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006907 struct alc_spec *spec = codec->spec;
6908 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006909 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006910 spec->jack_present ? 1 : 3);
6911}
6912
6913static void alc882_targa_init_hook(struct hda_codec *codec)
6914{
6915 struct alc_spec *spec = codec->spec;
6916
6917 spec->autocfg.hp_pins[0] = 0x14;
6918 spec->autocfg.speaker_pins[0] = 0x1b;
6919 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02006920}
6921
6922static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
6923{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006924 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02006925 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02006926}
6927
6928static struct hda_verb alc882_asus_a7j_verbs[] = {
6929 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6930 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6931
6932 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6933 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6934 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006935
Kailang Yang272a5272007-05-14 11:00:38 +02006936 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6937 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6938 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6939
6940 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6941 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6942 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6943 { } /* end */
6944};
6945
Takashi Iwai914759b2007-09-06 14:52:04 +02006946static struct hda_verb alc882_asus_a7m_verbs[] = {
6947 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6948 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6949
6950 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6951 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6952 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006953
Takashi Iwai914759b2007-09-06 14:52:04 +02006954 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6955 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6956 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6957
6958 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6959 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6960 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6961 { } /* end */
6962};
6963
Tobin Davis9102cd12006-12-15 10:02:12 +01006964static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
6965{
6966 unsigned int gpiostate, gpiomask, gpiodir;
6967
6968 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
6969 AC_VERB_GET_GPIO_DATA, 0);
6970
6971 if (!muted)
6972 gpiostate |= (1 << pin);
6973 else
6974 gpiostate &= ~(1 << pin);
6975
6976 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
6977 AC_VERB_GET_GPIO_MASK, 0);
6978 gpiomask |= (1 << pin);
6979
6980 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
6981 AC_VERB_GET_GPIO_DIRECTION, 0);
6982 gpiodir |= (1 << pin);
6983
6984
6985 snd_hda_codec_write(codec, codec->afg, 0,
6986 AC_VERB_SET_GPIO_MASK, gpiomask);
6987 snd_hda_codec_write(codec, codec->afg, 0,
6988 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
6989
6990 msleep(1);
6991
6992 snd_hda_codec_write(codec, codec->afg, 0,
6993 AC_VERB_SET_GPIO_DATA, gpiostate);
6994}
6995
Takashi Iwai7debbe52007-08-16 15:01:03 +02006996/* set up GPIO at initialization */
6997static void alc885_macpro_init_hook(struct hda_codec *codec)
6998{
6999 alc882_gpio_mute(codec, 0, 0);
7000 alc882_gpio_mute(codec, 1, 0);
7001}
7002
7003/* set up GPIO and update auto-muting at initialization */
7004static void alc885_imac24_init_hook(struct hda_codec *codec)
7005{
7006 alc885_macpro_init_hook(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007007 alc885_imac24_automute_init_hook(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02007008}
7009
Kailang Yangdf694da2005-12-05 19:42:22 +01007010/*
7011 * generic initialization of ADC, input mixers and output mixers
7012 */
7013static struct hda_verb alc882_auto_init_verbs[] = {
7014 /*
7015 * Unmute ADC0-2 and set the default input to mic-in
7016 */
7017 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7018 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7019 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7020 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7021 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7022 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7023
Takashi Iwaicb53c622007-08-10 17:21:45 +02007024 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01007025 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007026 * Note: PASD motherboards uses the Line In 2 as the input for
7027 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01007028 */
7029 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02007030 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7031 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7032 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7033 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7034 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01007035
7036 /*
7037 * Set up output mixers (0x0c - 0x0f)
7038 */
7039 /* set vol=0 to output mixers */
7040 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7041 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7042 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7043 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7044 /* set up input amps for analog loopback */
7045 /* Amp Indices: DAC = 0, mixer = 1 */
7046 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7047 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7048 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7049 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7050 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7051 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7052 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7053 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7054 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7055 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7056
7057 /* FIXME: use matrix-type input source selection */
7058 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7059 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7060 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7061 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7062 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7063 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7064 /* Input mixer2 */
7065 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7066 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7067 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7068 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7069 /* Input mixer3 */
7070 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7071 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7072 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7073 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7074
7075 { }
7076};
7077
Takashi Iwaicb53c622007-08-10 17:21:45 +02007078#ifdef CONFIG_SND_HDA_POWER_SAVE
7079#define alc882_loopbacks alc880_loopbacks
7080#endif
7081
Sasha Alexandrdef319f2009-06-16 16:00:15 -04007082/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +01007083#define alc882_pcm_analog_playback alc880_pcm_analog_playback
7084#define alc882_pcm_analog_capture alc880_pcm_analog_capture
7085#define alc882_pcm_digital_playback alc880_pcm_digital_playback
7086#define alc882_pcm_digital_capture alc880_pcm_digital_capture
7087
7088/*
7089 * configuration and preset
7090 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007091static const char *alc882_models[ALC882_MODEL_LAST] = {
7092 [ALC882_3ST_DIG] = "3stack-dig",
7093 [ALC882_6ST_DIG] = "6stack-dig",
7094 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02007095 [ALC882_W2JC] = "w2jc",
Takashi Iwai0438a002007-09-06 14:54:11 +02007096 [ALC882_TARGA] = "targa",
7097 [ALC882_ASUS_A7J] = "asus-a7j",
7098 [ALC882_ASUS_A7M] = "asus-a7m",
Tobin Davis9102cd12006-12-15 10:02:12 +01007099 [ALC885_MACPRO] = "macpro",
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007100 [ALC885_MB5] = "mb5",
Takashi Iwai87350ad2007-08-16 18:19:38 +02007101 [ALC885_MBP3] = "mbp3",
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007102 [ALC885_IMAC24] = "imac24",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007103 [ALC882_AUTO] = "auto",
7104};
7105
7106static struct snd_pci_quirk alc882_cfg_tbl[] = {
7107 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02007108 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Kailang Yangac8842a2007-09-20 12:51:39 +02007109 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
Takashi Iwai914759b2007-09-06 14:52:04 +02007110 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007111 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Claudio Matsuokac5d9f1c2007-07-19 23:18:32 +02007112 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
Tobin Davis7b9470d2006-12-28 13:56:48 +01007113 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007114 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Jiang zhe44447042008-01-28 12:28:24 +01007115 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007116 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
7117 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
7118 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yangdf694da2005-12-05 19:42:22 +01007119 {}
7120};
7121
7122static struct alc_config_preset alc882_presets[] = {
7123 [ALC882_3ST_DIG] = {
7124 .mixers = { alc882_base_mixer },
7125 .init_verbs = { alc882_init_verbs },
7126 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7127 .dac_nids = alc882_dac_nids,
7128 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01007129 .dig_in_nid = ALC882_DIGIN_NID,
7130 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
7131 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02007132 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01007133 .input_mux = &alc882_capture_source,
7134 },
7135 [ALC882_6ST_DIG] = {
7136 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
7137 .init_verbs = { alc882_init_verbs },
7138 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7139 .dac_nids = alc882_dac_nids,
7140 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01007141 .dig_in_nid = ALC882_DIGIN_NID,
7142 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
7143 .channel_mode = alc882_sixstack_modes,
7144 .input_mux = &alc882_capture_source,
7145 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007146 [ALC882_ARIMA] = {
7147 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
7148 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
7149 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7150 .dac_nids = alc882_dac_nids,
7151 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
7152 .channel_mode = alc882_sixstack_modes,
7153 .input_mux = &alc882_capture_source,
7154 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02007155 [ALC882_W2JC] = {
7156 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
7157 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
7158 alc880_gpio1_init_verbs },
7159 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7160 .dac_nids = alc882_dac_nids,
7161 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
7162 .channel_mode = alc880_threestack_modes,
7163 .need_dac_fix = 1,
7164 .input_mux = &alc882_capture_source,
7165 .dig_out_nid = ALC882_DIGOUT_NID,
7166 },
Takashi Iwai87350ad2007-08-16 18:19:38 +02007167 [ALC885_MBP3] = {
7168 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
7169 .init_verbs = { alc885_mbp3_init_verbs,
7170 alc880_gpio1_init_verbs },
7171 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7172 .dac_nids = alc882_dac_nids,
7173 .channel_mode = alc885_mbp_6ch_modes,
7174 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
7175 .input_mux = &alc882_capture_source,
7176 .dig_out_nid = ALC882_DIGOUT_NID,
7177 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007178 .unsol_event = alc_automute_amp_unsol_event,
7179 .init_hook = alc885_mbp3_init_hook,
Takashi Iwai87350ad2007-08-16 18:19:38 +02007180 },
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007181 [ALC885_MB5] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007182 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007183 .init_verbs = { alc885_mb5_init_verbs,
7184 alc880_gpio1_init_verbs },
7185 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7186 .dac_nids = alc882_dac_nids,
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007187 .channel_mode = alc885_mb5_6ch_modes,
7188 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007189 .input_mux = &mb5_capture_source,
7190 .dig_out_nid = ALC882_DIGOUT_NID,
7191 .dig_in_nid = ALC882_DIGIN_NID,
7192 },
Tobin Davis9102cd12006-12-15 10:02:12 +01007193 [ALC885_MACPRO] = {
7194 .mixers = { alc882_macpro_mixer },
7195 .init_verbs = { alc882_macpro_init_verbs },
7196 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7197 .dac_nids = alc882_dac_nids,
7198 .dig_out_nid = ALC882_DIGOUT_NID,
7199 .dig_in_nid = ALC882_DIGIN_NID,
7200 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
7201 .channel_mode = alc882_ch_modes,
7202 .input_mux = &alc882_capture_source,
Takashi Iwai7debbe52007-08-16 15:01:03 +02007203 .init_hook = alc885_macpro_init_hook,
Tobin Davis9102cd12006-12-15 10:02:12 +01007204 },
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007205 [ALC885_IMAC24] = {
7206 .mixers = { alc885_imac24_mixer },
7207 .init_verbs = { alc885_imac24_init_verbs },
7208 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7209 .dac_nids = alc882_dac_nids,
7210 .dig_out_nid = ALC882_DIGOUT_NID,
7211 .dig_in_nid = ALC882_DIGIN_NID,
7212 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
7213 .channel_mode = alc882_ch_modes,
7214 .input_mux = &alc882_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007215 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai7debbe52007-08-16 15:01:03 +02007216 .init_hook = alc885_imac24_init_hook,
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007217 },
Kailang Yang272a5272007-05-14 11:00:38 +02007218 [ALC882_TARGA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007219 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Kailang Yang272a5272007-05-14 11:00:38 +02007220 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
7221 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7222 .dac_nids = alc882_dac_nids,
7223 .dig_out_nid = ALC882_DIGOUT_NID,
7224 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
7225 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01007226 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02007227 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
7228 .channel_mode = alc882_3ST_6ch_modes,
7229 .need_dac_fix = 1,
7230 .input_mux = &alc882_capture_source,
7231 .unsol_event = alc882_targa_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007232 .init_hook = alc882_targa_init_hook,
Kailang Yang272a5272007-05-14 11:00:38 +02007233 },
7234 [ALC882_ASUS_A7J] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007235 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Kailang Yang272a5272007-05-14 11:00:38 +02007236 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
7237 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7238 .dac_nids = alc882_dac_nids,
7239 .dig_out_nid = ALC882_DIGOUT_NID,
7240 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
7241 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01007242 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02007243 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
7244 .channel_mode = alc882_3ST_6ch_modes,
7245 .need_dac_fix = 1,
7246 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02007247 },
Takashi Iwai914759b2007-09-06 14:52:04 +02007248 [ALC882_ASUS_A7M] = {
7249 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
7250 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
7251 alc880_gpio1_init_verbs,
7252 alc882_asus_a7m_verbs },
7253 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7254 .dac_nids = alc882_dac_nids,
7255 .dig_out_nid = ALC882_DIGOUT_NID,
7256 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
7257 .channel_mode = alc880_threestack_modes,
7258 .need_dac_fix = 1,
7259 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02007260 },
Kailang Yangdf694da2005-12-05 19:42:22 +01007261};
7262
7263
7264/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02007265 * Pin config fixes
7266 */
Kailang Yangea1fb292008-08-26 12:58:38 +02007267enum {
Takashi Iwaif95474e2007-07-10 00:47:43 +02007268 PINFIX_ABIT_AW9D_MAX
7269};
7270
7271static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
7272 { 0x15, 0x01080104 }, /* side */
7273 { 0x16, 0x01011012 }, /* rear */
7274 { 0x17, 0x01016011 }, /* clfe */
7275 { }
7276};
7277
7278static const struct alc_pincfg *alc882_pin_fixes[] = {
7279 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
7280};
7281
7282static struct snd_pci_quirk alc882_pinfix_tbl[] = {
7283 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
7284 {}
7285};
7286
7287/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007288 * BIOS auto configuration
7289 */
7290static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
7291 hda_nid_t nid, int pin_type,
7292 int dac_idx)
7293{
7294 /* set as output */
7295 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007296 int idx;
7297
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007298 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01007299 if (spec->multiout.dac_nids[dac_idx] == 0x25)
7300 idx = 4;
7301 else
7302 idx = spec->multiout.dac_nids[dac_idx] - 2;
Kailang Yangdf694da2005-12-05 19:42:22 +01007303 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
7304
7305}
7306
7307static void alc882_auto_init_multi_out(struct hda_codec *codec)
7308{
7309 struct alc_spec *spec = codec->spec;
7310 int i;
7311
7312 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007313 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007314 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01007315 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007316 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007317 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01007318 }
7319}
7320
7321static void alc882_auto_init_hp_out(struct hda_codec *codec)
7322{
7323 struct alc_spec *spec = codec->spec;
7324 hda_nid_t pin;
7325
Takashi Iwaieb06ed82006-09-20 17:10:27 +02007326 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007327 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007328 /* use dac 0 */
7329 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007330 pin = spec->autocfg.speaker_pins[0];
7331 if (pin)
7332 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01007333}
7334
7335#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
7336#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
7337
7338static void alc882_auto_init_analog_input(struct hda_codec *codec)
7339{
7340 struct alc_spec *spec = codec->spec;
7341 int i;
7342
7343 for (i = 0; i < AUTO_PIN_LAST; i++) {
7344 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai7194cae2008-03-06 16:58:17 +01007345 if (!nid)
7346 continue;
Takashi Iwai23f0c042009-02-26 13:03:58 +01007347 alc_set_input_pin(codec, nid, AUTO_PIN_FRONT_MIC /*i*/);
Takashi Iwai7194cae2008-03-06 16:58:17 +01007348 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
7349 snd_hda_codec_write(codec, nid, 0,
7350 AC_VERB_SET_AMP_GAIN_MUTE,
7351 AMP_OUT_MUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01007352 }
7353}
7354
Takashi Iwaif511b012008-08-15 16:46:42 +02007355static void alc882_auto_init_input_src(struct hda_codec *codec)
7356{
7357 struct alc_spec *spec = codec->spec;
Takashi Iwaif511b012008-08-15 16:46:42 +02007358 int c;
7359
7360 for (c = 0; c < spec->num_adc_nids; c++) {
7361 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
7362 hda_nid_t nid = spec->capsrc_nids[c];
Herton Ronaldo Krzesinskib98b7b32009-01-29 13:18:31 -02007363 unsigned int mux_idx;
7364 const struct hda_input_mux *imux;
Takashi Iwaif511b012008-08-15 16:46:42 +02007365 int conns, mute, idx, item;
7366
7367 conns = snd_hda_get_connections(codec, nid, conn_list,
7368 ARRAY_SIZE(conn_list));
7369 if (conns < 0)
7370 continue;
Herton Ronaldo Krzesinskib98b7b32009-01-29 13:18:31 -02007371 mux_idx = c >= spec->num_mux_defs ? 0 : c;
7372 imux = &spec->input_mux[mux_idx];
Takashi Iwaif511b012008-08-15 16:46:42 +02007373 for (idx = 0; idx < conns; idx++) {
7374 /* if the current connection is the selected one,
7375 * unmute it as default - otherwise mute it
7376 */
7377 mute = AMP_IN_MUTE(idx);
7378 for (item = 0; item < imux->num_items; item++) {
7379 if (imux->items[item].index == idx) {
7380 if (spec->cur_mux[c] == item)
7381 mute = AMP_IN_UNMUTE(idx);
7382 break;
7383 }
7384 }
Herton Ronaldo Krzesinskib98b7b32009-01-29 13:18:31 -02007385 /* check if we have a selector or mixer
7386 * we could check for the widget type instead, but
7387 * just check for Amp-In presence (in case of mixer
7388 * without amp-in there is something wrong, this
7389 * function shouldn't be used or capsrc nid is wrong)
7390 */
7391 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
7392 snd_hda_codec_write(codec, nid, 0,
7393 AC_VERB_SET_AMP_GAIN_MUTE,
7394 mute);
7395 else if (mute != AMP_IN_MUTE(idx))
7396 snd_hda_codec_write(codec, nid, 0,
7397 AC_VERB_SET_CONNECT_SEL,
7398 idx);
Takashi Iwaif511b012008-08-15 16:46:42 +02007399 }
7400 }
7401}
7402
Takashi Iwai776e1842007-08-29 15:07:11 +02007403/* add mic boosts if needed */
7404static int alc_auto_add_mic_boost(struct hda_codec *codec)
7405{
7406 struct alc_spec *spec = codec->spec;
7407 int err;
7408 hda_nid_t nid;
7409
7410 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01007411 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02007412 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7413 "Mic Boost",
7414 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
7415 if (err < 0)
7416 return err;
7417 }
7418 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01007419 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02007420 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7421 "Front Mic Boost",
7422 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
7423 if (err < 0)
7424 return err;
7425 }
7426 return 0;
7427}
7428
Kailang Yangdf694da2005-12-05 19:42:22 +01007429/* almost identical with ALC880 parser... */
7430static int alc882_parse_auto_config(struct hda_codec *codec)
7431{
7432 struct alc_spec *spec = codec->spec;
7433 int err = alc880_parse_auto_config(codec);
7434
7435 if (err < 0)
7436 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02007437 else if (!err)
7438 return 0; /* no config found */
7439
7440 err = alc_auto_add_mic_boost(codec);
7441 if (err < 0)
7442 return err;
7443
7444 /* hack - override the init verbs */
7445 spec->init_verbs[0] = alc882_auto_init_verbs;
7446
7447 return 1; /* config found */
Kailang Yangdf694da2005-12-05 19:42:22 +01007448}
7449
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007450/* additional initialization for auto-configuration model */
7451static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01007452{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007453 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007454 alc882_auto_init_multi_out(codec);
7455 alc882_auto_init_hp_out(codec);
7456 alc882_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02007457 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007458 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02007459 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01007460}
7461
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007462static int patch_alc883(struct hda_codec *codec); /* called in patch_alc882() */
7463
Linus Torvalds1da177e2005-04-16 15:20:36 -07007464static int patch_alc882(struct hda_codec *codec)
7465{
7466 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007467 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007468
Takashi Iwaie560d8d2005-09-09 14:21:46 +02007469 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007470 if (spec == NULL)
7471 return -ENOMEM;
7472
Linus Torvalds1da177e2005-04-16 15:20:36 -07007473 codec->spec = spec;
7474
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007475 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
7476 alc882_models,
7477 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007478
Kailang Yangdf694da2005-12-05 19:42:22 +01007479 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01007480 /* Pick up systems that don't supply PCI SSID */
7481 switch (codec->subsystem_id) {
7482 case 0x106b0c00: /* Mac Pro */
7483 board_config = ALC885_MACPRO;
7484 break;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007485 case 0x106b1000: /* iMac 24 */
Peter Korsgaardf3911c52008-09-27 09:13:45 +02007486 case 0x106b2800: /* AppleTV */
Mark Eggleston3077e442009-01-31 17:57:54 +01007487 case 0x106b3e00: /* iMac 24 Aluminium */
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007488 board_config = ALC885_IMAC24;
7489 break;
Luke Yelavich2d466382009-02-23 13:00:33 +11007490 case 0x106b00a0: /* MacBookPro3,1 - Another revision */
Takashi Iwaic7e07572008-06-26 14:42:51 +02007491 case 0x106b00a1: /* Macbook (might be wrong - PCI SSID?) */
David Woodhouse9c95c432008-09-18 13:37:13 -07007492 case 0x106b00a4: /* MacbookPro4,1 */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007493 case 0x106b2c00: /* Macbook Pro rev3 */
Torben Schulzeb4c41d2009-05-18 15:02:35 +02007494 /* Macbook 3.1 (0x106b3600) is handled by patch_alc883() */
Luke Yelavich2a884642009-01-28 15:58:38 +11007495 case 0x106b3800: /* MacbookPro4,1 - latter revision */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007496 board_config = ALC885_MBP3;
7497 break;
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007498 case 0x106b3f00: /* Macbook 5,1 */
Takashi Iwai7442f9d2009-05-14 18:20:33 +02007499 case 0x106b4000: /* Macbook Pro 5,1 - FIXME: HP jack sense
7500 * seems not working, so apparently
7501 * no perfect solution yet
7502 */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007503 board_config = ALC885_MB5;
7504 break;
Tobin Davis081d17c2007-02-15 17:46:18 +01007505 default:
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007506 /* ALC889A is handled better as ALC888-compatible */
Clive Messer669faba2008-09-30 15:49:13 +02007507 if (codec->revision_id == 0x100101 ||
7508 codec->revision_id == 0x100103) {
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007509 alc_free(codec);
7510 return patch_alc883(codec);
7511 }
Takashi Iwai6c627f32009-05-18 12:33:36 +02007512 printk(KERN_INFO "hda_codec: Unknown model for %s, "
7513 "trying auto-probe from BIOS...\n",
7514 codec->chip_name);
Tobin Davis081d17c2007-02-15 17:46:18 +01007515 board_config = ALC882_AUTO;
7516 }
Kailang Yangdf694da2005-12-05 19:42:22 +01007517 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007518
Takashi Iwaif95474e2007-07-10 00:47:43 +02007519 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
7520
Kailang Yangdf694da2005-12-05 19:42:22 +01007521 if (board_config == ALC882_AUTO) {
7522 /* automatic parse from the BIOS config */
7523 err = alc882_parse_auto_config(codec);
7524 if (err < 0) {
7525 alc_free(codec);
7526 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007527 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007528 printk(KERN_INFO
7529 "hda_codec: Cannot set up configuration "
7530 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007531 board_config = ALC882_3ST_DIG;
7532 }
7533 }
7534
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09007535 err = snd_hda_attach_beep_device(codec, 0x1);
7536 if (err < 0) {
7537 alc_free(codec);
7538 return err;
7539 }
7540
Kailang Yangdf694da2005-12-05 19:42:22 +01007541 if (board_config != ALC882_AUTO)
7542 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007543
Kailang Yangdf694da2005-12-05 19:42:22 +01007544 spec->stream_analog_playback = &alc882_pcm_analog_playback;
7545 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01007546 /* FIXME: setup DAC5 */
7547 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
7548 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007549
Kailang Yangdf694da2005-12-05 19:42:22 +01007550 spec->stream_digital_playback = &alc882_pcm_digital_playback;
7551 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007552
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007553 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01007554 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01007555 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007556 /* get type */
7557 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01007558 if (wcap != AC_WID_AUD_IN) {
7559 spec->adc_nids = alc882_adc_nids_alt;
7560 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
Takashi Iwaie1406342008-02-11 18:32:32 +01007561 spec->capsrc_nids = alc882_capsrc_nids_alt;
Kailang Yangdf694da2005-12-05 19:42:22 +01007562 } else {
7563 spec->adc_nids = alc882_adc_nids;
7564 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +01007565 spec->capsrc_nids = alc882_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +01007566 }
7567 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007568 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007569 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007570
Takashi Iwai2134ea42008-01-10 16:53:55 +01007571 spec->vmaster_nid = 0x0c;
7572
Linus Torvalds1da177e2005-04-16 15:20:36 -07007573 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01007574 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007575 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02007576#ifdef CONFIG_SND_HDA_POWER_SAVE
7577 if (!spec->loopback.amplist)
7578 spec->loopback.amplist = alc882_loopbacks;
7579#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01007580 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007581
7582 return 0;
7583}
7584
7585/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007586 * ALC883 support
7587 *
7588 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
7589 * configuration. Each pin widget can choose any input DACs and a mixer.
7590 * Each ADC is connected from a mixer of all inputs. This makes possible
7591 * 6-channel independent captures.
7592 *
7593 * In addition, an independent DAC for the multi-playback (not used in this
7594 * driver yet).
7595 */
7596#define ALC883_DIGOUT_NID 0x06
7597#define ALC883_DIGIN_NID 0x0a
7598
Wu Fengguang3ab90932008-11-17 09:51:09 +01007599#define ALC1200_DIGOUT_NID 0x10
7600
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007601static hda_nid_t alc883_dac_nids[4] = {
7602 /* front, rear, clfe, rear_surr */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01007603 0x02, 0x03, 0x04, 0x05
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007604};
7605
7606static hda_nid_t alc883_adc_nids[2] = {
7607 /* ADC1-2 */
7608 0x08, 0x09,
7609};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007610
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007611static hda_nid_t alc883_adc_nids_alt[1] = {
7612 /* ADC1 */
7613 0x08,
7614};
7615
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08007616static hda_nid_t alc883_adc_nids_rev[2] = {
7617 /* ADC2-1 */
7618 0x09, 0x08
7619};
7620
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007621#define alc889_adc_nids alc880_adc_nids
7622
Takashi Iwaie1406342008-02-11 18:32:32 +01007623static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 };
7624
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08007625static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
7626
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007627#define alc889_capsrc_nids alc882_capsrc_nids
7628
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007629/* input MUX */
7630/* FIXME: should be a matrix-type input source selection */
7631
7632static struct hda_input_mux alc883_capture_source = {
7633 .num_items = 4,
7634 .items = {
7635 { "Mic", 0x0 },
7636 { "Front Mic", 0x1 },
7637 { "Line", 0x2 },
7638 { "CD", 0x4 },
7639 },
7640};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007641
Jiang zhe17bba1b2008-06-04 12:11:07 +02007642static struct hda_input_mux alc883_3stack_6ch_intel = {
7643 .num_items = 4,
7644 .items = {
7645 { "Mic", 0x1 },
7646 { "Front Mic", 0x0 },
7647 { "Line", 0x2 },
7648 { "CD", 0x4 },
7649 },
7650};
7651
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007652static struct hda_input_mux alc883_lenovo_101e_capture_source = {
7653 .num_items = 2,
7654 .items = {
7655 { "Mic", 0x1 },
7656 { "Line", 0x2 },
7657 },
7658};
7659
Kailang Yang272a5272007-05-14 11:00:38 +02007660static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
7661 .num_items = 4,
7662 .items = {
7663 { "Mic", 0x0 },
7664 { "iMic", 0x1 },
7665 { "Line", 0x2 },
7666 { "CD", 0x4 },
7667 },
7668};
7669
Jiang zhefb97dc62008-03-06 11:07:11 +01007670static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
7671 .num_items = 2,
7672 .items = {
7673 { "Mic", 0x0 },
7674 { "Int Mic", 0x1 },
7675 },
7676};
7677
Kailang Yange2757d52008-08-26 13:17:46 +02007678static struct hda_input_mux alc883_lenovo_sky_capture_source = {
7679 .num_items = 3,
7680 .items = {
7681 { "Mic", 0x0 },
7682 { "Front Mic", 0x1 },
7683 { "Line", 0x4 },
7684 },
7685};
7686
7687static struct hda_input_mux alc883_asus_eee1601_capture_source = {
7688 .num_items = 2,
7689 .items = {
7690 { "Mic", 0x0 },
7691 { "Line", 0x2 },
7692 },
7693};
7694
Torben Schulzeb4c41d2009-05-18 15:02:35 +02007695static struct hda_input_mux alc889A_mb31_capture_source = {
7696 .num_items = 2,
7697 .items = {
7698 { "Mic", 0x0 },
7699 /* Front Mic (0x01) unused */
7700 { "Line", 0x2 },
7701 /* Line 2 (0x03) unused */
7702 /* CD (0x04) unsused? */
7703 },
7704};
7705
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007706/*
7707 * 2ch mode
7708 */
7709static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
7710 { 2, NULL }
7711};
7712
7713/*
7714 * 2ch mode
7715 */
7716static struct hda_verb alc883_3ST_ch2_init[] = {
7717 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7718 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7719 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7720 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7721 { } /* end */
7722};
7723
7724/*
Tobin Davisb2011312007-09-17 12:45:11 +02007725 * 4ch mode
7726 */
7727static struct hda_verb alc883_3ST_ch4_init[] = {
7728 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7729 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7730 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7731 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7732 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7733 { } /* end */
7734};
7735
7736/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007737 * 6ch mode
7738 */
7739static struct hda_verb alc883_3ST_ch6_init[] = {
7740 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7741 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7742 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7743 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7744 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7745 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7746 { } /* end */
7747};
7748
Tobin Davisb2011312007-09-17 12:45:11 +02007749static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007750 { 2, alc883_3ST_ch2_init },
Tobin Davisb2011312007-09-17 12:45:11 +02007751 { 4, alc883_3ST_ch4_init },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007752 { 6, alc883_3ST_ch6_init },
7753};
7754
David Heidelberger64a8be72009-06-08 16:15:18 +02007755
7756/*
7757 * 2ch mode
7758 */
7759static struct hda_verb alc883_4ST_ch2_init[] = {
Takashi Iwaif03ecf52009-06-08 16:38:17 +02007760 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
David Heidelberger64a8be72009-06-08 16:15:18 +02007761 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7762 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7763 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7764 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7765 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7766 { } /* end */
7767};
7768
7769/*
7770 * 4ch mode
7771 */
7772static struct hda_verb alc883_4ST_ch4_init[] = {
7773 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7774 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7775 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7776 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7777 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7778 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7779 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7780 { } /* end */
7781};
7782
7783/*
7784 * 6ch mode
7785 */
7786static struct hda_verb alc883_4ST_ch6_init[] = {
7787 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7788 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7789 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7790 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7791 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7792 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7793 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7794 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7795 { } /* end */
7796};
7797
7798/*
7799 * 8ch mode
7800 */
7801static struct hda_verb alc883_4ST_ch8_init[] = {
7802 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7803 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7804 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7805 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7806 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7807 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7808 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7809 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7810 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7811 { } /* end */
7812};
7813
7814static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
7815 { 2, alc883_4ST_ch2_init },
7816 { 4, alc883_4ST_ch4_init },
7817 { 6, alc883_4ST_ch6_init },
7818 { 8, alc883_4ST_ch8_init },
7819};
7820
7821
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007822/*
Jiang zhe17bba1b2008-06-04 12:11:07 +02007823 * 2ch mode
7824 */
7825static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7826 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7827 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7828 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7829 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7830 { } /* end */
7831};
7832
7833/*
7834 * 4ch mode
7835 */
7836static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7837 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7838 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7839 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7840 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7841 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7842 { } /* end */
7843};
7844
7845/*
7846 * 6ch mode
7847 */
7848static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7849 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7850 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7851 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7852 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7853 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7854 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7855 { } /* end */
7856};
7857
7858static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7859 { 2, alc883_3ST_ch2_intel_init },
7860 { 4, alc883_3ST_ch4_intel_init },
7861 { 6, alc883_3ST_ch6_intel_init },
7862};
7863
7864/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007865 * 6ch mode
7866 */
7867static struct hda_verb alc883_sixstack_ch6_init[] = {
7868 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7869 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7870 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7871 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7872 { } /* end */
7873};
7874
7875/*
7876 * 8ch mode
7877 */
7878static struct hda_verb alc883_sixstack_ch8_init[] = {
7879 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7880 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7881 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7882 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7883 { } /* end */
7884};
7885
7886static struct hda_channel_mode alc883_sixstack_modes[2] = {
7887 { 6, alc883_sixstack_ch6_init },
7888 { 8, alc883_sixstack_ch8_init },
7889};
7890
Torben Schulzeb4c41d2009-05-18 15:02:35 +02007891/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
7892static struct hda_verb alc889A_mb31_ch2_init[] = {
7893 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7894 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7895 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7896 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7897 { } /* end */
7898};
7899
7900/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
7901static struct hda_verb alc889A_mb31_ch4_init[] = {
7902 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7903 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7904 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7905 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7906 { } /* end */
7907};
7908
7909/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
7910static struct hda_verb alc889A_mb31_ch5_init[] = {
7911 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
7912 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7913 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7914 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7915 { } /* end */
7916};
7917
7918/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
7919static struct hda_verb alc889A_mb31_ch6_init[] = {
7920 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
7921 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
7922 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7923 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7924 { } /* end */
7925};
7926
7927static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
7928 { 2, alc889A_mb31_ch2_init },
7929 { 4, alc889A_mb31_ch4_init },
7930 { 5, alc889A_mb31_ch5_init },
7931 { 6, alc889A_mb31_ch6_init },
7932};
7933
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007934static struct hda_verb alc883_medion_eapd_verbs[] = {
7935 /* eanable EAPD on medion laptop */
7936 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7937 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7938 { }
7939};
7940
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007941/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7942 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7943 */
7944
7945static struct snd_kcontrol_new alc883_base_mixer[] = {
7946 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7947 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7948 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7949 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7950 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7951 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7952 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7953 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7954 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7955 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7956 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7957 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7958 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7959 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7960 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7961 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007962 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007963 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7964 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007965 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007966 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007967 { } /* end */
7968};
7969
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007970static struct snd_kcontrol_new alc883_mitac_mixer[] = {
7971 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7972 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7973 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7974 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7975 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7976 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7977 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7978 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7979 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7980 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7981 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7982 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7983 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007984 { } /* end */
7985};
7986
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007987static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007988 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7989 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7990 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7991 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7992 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7993 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7994 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7995 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7996 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7997 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01007998 { } /* end */
7999};
8000
Jiang zhefb97dc62008-03-06 11:07:11 +01008001static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
8002 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8003 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8004 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8005 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8006 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8007 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8008 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8009 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8010 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8011 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01008012 { } /* end */
8013};
8014
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008015static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
8016 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8017 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8018 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8019 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8020 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8021 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8022 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8023 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008024 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008025 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8026 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008027 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008028 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008029 { } /* end */
8030};
8031
8032static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
8033 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8034 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8035 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8036 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8037 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8038 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8039 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8040 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8041 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8042 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8043 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8044 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8045 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8046 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008047 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008048 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8049 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008050 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008051 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008052 { } /* end */
8053};
8054
Jiang zhe17bba1b2008-06-04 12:11:07 +02008055static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
8056 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8057 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8058 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8059 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8060 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8061 HDA_OUTPUT),
8062 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8063 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8064 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8065 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8066 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8067 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8068 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8069 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8070 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8071 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8072 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8073 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8074 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8075 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008076 { } /* end */
8077};
8078
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008079static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02008080 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008081 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008082 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008083 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008084 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8085 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008086 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8087 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008088 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8089 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8090 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8091 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8092 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8093 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008094 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008095 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8096 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008097 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008098 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008099 { } /* end */
8100};
8101
Sasha Alexandrc2592492009-06-16 14:52:54 -04008102static struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008103 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8104 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8105 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8106 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8107 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8108 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8109 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8110 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8111 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8112 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8113 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8114 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8115 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8116 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008117 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008118 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008119 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008120};
Kailang Yangccc656c2006-10-17 12:32:26 +02008121
Sasha Alexandrc2592492009-06-16 14:52:54 -04008122static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008123 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8124 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8125 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8126 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8127 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8128 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008129 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008130 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02008131 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8132 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8133 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008134 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008135};
Kailang Yangccc656c2006-10-17 12:32:26 +02008136
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008137static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
8138 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8139 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01008140 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8141 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008142 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8143 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8144 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8145 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008146 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008147};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008148
Kailang Yang272a5272007-05-14 11:00:38 +02008149static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
8150 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8151 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
8152 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8153 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8154 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8155 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8156 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8157 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8158 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008159 { } /* end */
8160};
8161
8162static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
8163 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8164 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8165 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8166 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8167 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8168 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8169 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8170 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8171 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008172 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02008173};
Kailang Yang272a5272007-05-14 11:00:38 +02008174
Tobin Davis2880a8672007-08-07 11:50:26 +02008175static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02008176 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8177 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a8672007-08-07 11:50:26 +02008178 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a8672007-08-07 11:50:26 +02008179 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8180 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02008181 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8182 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8183 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a8672007-08-07 11:50:26 +02008184 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02008185};
Tobin Davis2880a8672007-08-07 11:50:26 +02008186
Tony Vroond2fd4b02009-06-21 00:40:10 +01008187static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
8188 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8189 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8190 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8191 HDA_BIND_MUTE("LFE Playback Switch", 0x0f, 2, HDA_INPUT),
8192 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8193 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8194 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8195 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8196 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8197 { } /* end */
8198};
8199
Kailang Yange2757d52008-08-26 13:17:46 +02008200static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
8201 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8202 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8203 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8204 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
8205 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
8206 0x0d, 1, 0x0, HDA_OUTPUT),
8207 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
8208 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
8209 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
8210 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8211 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008212 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8213 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8214 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8215 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8216 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8217 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8218 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8219 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8220 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8221 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008222 { } /* end */
8223};
8224
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008225static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
8226 /* Output mixers */
8227 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8228 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
8229 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
8230 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
8231 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
8232 HDA_OUTPUT),
8233 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
8234 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
8235 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
8236 /* Output switches */
8237 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
8238 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
8239 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
8240 /* Boost mixers */
8241 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
8242 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
8243 /* Input mixers */
8244 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
8245 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
8246 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8247 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8248 { } /* end */
8249};
8250
Guido Günther3e1647c2009-06-05 00:47:26 +02008251static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
8252 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8253 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8254 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8255 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8256 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8257 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8258 { } /* end */
8259};
8260
Kailang Yange2757d52008-08-26 13:17:46 +02008261static struct hda_bind_ctls alc883_bind_cap_vol = {
8262 .ops = &snd_hda_bind_vol,
8263 .values = {
8264 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8265 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8266 0
8267 },
8268};
8269
8270static struct hda_bind_ctls alc883_bind_cap_switch = {
8271 .ops = &snd_hda_bind_sw,
8272 .values = {
8273 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8274 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8275 0
8276 },
8277};
8278
8279static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
8280 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8281 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8282 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8283 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8284 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8285 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8286 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8287 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008288 { } /* end */
8289};
8290
8291static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02008292 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
8293 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
8294 {
8295 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8296 /* .name = "Capture Source", */
8297 .name = "Input Source",
8298 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01008299 .info = alc_mux_enum_info,
8300 .get = alc_mux_enum_get,
8301 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02008302 },
8303 { } /* end */
8304};
8305
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008306static struct snd_kcontrol_new alc883_chmode_mixer[] = {
8307 {
8308 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8309 .name = "Channel Mode",
8310 .info = alc_ch_mode_info,
8311 .get = alc_ch_mode_get,
8312 .put = alc_ch_mode_put,
8313 },
8314 { } /* end */
8315};
8316
8317static struct hda_verb alc883_init_verbs[] = {
8318 /* ADC1: mute amp left and right */
Kailang Yange2757d52008-08-26 13:17:46 +02008319 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008320 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8321 /* ADC2: mute amp left and right */
8322 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8323 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8324 /* Front mixer: unmute input/output amp left and right (volume = 0) */
8325 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8326 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8327 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8328 /* Rear mixer */
8329 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8330 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8331 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8332 /* CLFE mixer */
8333 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8334 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8335 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8336 /* Side mixer */
8337 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8338 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8339 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8340
Takashi Iwaicb53c622007-08-10 17:21:45 +02008341 /* mute analog input loopbacks */
8342 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8343 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8344 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8345 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8346 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008347
8348 /* Front Pin: output 0 (0x0c) */
8349 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8350 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8351 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8352 /* Rear Pin: output 1 (0x0d) */
8353 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8354 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8355 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8356 /* CLFE Pin: output 2 (0x0e) */
8357 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8358 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8359 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
8360 /* Side Pin: output 3 (0x0f) */
8361 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8362 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8363 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8364 /* Mic (rear) pin: input vref at 80% */
8365 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8366 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8367 /* Front Mic pin: input vref at 80% */
8368 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8369 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8370 /* Line In pin: input */
8371 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8372 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8373 /* Line-2 In: Headphone output (output 0 - 0x0c) */
8374 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8375 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8376 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8377 /* CD pin widget for input */
8378 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8379
8380 /* FIXME: use matrix-type input source selection */
8381 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8382 /* Input mixer2 */
8383 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yange2757d52008-08-26 13:17:46 +02008384 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8385 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8386 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008387 /* Input mixer3 */
8388 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yange2757d52008-08-26 13:17:46 +02008389 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8390 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8391 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008392 { }
8393};
8394
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008395/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008396static void alc883_mitac_init_hook(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008397{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008398 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008399
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008400 spec->autocfg.hp_pins[0] = 0x15;
8401 spec->autocfg.speaker_pins[0] = 0x14;
8402 spec->autocfg.speaker_pins[1] = 0x17;
8403 alc_automute_amp(codec);
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008404}
8405
8406/* auto-toggle front mic */
8407/*
8408static void alc883_mitac_mic_automute(struct hda_codec *codec)
8409{
8410 unsigned int present;
8411 unsigned char bits;
8412
8413 present = snd_hda_codec_read(codec, 0x18, 0,
8414 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8415 bits = present ? HDA_AMP_MUTE : 0;
8416 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
8417}
8418*/
8419
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008420static struct hda_verb alc883_mitac_verbs[] = {
8421 /* HP */
8422 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8423 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8424 /* Subwoofer */
8425 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8426 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8427
8428 /* enable unsolicited event */
8429 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8430 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
8431
8432 { } /* end */
8433};
8434
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008435static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008436 /* HP */
8437 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8438 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8439 /* Int speaker */
8440 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
8441 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8442
8443 /* enable unsolicited event */
8444 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008445 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01008446
8447 { } /* end */
8448};
8449
Jiang zhefb97dc62008-03-06 11:07:11 +01008450static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
8451 /* HP */
8452 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8453 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8454 /* Subwoofer */
8455 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8456 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8457
8458 /* enable unsolicited event */
8459 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8460
8461 { } /* end */
8462};
8463
Sasha Alexandrc2592492009-06-16 14:52:54 -04008464static struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008465 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8466 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8467
8468 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8469 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008470
David Heidelberger64a8be72009-06-08 16:15:18 +02008471/* Connect Line-Out side jack (SPDIF) to Side */
8472 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8473 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8474 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8475/* Connect Mic jack to CLFE */
8476 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8477 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8478 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
8479/* Connect Line-in jack to Surround */
8480 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8481 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8482 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8483/* Connect HP out jack to Front */
8484 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8485 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8486 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02008487
8488 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02008489
8490 { } /* end */
8491};
8492
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008493static struct hda_verb alc883_lenovo_101e_verbs[] = {
8494 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8495 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
8496 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
8497 { } /* end */
8498};
8499
Kailang Yang272a5272007-05-14 11:00:38 +02008500static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
8501 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8502 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8503 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8504 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8505 { } /* end */
8506};
8507
8508static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
8509 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8510 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8511 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8512 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
8513 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8514 { } /* end */
8515};
8516
Kailang Yang189609a2007-08-20 11:31:23 +02008517static struct hda_verb alc883_haier_w66_verbs[] = {
8518 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8519 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8520
8521 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8522
8523 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8524 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8525 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8526 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8527 { } /* end */
8528};
8529
Kailang Yange2757d52008-08-26 13:17:46 +02008530static struct hda_verb alc888_lenovo_sky_verbs[] = {
8531 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8532 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8533 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8534 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8535 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8536 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8537 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8538 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8539 { } /* end */
8540};
8541
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008542static struct hda_verb alc888_6st_dell_verbs[] = {
8543 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8544 { }
8545};
8546
Guido Günther3e1647c2009-06-05 00:47:26 +02008547static struct hda_verb alc883_vaiott_verbs[] = {
8548 /* HP */
8549 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8550 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8551
8552 /* enable unsolicited event */
8553 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8554
8555 { } /* end */
8556};
8557
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008558static void alc888_3st_hp_init_hook(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008559{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008560 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008561
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008562 spec->autocfg.hp_pins[0] = 0x1b;
8563 spec->autocfg.speaker_pins[0] = 0x14;
8564 spec->autocfg.speaker_pins[1] = 0x16;
8565 spec->autocfg.speaker_pins[2] = 0x18;
8566 alc_automute_amp(codec);
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008567}
8568
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008569static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008570 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01008571 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
8572 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008573 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008574 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008575};
8576
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008577/*
8578 * 2ch mode
8579 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008580static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008581 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8582 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8583 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
8584 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008585 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008586};
8587
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008588/*
8589 * 4ch mode
8590 */
8591static struct hda_verb alc888_3st_hp_4ch_init[] = {
8592 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8593 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8594 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8595 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8596 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8597 { } /* end */
8598};
8599
8600/*
8601 * 6ch mode
8602 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008603static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008604 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8605 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008606 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008607 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8608 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008609 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8610 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008611};
8612
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008613static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008614 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008615 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008616 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008617};
8618
Kailang Yang272a5272007-05-14 11:00:38 +02008619/* toggle front-jack and RCA according to the hp-jack state */
8620static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
8621{
8622 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008623
Kailang Yang272a5272007-05-14 11:00:38 +02008624 present = snd_hda_codec_read(codec, 0x1b, 0,
8625 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008626 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8627 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8628 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8629 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008630}
8631
8632/* toggle RCA according to the front-jack state */
8633static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
8634{
8635 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008636
Kailang Yang272a5272007-05-14 11:00:38 +02008637 present = snd_hda_codec_read(codec, 0x14, 0,
8638 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008639 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8640 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008641}
Takashi Iwai47fd8302007-08-10 17:11:07 +02008642
Kailang Yang272a5272007-05-14 11:00:38 +02008643static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
8644 unsigned int res)
8645{
8646 if ((res >> 26) == ALC880_HP_EVENT)
8647 alc888_lenovo_ms7195_front_automute(codec);
8648 if ((res >> 26) == ALC880_FRONT_EVENT)
8649 alc888_lenovo_ms7195_rca_automute(codec);
8650}
8651
8652static struct hda_verb alc883_medion_md2_verbs[] = {
8653 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8654 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8655
8656 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8657
8658 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8659 { } /* end */
8660};
8661
8662/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008663static void alc883_medion_md2_init_hook(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02008664{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008665 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008666
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008667 spec->autocfg.hp_pins[0] = 0x14;
8668 spec->autocfg.speaker_pins[0] = 0x15;
8669 alc_automute_amp(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02008670}
8671
Kailang Yangccc656c2006-10-17 12:32:26 +02008672/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04008673#define alc883_targa_init_hook alc882_targa_init_hook
8674#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01008675
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008676static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
8677{
8678 unsigned int present;
8679
8680 present = snd_hda_codec_read(codec, 0x18, 0,
8681 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8682 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
8683 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8684}
8685
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008686static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008687{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008688 struct alc_spec *spec = codec->spec;
8689
8690 spec->autocfg.hp_pins[0] = 0x15;
8691 spec->autocfg.speaker_pins[0] = 0x14;
8692 alc_automute_amp(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008693 alc883_clevo_m720_mic_automute(codec);
8694}
8695
8696static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01008697 unsigned int res)
8698{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008699 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008700 case ALC880_MIC_EVENT:
8701 alc883_clevo_m720_mic_automute(codec);
8702 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008703 default:
8704 alc_automute_amp_unsol_event(codec, res);
8705 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008706 }
Jiang zhe368c7a92008-03-04 11:20:33 +01008707}
8708
Jiang zhefb97dc62008-03-06 11:07:11 +01008709/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008710static void alc883_2ch_fujitsu_pi2515_init_hook(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008711{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008712 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008713
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008714 spec->autocfg.hp_pins[0] = 0x14;
8715 spec->autocfg.speaker_pins[0] = 0x15;
8716 alc_automute_amp(codec);
Jiang zhefb97dc62008-03-06 11:07:11 +01008717}
8718
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008719static void alc883_haier_w66_init_hook(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008720{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008721 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008722
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008723 spec->autocfg.hp_pins[0] = 0x1b;
8724 spec->autocfg.speaker_pins[0] = 0x14;
8725 alc_automute_amp(codec);
Kailang Yang189609a2007-08-20 11:31:23 +02008726}
8727
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008728static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
8729{
8730 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008731 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008732
David Heidelberger64a8be72009-06-08 16:15:18 +02008733 present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0)
8734 & AC_PINSENSE_PRESENCE;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008735 bits = present ? HDA_AMP_MUTE : 0;
8736 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8737 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008738}
8739
8740static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
8741{
8742 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008743 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008744
8745 present = snd_hda_codec_read(codec, 0x1b, 0,
8746 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008747 bits = present ? HDA_AMP_MUTE : 0;
8748 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8749 HDA_AMP_MUTE, bits);
8750 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8751 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008752}
8753
8754static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
8755 unsigned int res)
8756{
8757 if ((res >> 26) == ALC880_HP_EVENT)
8758 alc883_lenovo_101e_all_automute(codec);
8759 if ((res >> 26) == ALC880_FRONT_EVENT)
8760 alc883_lenovo_101e_ispeaker_automute(codec);
8761}
8762
Takashi Iwai676a9b52007-08-16 15:23:35 +02008763/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008764static void alc883_acer_aspire_init_hook(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02008765{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008766 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008767
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008768 spec->autocfg.hp_pins[0] = 0x14;
8769 spec->autocfg.speaker_pins[0] = 0x15;
8770 spec->autocfg.speaker_pins[1] = 0x16;
8771 alc_automute_amp(codec);
Takashi Iwai676a9b52007-08-16 15:23:35 +02008772}
8773
Kailang Yangd1a991a2007-08-15 16:21:59 +02008774static struct hda_verb alc883_acer_eapd_verbs[] = {
8775 /* HP Pin: output 0 (0x0c) */
8776 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8777 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8778 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8779 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02008780 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8781 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008782 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008783 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
8784 /* eanable EAPD on medion laptop */
8785 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8786 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02008787 /* enable unsolicited event */
8788 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008789 { }
8790};
8791
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008792static void alc888_6st_dell_init_hook(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008793{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008794 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008795
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008796 spec->autocfg.hp_pins[0] = 0x1b;
8797 spec->autocfg.speaker_pins[0] = 0x14;
8798 spec->autocfg.speaker_pins[1] = 0x15;
8799 spec->autocfg.speaker_pins[2] = 0x16;
8800 spec->autocfg.speaker_pins[3] = 0x17;
8801 alc_automute_amp(codec);
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008802}
8803
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008804static void alc888_lenovo_sky_init_hook(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008805{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008806 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008807
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008808 spec->autocfg.hp_pins[0] = 0x1b;
8809 spec->autocfg.speaker_pins[0] = 0x14;
8810 spec->autocfg.speaker_pins[1] = 0x15;
8811 spec->autocfg.speaker_pins[2] = 0x16;
8812 spec->autocfg.speaker_pins[3] = 0x17;
8813 spec->autocfg.speaker_pins[4] = 0x1a;
8814 alc_automute_amp(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008815}
8816
Guido Günther3e1647c2009-06-05 00:47:26 +02008817static void alc883_vaiott_init_hook(struct hda_codec *codec)
8818{
8819 struct alc_spec *spec = codec->spec;
8820
8821 spec->autocfg.hp_pins[0] = 0x15;
8822 spec->autocfg.speaker_pins[0] = 0x14;
8823 spec->autocfg.speaker_pins[1] = 0x17;
8824 alc_automute_amp(codec);
8825}
8826
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008827/*
8828 * generic initialization of ADC, input mixers and output mixers
8829 */
8830static struct hda_verb alc883_auto_init_verbs[] = {
8831 /*
8832 * Unmute ADC0-2 and set the default input to mic-in
8833 */
8834 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8835 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8836 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8837 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8838
Takashi Iwaicb53c622007-08-10 17:21:45 +02008839 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008840 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008841 * Note: PASD motherboards uses the Line In 2 as the input for
8842 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008843 */
8844 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008845 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8846 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8847 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8848 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8849 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008850
8851 /*
8852 * Set up output mixers (0x0c - 0x0f)
8853 */
8854 /* set vol=0 to output mixers */
8855 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8856 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8857 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8858 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8859 /* set up input amps for analog loopback */
8860 /* Amp Indices: DAC = 0, mixer = 1 */
8861 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8862 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8863 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8864 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8865 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8866 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8867 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8868 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8869 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8870 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8871
8872 /* FIXME: use matrix-type input source selection */
8873 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8874 /* Input mixer1 */
8875 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8876 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8877 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008878 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008879 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
8880 /* Input mixer2 */
8881 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8882 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8883 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008884 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Andy Shevchenkoe3cde642007-12-03 16:50:58 +01008885 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008886
8887 { }
8888};
8889
Kailang Yange2757d52008-08-26 13:17:46 +02008890static struct hda_verb alc888_asus_m90v_verbs[] = {
8891 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8892 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8893 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8894 /* enable unsolicited event */
8895 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8896 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8897 { } /* end */
8898};
8899
8900static void alc883_nb_mic_automute(struct hda_codec *codec)
8901{
8902 unsigned int present;
8903
8904 present = snd_hda_codec_read(codec, 0x18, 0,
8905 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8906 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8907 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
8908 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8909 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
8910}
8911
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008912static void alc883_M90V_init_hook(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02008913{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008914 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02008915
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008916 spec->autocfg.hp_pins[0] = 0x1b;
8917 spec->autocfg.speaker_pins[0] = 0x14;
8918 spec->autocfg.speaker_pins[1] = 0x15;
8919 spec->autocfg.speaker_pins[2] = 0x16;
8920 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008921}
8922
8923static void alc883_mode2_unsol_event(struct hda_codec *codec,
8924 unsigned int res)
8925{
8926 switch (res >> 26) {
Kailang Yange2757d52008-08-26 13:17:46 +02008927 case ALC880_MIC_EVENT:
8928 alc883_nb_mic_automute(codec);
8929 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008930 default:
8931 alc_sku_unsol_event(codec, res);
8932 break;
Kailang Yange2757d52008-08-26 13:17:46 +02008933 }
8934}
8935
8936static void alc883_mode2_inithook(struct hda_codec *codec)
8937{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008938 alc883_M90V_init_hook(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008939 alc883_nb_mic_automute(codec);
8940}
8941
8942static struct hda_verb alc888_asus_eee1601_verbs[] = {
8943 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8944 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8945 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8946 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8947 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8948 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
8949 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
8950 /* enable unsolicited event */
8951 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8952 { } /* end */
8953};
8954
Kailang Yange2757d52008-08-26 13:17:46 +02008955static void alc883_eee1601_inithook(struct hda_codec *codec)
8956{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008957 struct alc_spec *spec = codec->spec;
8958
8959 spec->autocfg.hp_pins[0] = 0x14;
8960 spec->autocfg.speaker_pins[0] = 0x1b;
8961 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008962}
8963
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008964static struct hda_verb alc889A_mb31_verbs[] = {
8965 /* Init rear pin (used as headphone output) */
8966 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
8967 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
8968 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8969 /* Init line pin (used as output in 4ch and 6ch mode) */
8970 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
8971 /* Init line 2 pin (used as headphone out by default) */
8972 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
8973 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
8974 { } /* end */
8975};
8976
8977/* Mute speakers according to the headphone jack state */
8978static void alc889A_mb31_automute(struct hda_codec *codec)
8979{
8980 unsigned int present;
8981
8982 /* Mute only in 2ch or 4ch mode */
8983 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
8984 == 0x00) {
8985 present = snd_hda_codec_read(codec, 0x15, 0,
8986 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
8987 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8988 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8989 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8990 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8991 }
8992}
8993
8994static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
8995{
8996 if ((res >> 26) == ALC880_HP_EVENT)
8997 alc889A_mb31_automute(codec);
8998}
8999
Takashi Iwaicb53c622007-08-10 17:21:45 +02009000#ifdef CONFIG_SND_HDA_POWER_SAVE
9001#define alc883_loopbacks alc880_loopbacks
9002#endif
9003
Sasha Alexandrdef319f2009-06-16 16:00:15 -04009004/* pcm configuration: identical with ALC880 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009005#define alc883_pcm_analog_playback alc880_pcm_analog_playback
9006#define alc883_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +01009007#define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009008#define alc883_pcm_digital_playback alc880_pcm_digital_playback
9009#define alc883_pcm_digital_capture alc880_pcm_digital_capture
9010
9011/*
9012 * configuration and preset
9013 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009014static const char *alc883_models[ALC883_MODEL_LAST] = {
9015 [ALC883_3ST_2ch_DIG] = "3stack-dig",
9016 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
9017 [ALC883_3ST_6ch] = "3stack-6ch",
9018 [ALC883_6ST_DIG] = "6stack-dig",
9019 [ALC883_TARGA_DIG] = "targa-dig",
9020 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +02009021 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009022 [ALC883_ACER] = "acer",
Tobin Davis2880a8672007-08-07 11:50:26 +02009023 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009024 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaib1a91462009-06-21 10:56:44 +02009025 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
Hector Martin3b315d72009-06-02 10:54:19 +02009026 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009027 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02009028 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009029 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009030 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02009031 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
9032 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02009033 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02009034 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009035 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009036 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009037 [ALC883_MITAC] = "mitac",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009038 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01009039 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009040 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02009041 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Wu Fengguang3ab90932008-11-17 09:51:09 +01009042 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009043 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c2009-06-05 00:47:26 +02009044 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009045 [ALC883_AUTO] = "auto",
9046};
9047
9048static struct snd_pci_quirk alc883_cfg_tbl[] = {
9049 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009050 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01009051 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01009052 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009053 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
9054 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02009055 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009056 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
9057 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009058 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
9059 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +02009060 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
9061 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +02009062 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
9063 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaib3bdb302009-02-18 13:16:26 +01009064 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC883_AUTO),
Takashi Iwai94683502009-02-13 09:31:20 +01009065 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC883_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009066 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
9067 ALC888_ACER_ASPIRE_4930G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01009068 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
Tony Vroond2fd4b02009-06-21 00:40:10 +01009069 ALC888_ACER_ASPIRE_6530G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02009070 /* default Acer -- disabled as it causes more problems.
9071 * model=auto should work fine now
9072 */
9073 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009074 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Tobin Davisfebe3372007-06-12 11:27:46 +02009075 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009076 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
9077 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01009078 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01009079 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03009080 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Kailang Yanga01c30c2008-10-15 11:14:58 +02009081 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009082 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01009083 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01009084 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02009085 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Travis Place97ec7102008-05-23 18:31:46 +02009086 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009087 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009088 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009089 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
9090 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02009091 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009092 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Tobin Davis57b14f22007-04-18 23:05:36 +02009093 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009094 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
9095 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
9096 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Jiang zhe4383fae2008-04-14 12:58:57 +02009097 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009098 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01009099 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009100 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
9101 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
9102 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
9103 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
9104 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
9105 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
9106 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
9107 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
9108 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +02009109 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009110 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
9111 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02009112 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01009113 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01009114 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01009115 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02009116 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -04009117 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009118 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009119 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009120 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
9121 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
Takashi Iwaidea0a502009-02-09 17:14:52 +01009122 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04009123 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009124 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009125 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01009126 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009127 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009128 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02009129 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02009130 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009131 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
9132 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02009133 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02009134 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01009135 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01009136 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02009137 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Jiang zhe17bba1b2008-06-04 12:11:07 +02009138 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
9139 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009140 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Wu Fengguang4b558992009-01-12 09:18:58 +08009141 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC883_3ST_6ch_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009142 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Guido Günther3e1647c2009-06-05 00:47:26 +02009143 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009144 {}
9145};
9146
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009147static hda_nid_t alc883_slave_dig_outs[] = {
9148 ALC1200_DIGOUT_NID, 0,
9149};
9150
Wu Fengguangb25c9da2009-02-06 15:02:27 +08009151static hda_nid_t alc1200_slave_dig_outs[] = {
9152 ALC883_DIGOUT_NID, 0,
9153};
9154
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009155static struct alc_config_preset alc883_presets[] = {
9156 [ALC883_3ST_2ch_DIG] = {
9157 .mixers = { alc883_3ST_2ch_mixer },
9158 .init_verbs = { alc883_init_verbs },
9159 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9160 .dac_nids = alc883_dac_nids,
9161 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009162 .dig_in_nid = ALC883_DIGIN_NID,
9163 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9164 .channel_mode = alc883_3ST_2ch_modes,
9165 .input_mux = &alc883_capture_source,
9166 },
9167 [ALC883_3ST_6ch_DIG] = {
9168 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9169 .init_verbs = { alc883_init_verbs },
9170 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9171 .dac_nids = alc883_dac_nids,
9172 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009173 .dig_in_nid = ALC883_DIGIN_NID,
9174 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9175 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009176 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009177 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009178 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009179 [ALC883_3ST_6ch] = {
9180 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9181 .init_verbs = { alc883_init_verbs },
9182 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9183 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009184 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9185 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009186 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009187 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009188 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02009189 [ALC883_3ST_6ch_INTEL] = {
9190 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
9191 .init_verbs = { alc883_init_verbs },
9192 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9193 .dac_nids = alc883_dac_nids,
9194 .dig_out_nid = ALC883_DIGOUT_NID,
9195 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009196 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +02009197 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
9198 .channel_mode = alc883_3ST_6ch_intel_modes,
9199 .need_dac_fix = 1,
9200 .input_mux = &alc883_3stack_6ch_intel,
9201 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009202 [ALC883_6ST_DIG] = {
9203 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9204 .init_verbs = { alc883_init_verbs },
9205 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9206 .dac_nids = alc883_dac_nids,
9207 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009208 .dig_in_nid = ALC883_DIGIN_NID,
9209 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9210 .channel_mode = alc883_sixstack_modes,
9211 .input_mux = &alc883_capture_source,
9212 },
Kailang Yangccc656c2006-10-17 12:32:26 +02009213 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009214 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
9215 .init_verbs = { alc883_init_verbs, alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009216 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9217 .dac_nids = alc883_dac_nids,
9218 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009219 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9220 .channel_mode = alc883_3ST_6ch_modes,
9221 .need_dac_fix = 1,
9222 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009223 .unsol_event = alc883_targa_unsol_event,
9224 .init_hook = alc883_targa_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02009225 },
9226 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009227 .mixers = { alc883_targa_2ch_mixer},
9228 .init_verbs = { alc883_init_verbs, alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009229 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9230 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009231 .adc_nids = alc883_adc_nids_alt,
9232 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangccc656c2006-10-17 12:32:26 +02009233 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009234 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9235 .channel_mode = alc883_3ST_2ch_modes,
9236 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009237 .unsol_event = alc883_targa_unsol_event,
9238 .init_hook = alc883_targa_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02009239 },
David Heidelberger64a8be72009-06-08 16:15:18 +02009240 [ALC883_TARGA_8ch_DIG] = {
9241 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9242 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009243 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +02009244 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9245 .dac_nids = alc883_dac_nids,
9246 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9247 .adc_nids = alc883_adc_nids_rev,
9248 .capsrc_nids = alc883_capsrc_nids_rev,
9249 .dig_out_nid = ALC883_DIGOUT_NID,
9250 .dig_in_nid = ALC883_DIGIN_NID,
9251 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
9252 .channel_mode = alc883_4ST_8ch_modes,
9253 .need_dac_fix = 1,
9254 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009255 .unsol_event = alc883_targa_unsol_event,
9256 .init_hook = alc883_targa_init_hook,
David Heidelberger64a8be72009-06-08 16:15:18 +02009257 },
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02009258 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009259 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02009260 /* On TravelMate laptops, GPIO 0 enables the internal speaker
9261 * and the headphone jack. Turn this on and rely on the
9262 * standard mute methods whenever the user wants to turn
9263 * these outputs off.
9264 */
9265 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
9266 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9267 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02009268 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9269 .channel_mode = alc883_3ST_2ch_modes,
9270 .input_mux = &alc883_capture_source,
9271 },
Tobin Davis2880a8672007-08-07 11:50:26 +02009272 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009273 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02009274 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a8672007-08-07 11:50:26 +02009275 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9276 .dac_nids = alc883_dac_nids,
9277 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a8672007-08-07 11:50:26 +02009278 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9279 .channel_mode = alc883_3ST_2ch_modes,
9280 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009281 .unsol_event = alc_automute_amp_unsol_event,
9282 .init_hook = alc883_acer_aspire_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +02009283 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009284 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009285 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009286 alc883_chmode_mixer },
9287 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9288 alc888_acer_aspire_4930g_verbs },
9289 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9290 .dac_nids = alc883_dac_nids,
9291 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9292 .adc_nids = alc883_adc_nids_rev,
9293 .capsrc_nids = alc883_capsrc_nids_rev,
9294 .dig_out_nid = ALC883_DIGOUT_NID,
9295 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9296 .channel_mode = alc883_3ST_6ch_modes,
9297 .need_dac_fix = 1,
9298 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009299 ARRAY_SIZE(alc888_2_capture_sources),
9300 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009301 .unsol_event = alc_automute_amp_unsol_event,
9302 .init_hook = alc888_acer_aspire_4930g_init_hook,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009303 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01009304 [ALC888_ACER_ASPIRE_6530G] = {
9305 .mixers = { alc888_acer_aspire_6530_mixer },
9306 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9307 alc888_acer_aspire_6530g_verbs },
9308 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9309 .dac_nids = alc883_dac_nids,
9310 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9311 .adc_nids = alc883_adc_nids_rev,
9312 .capsrc_nids = alc883_capsrc_nids_rev,
9313 .dig_out_nid = ALC883_DIGOUT_NID,
9314 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9315 .channel_mode = alc883_3ST_2ch_modes,
9316 .num_mux_defs =
9317 ARRAY_SIZE(alc888_2_capture_sources),
9318 .input_mux = alc888_acer_aspire_6530_sources,
9319 .unsol_event = alc_automute_amp_unsol_event,
9320 .init_hook = alc888_acer_aspire_4930g_init_hook,
9321 },
Hector Martin3b315d72009-06-02 10:54:19 +02009322 [ALC888_ACER_ASPIRE_8930G] = {
9323 .mixers = { alc888_base_mixer,
9324 alc883_chmode_mixer },
9325 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin018df412009-06-04 00:13:40 +02009326 alc889_acer_aspire_8930g_verbs },
Hector Martin3b315d72009-06-02 10:54:19 +02009327 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9328 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +02009329 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9330 .adc_nids = alc889_adc_nids,
9331 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +02009332 .dig_out_nid = ALC883_DIGOUT_NID,
9333 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9334 .channel_mode = alc883_3ST_6ch_modes,
9335 .need_dac_fix = 1,
9336 .const_channel_count = 6,
9337 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +02009338 ARRAY_SIZE(alc889_capture_sources),
9339 .input_mux = alc889_capture_sources,
Hector Martin3b315d72009-06-02 10:54:19 +02009340 .unsol_event = alc_automute_amp_unsol_event,
Hector Martin018df412009-06-04 00:13:40 +02009341 .init_hook = alc889_acer_aspire_8930g_init_hook,
Hector Martin3b315d72009-06-02 10:54:19 +02009342 },
Tobin Davisc07584c2006-10-13 12:32:16 +02009343 [ALC883_MEDION] = {
9344 .mixers = { alc883_fivestack_mixer,
9345 alc883_chmode_mixer },
9346 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009347 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02009348 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9349 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009350 .adc_nids = alc883_adc_nids_alt,
9351 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Tobin Davisc07584c2006-10-13 12:32:16 +02009352 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9353 .channel_mode = alc883_sixstack_modes,
9354 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009355 },
Kailang Yang272a5272007-05-14 11:00:38 +02009356 [ALC883_MEDION_MD2] = {
9357 .mixers = { alc883_medion_md2_mixer},
9358 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
9359 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9360 .dac_nids = alc883_dac_nids,
9361 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009362 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9363 .channel_mode = alc883_3ST_2ch_modes,
9364 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009365 .unsol_event = alc_automute_amp_unsol_event,
9366 .init_hook = alc883_medion_md2_init_hook,
Kailang Yangea1fb292008-08-26 12:58:38 +02009367 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009368 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009369 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009370 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
9371 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9372 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009373 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9374 .channel_mode = alc883_3ST_2ch_modes,
9375 .input_mux = &alc883_capture_source,
9376 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009377 [ALC883_CLEVO_M720] = {
9378 .mixers = { alc883_clevo_m720_mixer },
9379 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01009380 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9381 .dac_nids = alc883_dac_nids,
9382 .dig_out_nid = ALC883_DIGOUT_NID,
9383 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9384 .channel_mode = alc883_3ST_2ch_modes,
9385 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009386 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009387 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +01009388 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009389 [ALC883_LENOVO_101E_2ch] = {
9390 .mixers = { alc883_lenovo_101e_2ch_mixer},
9391 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
9392 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9393 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009394 .adc_nids = alc883_adc_nids_alt,
9395 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009396 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9397 .channel_mode = alc883_3ST_2ch_modes,
9398 .input_mux = &alc883_lenovo_101e_capture_source,
9399 .unsol_event = alc883_lenovo_101e_unsol_event,
9400 .init_hook = alc883_lenovo_101e_all_automute,
9401 },
Kailang Yang272a5272007-05-14 11:00:38 +02009402 [ALC883_LENOVO_NB0763] = {
9403 .mixers = { alc883_lenovo_nb0763_mixer },
9404 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
9405 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9406 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02009407 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9408 .channel_mode = alc883_3ST_2ch_modes,
9409 .need_dac_fix = 1,
9410 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009411 .unsol_event = alc_automute_amp_unsol_event,
9412 .init_hook = alc883_medion_md2_init_hook,
Kailang Yang272a5272007-05-14 11:00:38 +02009413 },
9414 [ALC888_LENOVO_MS7195_DIG] = {
9415 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9416 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
9417 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9418 .dac_nids = alc883_dac_nids,
9419 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009420 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9421 .channel_mode = alc883_3ST_6ch_modes,
9422 .need_dac_fix = 1,
9423 .input_mux = &alc883_capture_source,
9424 .unsol_event = alc883_lenovo_ms7195_unsol_event,
9425 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02009426 },
9427 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009428 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +02009429 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
9430 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9431 .dac_nids = alc883_dac_nids,
9432 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02009433 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9434 .channel_mode = alc883_3ST_2ch_modes,
9435 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009436 .unsol_event = alc_automute_amp_unsol_event,
9437 .init_hook = alc883_haier_w66_init_hook,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009438 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009439 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009440 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009441 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009442 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9443 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009444 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
9445 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009446 .need_dac_fix = 1,
9447 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009448 .unsol_event = alc_automute_amp_unsol_event,
9449 .init_hook = alc888_3st_hp_init_hook,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009450 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009451 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01009452 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009453 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
9454 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9455 .dac_nids = alc883_dac_nids,
9456 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009457 .dig_in_nid = ALC883_DIGIN_NID,
9458 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9459 .channel_mode = alc883_sixstack_modes,
9460 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009461 .unsol_event = alc_automute_amp_unsol_event,
9462 .init_hook = alc888_6st_dell_init_hook,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009463 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009464 [ALC883_MITAC] = {
9465 .mixers = { alc883_mitac_mixer },
9466 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
9467 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9468 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009469 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9470 .channel_mode = alc883_3ST_2ch_modes,
9471 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009472 .unsol_event = alc_automute_amp_unsol_event,
9473 .init_hook = alc883_mitac_init_hook,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009474 },
Jiang zhefb97dc62008-03-06 11:07:11 +01009475 [ALC883_FUJITSU_PI2515] = {
9476 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
9477 .init_verbs = { alc883_init_verbs,
9478 alc883_2ch_fujitsu_pi2515_verbs},
9479 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9480 .dac_nids = alc883_dac_nids,
9481 .dig_out_nid = ALC883_DIGOUT_NID,
9482 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9483 .channel_mode = alc883_3ST_2ch_modes,
9484 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009485 .unsol_event = alc_automute_amp_unsol_event,
9486 .init_hook = alc883_2ch_fujitsu_pi2515_init_hook,
Jiang zhefb97dc62008-03-06 11:07:11 +01009487 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009488 [ALC888_FUJITSU_XA3530] = {
9489 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
9490 .init_verbs = { alc883_init_verbs,
9491 alc888_fujitsu_xa3530_verbs },
9492 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9493 .dac_nids = alc883_dac_nids,
9494 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9495 .adc_nids = alc883_adc_nids_rev,
9496 .capsrc_nids = alc883_capsrc_nids_rev,
9497 .dig_out_nid = ALC883_DIGOUT_NID,
9498 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
9499 .channel_mode = alc888_4ST_8ch_intel_modes,
9500 .num_mux_defs =
9501 ARRAY_SIZE(alc888_2_capture_sources),
9502 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009503 .unsol_event = alc_automute_amp_unsol_event,
9504 .init_hook = alc888_fujitsu_xa3530_init_hook,
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009505 },
Kailang Yange2757d52008-08-26 13:17:46 +02009506 [ALC888_LENOVO_SKY] = {
9507 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
9508 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
9509 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9510 .dac_nids = alc883_dac_nids,
9511 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +02009512 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9513 .channel_mode = alc883_sixstack_modes,
9514 .need_dac_fix = 1,
9515 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009516 .unsol_event = alc_automute_amp_unsol_event,
9517 .init_hook = alc888_lenovo_sky_init_hook,
Kailang Yange2757d52008-08-26 13:17:46 +02009518 },
9519 [ALC888_ASUS_M90V] = {
9520 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9521 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
9522 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9523 .dac_nids = alc883_dac_nids,
9524 .dig_out_nid = ALC883_DIGOUT_NID,
9525 .dig_in_nid = ALC883_DIGIN_NID,
9526 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9527 .channel_mode = alc883_3ST_6ch_modes,
9528 .need_dac_fix = 1,
9529 .input_mux = &alc883_fujitsu_pi2515_capture_source,
9530 .unsol_event = alc883_mode2_unsol_event,
9531 .init_hook = alc883_mode2_inithook,
9532 },
9533 [ALC888_ASUS_EEE1601] = {
9534 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009535 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +02009536 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
9537 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9538 .dac_nids = alc883_dac_nids,
9539 .dig_out_nid = ALC883_DIGOUT_NID,
9540 .dig_in_nid = ALC883_DIGIN_NID,
9541 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9542 .channel_mode = alc883_3ST_2ch_modes,
9543 .need_dac_fix = 1,
9544 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009545 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +02009546 .init_hook = alc883_eee1601_inithook,
9547 },
Wu Fengguang3ab90932008-11-17 09:51:09 +01009548 [ALC1200_ASUS_P5Q] = {
9549 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9550 .init_verbs = { alc883_init_verbs },
9551 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9552 .dac_nids = alc883_dac_nids,
9553 .dig_out_nid = ALC1200_DIGOUT_NID,
9554 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +08009555 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +01009556 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9557 .channel_mode = alc883_sixstack_modes,
9558 .input_mux = &alc883_capture_source,
9559 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009560 [ALC889A_MB31] = {
9561 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
9562 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
9563 alc880_gpio1_init_verbs },
9564 .adc_nids = alc883_adc_nids,
9565 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
9566 .dac_nids = alc883_dac_nids,
9567 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9568 .channel_mode = alc889A_mb31_6ch_modes,
9569 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
9570 .input_mux = &alc889A_mb31_capture_source,
9571 .dig_out_nid = ALC883_DIGOUT_NID,
9572 .unsol_event = alc889A_mb31_unsol_event,
9573 .init_hook = alc889A_mb31_automute,
9574 },
Guido Günther3e1647c2009-06-05 00:47:26 +02009575 [ALC883_SONY_VAIO_TT] = {
9576 .mixers = { alc883_vaiott_mixer },
9577 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
9578 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9579 .dac_nids = alc883_dac_nids,
9580 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9581 .channel_mode = alc883_3ST_2ch_modes,
9582 .input_mux = &alc883_capture_source,
9583 .unsol_event = alc_automute_amp_unsol_event,
9584 .init_hook = alc883_vaiott_init_hook,
9585 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009586};
9587
9588
9589/*
9590 * BIOS auto configuration
9591 */
9592static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
9593 hda_nid_t nid, int pin_type,
9594 int dac_idx)
9595{
9596 /* set as output */
9597 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009598 int idx;
9599
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009600 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009601 if (spec->multiout.dac_nids[dac_idx] == 0x25)
9602 idx = 4;
9603 else
9604 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009605 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
9606
9607}
9608
9609static void alc883_auto_init_multi_out(struct hda_codec *codec)
9610{
9611 struct alc_spec *spec = codec->spec;
9612 int i;
9613
9614 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009615 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009616 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009617 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009618 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009619 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009620 }
9621}
9622
9623static void alc883_auto_init_hp_out(struct hda_codec *codec)
9624{
9625 struct alc_spec *spec = codec->spec;
9626 hda_nid_t pin;
9627
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009628 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009629 if (pin) /* connect to front */
9630 /* use dac 0 */
9631 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009632 pin = spec->autocfg.speaker_pins[0];
9633 if (pin)
9634 alc883_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009635}
9636
9637#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
9638#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
9639
9640static void alc883_auto_init_analog_input(struct hda_codec *codec)
9641{
9642 struct alc_spec *spec = codec->spec;
9643 int i;
9644
9645 for (i = 0; i < AUTO_PIN_LAST; i++) {
9646 hda_nid_t nid = spec->autocfg.input_pins[i];
9647 if (alc883_is_input_pin(nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01009648 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01009649 if (nid != ALC883_PIN_CD_NID &&
9650 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009651 snd_hda_codec_write(codec, nid, 0,
9652 AC_VERB_SET_AMP_GAIN_MUTE,
9653 AMP_OUT_MUTE);
9654 }
9655 }
9656}
9657
Takashi Iwaif511b012008-08-15 16:46:42 +02009658#define alc883_auto_init_input_src alc882_auto_init_input_src
9659
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009660/* almost identical with ALC880 parser... */
9661static int alc883_parse_auto_config(struct hda_codec *codec)
9662{
9663 struct alc_spec *spec = codec->spec;
9664 int err = alc880_parse_auto_config(codec);
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009665 struct auto_pin_cfg *cfg = &spec->autocfg;
9666 int i;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009667
9668 if (err < 0)
9669 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02009670 else if (!err)
9671 return 0; /* no config found */
9672
9673 err = alc_auto_add_mic_boost(codec);
9674 if (err < 0)
9675 return err;
9676
9677 /* hack - override the init verbs */
9678 spec->init_verbs[0] = alc883_auto_init_verbs;
Takashi Iwai776e1842007-08-29 15:07:11 +02009679
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009680 /* setup input_mux for ALC889 */
9681 if (codec->vendor_id == 0x10ec0889) {
9682 /* digital-mic input pin is excluded in alc880_auto_create..()
9683 * because it's under 0x18
9684 */
9685 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
9686 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
9687 struct hda_input_mux *imux = &spec->private_imux[0];
9688 for (i = 1; i < 3; i++)
9689 memcpy(&spec->private_imux[i],
9690 &spec->private_imux[0],
9691 sizeof(spec->private_imux[0]));
9692 imux->items[imux->num_items].label = "Int DMic";
9693 imux->items[imux->num_items].index = 0x0b;
9694 imux->num_items++;
9695 spec->num_mux_defs = 3;
9696 spec->input_mux = spec->private_imux;
9697 }
9698 }
9699
Takashi Iwai776e1842007-08-29 15:07:11 +02009700 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009701}
9702
9703/* additional initialization for auto-configuration model */
9704static void alc883_auto_init(struct hda_codec *codec)
9705{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009706 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009707 alc883_auto_init_multi_out(codec);
9708 alc883_auto_init_hp_out(codec);
9709 alc883_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02009710 alc883_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009711 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02009712 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009713}
9714
9715static int patch_alc883(struct hda_codec *codec)
9716{
9717 struct alc_spec *spec;
9718 int err, board_config;
9719
9720 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
9721 if (spec == NULL)
9722 return -ENOMEM;
9723
9724 codec->spec = spec;
9725
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02009726 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
9727
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009728 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
9729 alc883_models,
9730 alc883_cfg_tbl);
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009731 if (board_config < 0 || board_config >= ALC883_MODEL_LAST) {
9732 /* Pick up systems that don't supply PCI SSID */
9733 switch (codec->subsystem_id) {
9734 case 0x106b3600: /* Macbook 3.1 */
9735 board_config = ALC889A_MB31;
9736 break;
9737 default:
9738 printk(KERN_INFO
9739 "hda_codec: Unknown model for %s, trying "
9740 "auto-probe from BIOS...\n", codec->chip_name);
9741 board_config = ALC883_AUTO;
9742 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009743 }
9744
9745 if (board_config == ALC883_AUTO) {
9746 /* automatic parse from the BIOS config */
9747 err = alc883_parse_auto_config(codec);
9748 if (err < 0) {
9749 alc_free(codec);
9750 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009751 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009752 printk(KERN_INFO
9753 "hda_codec: Cannot set up configuration "
9754 "from BIOS. Using base mode...\n");
9755 board_config = ALC883_3ST_2ch_DIG;
9756 }
9757 }
9758
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09009759 err = snd_hda_attach_beep_device(codec, 0x1);
9760 if (err < 0) {
9761 alc_free(codec);
9762 return err;
9763 }
9764
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009765 if (board_config != ALC883_AUTO)
9766 setup_preset(spec, &alc883_presets[board_config]);
9767
Kailang Yang2f893282008-05-27 12:14:47 +02009768 switch (codec->vendor_id) {
9769 case 0x10ec0888:
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009770 if (!spec->num_adc_nids) {
9771 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
9772 spec->adc_nids = alc883_adc_nids;
9773 }
9774 if (!spec->capsrc_nids)
9775 spec->capsrc_nids = alc883_capsrc_nids;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02009776 spec->init_amp = ALC_INIT_DEFAULT; /* always initialize */
Kailang Yang2f893282008-05-27 12:14:47 +02009777 break;
9778 case 0x10ec0889:
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009779 if (!spec->num_adc_nids) {
9780 spec->num_adc_nids = ARRAY_SIZE(alc889_adc_nids);
9781 spec->adc_nids = alc889_adc_nids;
9782 }
9783 if (!spec->capsrc_nids)
9784 spec->capsrc_nids = alc889_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +02009785 break;
9786 default:
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009787 if (!spec->num_adc_nids) {
9788 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
9789 spec->adc_nids = alc883_adc_nids;
9790 }
9791 if (!spec->capsrc_nids)
9792 spec->capsrc_nids = alc883_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +02009793 break;
9794 }
9795
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009796 spec->stream_analog_playback = &alc883_pcm_analog_playback;
9797 spec->stream_analog_capture = &alc883_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01009798 spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009799
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009800 spec->stream_digital_playback = &alc883_pcm_digital_playback;
9801 spec->stream_digital_capture = &alc883_pcm_digital_capture;
9802
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009803 if (!spec->cap_mixer)
9804 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01009805 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009806
Takashi Iwai2134ea42008-01-10 16:53:55 +01009807 spec->vmaster_nid = 0x0c;
9808
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009809 codec->patch_ops = alc_patch_ops;
9810 if (board_config == ALC883_AUTO)
9811 spec->init_hook = alc883_auto_init;
Kailang Yangf9423e72008-05-27 12:32:25 +02009812
Takashi Iwaicb53c622007-08-10 17:21:45 +02009813#ifdef CONFIG_SND_HDA_POWER_SAVE
9814 if (!spec->loopback.amplist)
9815 spec->loopback.amplist = alc883_loopbacks;
9816#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01009817 codec->proc_widget_hook = print_realtek_coef;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009818
9819 return 0;
9820}
9821
9822/*
Kailang Yangdf694da2005-12-05 19:42:22 +01009823 * ALC262 support
9824 */
9825
9826#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
9827#define ALC262_DIGIN_NID ALC880_DIGIN_NID
9828
9829#define alc262_dac_nids alc260_dac_nids
9830#define alc262_adc_nids alc882_adc_nids
9831#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +01009832#define alc262_capsrc_nids alc882_capsrc_nids
9833#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +01009834
9835#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01009836#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01009837
Kailang Yang4e555fe2008-08-26 13:05:55 +02009838static hda_nid_t alc262_dmic_adc_nids[1] = {
9839 /* ADC0 */
9840 0x09
9841};
9842
9843static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
9844
Kailang Yangdf694da2005-12-05 19:42:22 +01009845static struct snd_kcontrol_new alc262_base_mixer[] = {
9846 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9847 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9848 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9849 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9850 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9851 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9852 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9853 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009854 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009855 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9856 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009857 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009858 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
9859 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9860 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
9861 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009862 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01009863};
9864
Takashi Iwaice875f02008-01-28 18:17:43 +01009865/* update HP, line and mono-out pins according to the master switch */
9866static void alc262_hp_master_update(struct hda_codec *codec)
9867{
9868 struct alc_spec *spec = codec->spec;
9869 int val = spec->master_sw;
9870
9871 /* HP & line-out */
9872 snd_hda_codec_write_cache(codec, 0x1b, 0,
9873 AC_VERB_SET_PIN_WIDGET_CONTROL,
9874 val ? PIN_HP : 0);
9875 snd_hda_codec_write_cache(codec, 0x15, 0,
9876 AC_VERB_SET_PIN_WIDGET_CONTROL,
9877 val ? PIN_HP : 0);
9878 /* mono (speaker) depending on the HP jack sense */
9879 val = val && !spec->jack_present;
9880 snd_hda_codec_write_cache(codec, 0x16, 0,
9881 AC_VERB_SET_PIN_WIDGET_CONTROL,
9882 val ? PIN_OUT : 0);
9883}
9884
9885static void alc262_hp_bpc_automute(struct hda_codec *codec)
9886{
9887 struct alc_spec *spec = codec->spec;
9888 unsigned int presence;
9889 presence = snd_hda_codec_read(codec, 0x1b, 0,
9890 AC_VERB_GET_PIN_SENSE, 0);
9891 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9892 alc262_hp_master_update(codec);
9893}
9894
9895static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
9896{
9897 if ((res >> 26) != ALC880_HP_EVENT)
9898 return;
9899 alc262_hp_bpc_automute(codec);
9900}
9901
9902static void alc262_hp_wildwest_automute(struct hda_codec *codec)
9903{
9904 struct alc_spec *spec = codec->spec;
9905 unsigned int presence;
9906 presence = snd_hda_codec_read(codec, 0x15, 0,
9907 AC_VERB_GET_PIN_SENSE, 0);
9908 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9909 alc262_hp_master_update(codec);
9910}
9911
9912static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
9913 unsigned int res)
9914{
9915 if ((res >> 26) != ALC880_HP_EVENT)
9916 return;
9917 alc262_hp_wildwest_automute(codec);
9918}
9919
Takashi Iwaib72519b2009-05-08 14:31:55 +02009920#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +01009921
9922static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
9923 struct snd_ctl_elem_value *ucontrol)
9924{
9925 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9926 struct alc_spec *spec = codec->spec;
9927 int val = !!*ucontrol->value.integer.value;
9928
9929 if (val == spec->master_sw)
9930 return 0;
9931 spec->master_sw = val;
9932 alc262_hp_master_update(codec);
9933 return 1;
9934}
9935
Takashi Iwaib72519b2009-05-08 14:31:55 +02009936#define ALC262_HP_MASTER_SWITCH \
9937 { \
9938 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
9939 .name = "Master Playback Switch", \
9940 .info = snd_ctl_boolean_mono_info, \
9941 .get = alc262_hp_master_sw_get, \
9942 .put = alc262_hp_master_sw_put, \
9943 }
9944
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009945static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +02009946 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009947 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9948 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9949 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009950 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9951 HDA_OUTPUT),
9952 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9953 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009954 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9955 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009956 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009957 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9958 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009959 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009960 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9961 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9962 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9963 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009964 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
9965 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
9966 { } /* end */
9967};
9968
Kailang Yangcd7509a2007-01-26 18:33:17 +01009969static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +02009970 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +01009971 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9972 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9973 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9974 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009975 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9976 HDA_OUTPUT),
9977 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9978 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009979 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
9980 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009981 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009982 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9983 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9984 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9985 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009986 { } /* end */
9987};
9988
9989static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
9990 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9991 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009992 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009993 { } /* end */
9994};
9995
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009996/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009997static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009998{
9999 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010000
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010001 spec->autocfg.hp_pins[0] = 0x15;
10002 spec->autocfg.speaker_pins[0] = 0x0c; /* HACK: not actually a pin */
10003 alc_automute_amp(codec);
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010004}
10005
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010006static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010010007 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10008 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010009 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10010 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10011 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10012 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10013 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10014 { } /* end */
10015};
10016
10017static struct hda_verb alc262_hp_t5735_verbs[] = {
10018 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10019 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10020
10021 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10022 { }
10023};
10024
Kailang Yang8c427222008-01-10 13:03:59 +010010025static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +010010026 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10027 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010010028 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
10029 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010010030 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10031 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10032 { } /* end */
10033};
10034
10035static struct hda_verb alc262_hp_rp5700_verbs[] = {
10036 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10037 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10038 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10039 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10040 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10041 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10042 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10043 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10044 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10045 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10046 {}
10047};
10048
10049static struct hda_input_mux alc262_hp_rp5700_capture_source = {
10050 .num_items = 1,
10051 .items = {
10052 { "Line", 0x1 },
10053 },
10054};
10055
Takashi Iwai42171c12009-05-08 14:11:43 +020010056/* bind hp and internal speaker mute (with plug check) as master switch */
10057static void alc262_hippo_master_update(struct hda_codec *codec)
10058{
10059 struct alc_spec *spec = codec->spec;
10060 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10061 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
10062 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
10063 unsigned int mute;
10064
10065 /* HP */
10066 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
10067 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
10068 HDA_AMP_MUTE, mute);
10069 /* mute internal speaker per jack sense */
10070 if (spec->jack_present)
10071 mute = HDA_AMP_MUTE;
10072 if (line_nid)
10073 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
10074 HDA_AMP_MUTE, mute);
10075 if (speaker_nid && speaker_nid != line_nid)
10076 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
10077 HDA_AMP_MUTE, mute);
10078}
10079
10080#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
10081
10082static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
10083 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +020010084{
10085 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +020010086 struct alc_spec *spec = codec->spec;
10087 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010088
Takashi Iwai42171c12009-05-08 14:11:43 +020010089 if (val == spec->master_sw)
10090 return 0;
10091 spec->master_sw = val;
10092 alc262_hippo_master_update(codec);
10093 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010094}
Takashi Iwai5b319542007-07-26 11:49:22 +020010095
Takashi Iwai42171c12009-05-08 14:11:43 +020010096#define ALC262_HIPPO_MASTER_SWITCH \
10097 { \
10098 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10099 .name = "Master Playback Switch", \
10100 .info = snd_ctl_boolean_mono_info, \
10101 .get = alc262_hippo_master_sw_get, \
10102 .put = alc262_hippo_master_sw_put, \
10103 }
10104
10105static struct snd_kcontrol_new alc262_hippo_mixer[] = {
10106 ALC262_HIPPO_MASTER_SWITCH,
10107 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10108 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10109 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10110 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10111 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10112 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10113 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10114 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10115 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10116 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10117 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10118 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10119 { } /* end */
10120};
10121
10122static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
10123 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10124 ALC262_HIPPO_MASTER_SWITCH,
10125 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10126 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10127 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10128 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10129 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10130 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10131 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10132 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10133 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10134 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10135 { } /* end */
10136};
10137
10138/* mute/unmute internal speaker according to the hp jack and mute state */
10139static void alc262_hippo_automute(struct hda_codec *codec)
10140{
10141 struct alc_spec *spec = codec->spec;
10142 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10143 unsigned int present;
10144
10145 /* need to execute and sync at first */
10146 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
10147 present = snd_hda_codec_read(codec, hp_nid, 0,
10148 AC_VERB_GET_PIN_SENSE, 0);
10149 spec->jack_present = (present & 0x80000000) != 0;
10150 alc262_hippo_master_update(codec);
10151}
10152
10153static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
10154{
10155 if ((res >> 26) != ALC880_HP_EVENT)
10156 return;
10157 alc262_hippo_automute(codec);
10158}
10159
10160static void alc262_hippo_init_hook(struct hda_codec *codec)
10161{
10162 struct alc_spec *spec = codec->spec;
10163
10164 spec->autocfg.hp_pins[0] = 0x15;
10165 spec->autocfg.speaker_pins[0] = 0x14;
10166 alc262_hippo_automute(codec);
10167}
10168
10169static void alc262_hippo1_init_hook(struct hda_codec *codec)
10170{
10171 struct alc_spec *spec = codec->spec;
10172
10173 spec->autocfg.hp_pins[0] = 0x1b;
10174 spec->autocfg.speaker_pins[0] = 0x14;
10175 alc262_hippo_automute(codec);
10176}
10177
10178
Kailang Yang272a5272007-05-14 11:00:38 +020010179static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +020010180 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020010181 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +020010182 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10183 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10184 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10185 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10186 { } /* end */
10187};
10188
Kailang Yang83c34212007-07-05 11:43:05 +020010189static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020010190 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10191 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +020010192 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10193 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10194 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10195 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10196 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10197 { } /* end */
10198};
Kailang Yang272a5272007-05-14 11:00:38 +020010199
Tony Vroonba340e82009-02-02 19:01:30 +000010200static struct snd_kcontrol_new alc262_tyan_mixer[] = {
10201 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10202 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
10203 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
10204 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
10205 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10206 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10207 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10208 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10209 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10210 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10211 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10212 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10213 { } /* end */
10214};
10215
10216static struct hda_verb alc262_tyan_verbs[] = {
10217 /* Headphone automute */
10218 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10219 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10220 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10221
10222 /* P11 AUX_IN, white 4-pin connector */
10223 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10224 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
10225 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
10226 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
10227
10228 {}
10229};
10230
10231/* unsolicited event for HP jack sensing */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010232static void alc262_tyan_init_hook(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000010233{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010234 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000010235
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010236 spec->autocfg.hp_pins[0] = 0x1b;
10237 spec->autocfg.speaker_pins[0] = 0x15;
10238 alc_automute_amp(codec);
Tony Vroonba340e82009-02-02 19:01:30 +000010239}
10240
Tony Vroonba340e82009-02-02 19:01:30 +000010241
Kailang Yangdf694da2005-12-05 19:42:22 +010010242#define alc262_capture_mixer alc882_capture_mixer
10243#define alc262_capture_alt_mixer alc882_capture_alt_mixer
10244
10245/*
10246 * generic initialization of ADC, input mixers and output mixers
10247 */
10248static struct hda_verb alc262_init_verbs[] = {
10249 /*
10250 * Unmute ADC0-2 and set the default input to mic-in
10251 */
10252 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10253 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10254 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10255 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10256 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10257 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10258
Takashi Iwaicb53c622007-08-10 17:21:45 +020010259 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010260 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010261 * Note: PASD motherboards uses the Line In 2 as the input for
10262 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010263 */
10264 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010265 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10266 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10267 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10268 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10269 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010270
10271 /*
10272 * Set up output mixers (0x0c - 0x0e)
10273 */
10274 /* set vol=0 to output mixers */
10275 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10276 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10277 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10278 /* set up input amps for analog loopback */
10279 /* Amp Indices: DAC = 0, mixer = 1 */
10280 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10281 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10282 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10283 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10284 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10285 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10286
10287 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10288 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10289 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10290 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10291 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10292 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10293
10294 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10295 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10296 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10297 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10298 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020010299
Kailang Yangdf694da2005-12-05 19:42:22 +010010300 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10301 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020010302
Kailang Yangdf694da2005-12-05 19:42:22 +010010303 /* FIXME: use matrix-type input source selection */
10304 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10305 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10306 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10307 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10308 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10309 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10310 /* Input mixer2 */
10311 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10312 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10313 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10314 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10315 /* Input mixer3 */
10316 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10317 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10318 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010319 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010010320
10321 { }
10322};
10323
Kailang Yang4e555fe2008-08-26 13:05:55 +020010324static struct hda_verb alc262_eapd_verbs[] = {
10325 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10326 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10327 { }
10328};
10329
Kailang Yangccc656c2006-10-17 12:32:26 +020010330static struct hda_verb alc262_hippo_unsol_verbs[] = {
10331 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10332 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10333 {}
10334};
10335
10336static struct hda_verb alc262_hippo1_unsol_verbs[] = {
10337 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10338 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10339 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10340
10341 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10342 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10343 {}
10344};
10345
Kailang Yang272a5272007-05-14 11:00:38 +020010346static struct hda_verb alc262_sony_unsol_verbs[] = {
10347 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10348 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10349 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
10350
10351 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10352 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090010353 {}
Kailang Yang272a5272007-05-14 11:00:38 +020010354};
10355
Kailang Yang4e555fe2008-08-26 13:05:55 +020010356static struct hda_input_mux alc262_dmic_capture_source = {
10357 .num_items = 2,
10358 .items = {
10359 { "Int DMic", 0x9 },
10360 { "Mic", 0x0 },
10361 },
10362};
10363
10364static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
10365 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10366 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10367 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10368 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10369 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020010370 { } /* end */
10371};
10372
10373static struct hda_verb alc262_toshiba_s06_verbs[] = {
10374 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10375 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10376 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10377 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10378 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
10379 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10380 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
10381 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10382 {}
10383};
10384
10385static void alc262_dmic_automute(struct hda_codec *codec)
10386{
10387 unsigned int present;
10388
10389 present = snd_hda_codec_read(codec, 0x18, 0,
10390 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10391 snd_hda_codec_write(codec, 0x22, 0,
10392 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x09);
10393}
10394
Kailang Yang4e555fe2008-08-26 13:05:55 +020010395
10396/* unsolicited event for HP jack sensing */
10397static void alc262_toshiba_s06_unsol_event(struct hda_codec *codec,
10398 unsigned int res)
10399{
Kailang Yang4e555fe2008-08-26 13:05:55 +020010400 if ((res >> 26) == ALC880_MIC_EVENT)
10401 alc262_dmic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010402 else
10403 alc_sku_unsol_event(codec, res);
Kailang Yang4e555fe2008-08-26 13:05:55 +020010404}
10405
10406static void alc262_toshiba_s06_init_hook(struct hda_codec *codec)
10407{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010408 struct alc_spec *spec = codec->spec;
10409
10410 spec->autocfg.hp_pins[0] = 0x15;
10411 spec->autocfg.speaker_pins[0] = 0x14;
10412 alc_automute_pin(codec);
Kailang Yang4e555fe2008-08-26 13:05:55 +020010413 alc262_dmic_automute(codec);
10414}
10415
Takashi Iwai834be882006-03-01 14:16:17 +010010416/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010417 * nec model
10418 * 0x15 = headphone
10419 * 0x16 = internal speaker
10420 * 0x18 = external mic
10421 */
10422
10423static struct snd_kcontrol_new alc262_nec_mixer[] = {
10424 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
10425 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
10426
10427 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10428 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10429 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10430
10431 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10432 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10433 { } /* end */
10434};
10435
10436static struct hda_verb alc262_nec_verbs[] = {
10437 /* Unmute Speaker */
10438 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10439
10440 /* Headphone */
10441 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10442 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10443
10444 /* External mic to headphone */
10445 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10446 /* External mic to speaker */
10447 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10448 {}
10449};
10450
10451/*
Takashi Iwai834be882006-03-01 14:16:17 +010010452 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010010453 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
10454 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010010455 */
10456
10457#define ALC_HP_EVENT 0x37
10458
10459static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
10460 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10461 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010010462 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10463 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010010464 {}
10465};
10466
Jiang zhe0e31daf2008-03-20 12:12:39 +010010467static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
10468 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10469 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10470 {}
10471};
10472
Takashi Iwai834be882006-03-01 14:16:17 +010010473static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010474 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010010475 .items = {
10476 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010477 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010010478 { "CD", 0x4 },
10479 },
10480};
10481
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010482static struct hda_input_mux alc262_HP_capture_source = {
10483 .num_items = 5,
10484 .items = {
10485 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020010486 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010487 { "Line", 0x2 },
10488 { "CD", 0x4 },
10489 { "AUX IN", 0x6 },
10490 },
10491};
10492
zhejiangaccbe492007-08-31 12:36:05 +020010493static struct hda_input_mux alc262_HP_D7000_capture_source = {
10494 .num_items = 4,
10495 .items = {
10496 { "Mic", 0x0 },
10497 { "Front Mic", 0x2 },
10498 { "Line", 0x1 },
10499 { "CD", 0x4 },
10500 },
10501};
10502
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010503/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010010504static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
10505{
10506 struct alc_spec *spec = codec->spec;
10507 unsigned int mute;
10508
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010509 if (force || !spec->sense_updated) {
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010510 unsigned int present;
Takashi Iwai834be882006-03-01 14:16:17 +010010511 /* need to execute and sync at first */
10512 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010513 /* check laptop HP jack */
10514 present = snd_hda_codec_read(codec, 0x14, 0,
10515 AC_VERB_GET_PIN_SENSE, 0);
10516 /* need to execute and sync at first */
10517 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10518 /* check docking HP jack */
10519 present |= snd_hda_codec_read(codec, 0x1b, 0,
10520 AC_VERB_GET_PIN_SENSE, 0);
10521 if (present & AC_PINSENSE_PRESENCE)
10522 spec->jack_present = 1;
10523 else
10524 spec->jack_present = 0;
Takashi Iwai834be882006-03-01 14:16:17 +010010525 spec->sense_updated = 1;
10526 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010527 /* unmute internal speaker only if both HPs are unplugged and
10528 * master switch is on
10529 */
10530 if (spec->jack_present)
10531 mute = HDA_AMP_MUTE;
10532 else
Takashi Iwai834be882006-03-01 14:16:17 +010010533 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010534 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10535 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010010536}
10537
10538/* unsolicited event for HP jack sensing */
10539static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
10540 unsigned int res)
10541{
10542 if ((res >> 26) != ALC_HP_EVENT)
10543 return;
10544 alc262_fujitsu_automute(codec, 1);
10545}
10546
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010547static void alc262_fujitsu_init_hook(struct hda_codec *codec)
10548{
10549 alc262_fujitsu_automute(codec, 1);
10550}
10551
Takashi Iwai834be882006-03-01 14:16:17 +010010552/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020010553static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
10554 .ops = &snd_hda_bind_vol,
10555 .values = {
10556 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
10557 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
10558 0
10559 },
10560};
Takashi Iwai834be882006-03-01 14:16:17 +010010561
Jiang zhe0e31daf2008-03-20 12:12:39 +010010562/* mute/unmute internal speaker according to the hp jack and mute state */
10563static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
10564{
10565 struct alc_spec *spec = codec->spec;
10566 unsigned int mute;
10567
10568 if (force || !spec->sense_updated) {
10569 unsigned int present_int_hp;
10570 /* need to execute and sync at first */
10571 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10572 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
10573 AC_VERB_GET_PIN_SENSE, 0);
10574 spec->jack_present = (present_int_hp & 0x80000000) != 0;
10575 spec->sense_updated = 1;
10576 }
10577 if (spec->jack_present) {
10578 /* mute internal speaker */
10579 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10580 HDA_AMP_MUTE, HDA_AMP_MUTE);
10581 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10582 HDA_AMP_MUTE, HDA_AMP_MUTE);
10583 } else {
10584 /* unmute internal speaker if necessary */
10585 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
10586 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10587 HDA_AMP_MUTE, mute);
10588 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10589 HDA_AMP_MUTE, mute);
10590 }
10591}
10592
10593/* unsolicited event for HP jack sensing */
10594static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
10595 unsigned int res)
10596{
10597 if ((res >> 26) != ALC_HP_EVENT)
10598 return;
10599 alc262_lenovo_3000_automute(codec, 1);
10600}
10601
Takashi Iwai834be882006-03-01 14:16:17 +010010602/* bind hp and internal speaker mute (with plug check) */
10603static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
10604 struct snd_ctl_elem_value *ucontrol)
10605{
10606 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10607 long *valp = ucontrol->value.integer.value;
10608 int change;
10609
Tony Vroon5d9fab22008-03-14 17:09:18 +010010610 change = snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10611 HDA_AMP_MUTE,
10612 valp ? 0 : HDA_AMP_MUTE);
10613 change |= snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
10614 HDA_AMP_MUTE,
10615 valp ? 0 : HDA_AMP_MUTE);
10616
Takashi Iwai82beb8f2007-08-10 17:09:26 +020010617 if (change)
10618 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010010619 return change;
10620}
10621
10622static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020010623 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010010624 {
10625 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10626 .name = "Master Playback Switch",
10627 .info = snd_hda_mixer_amp_switch_info,
10628 .get = snd_hda_mixer_amp_switch_get,
10629 .put = alc262_fujitsu_master_sw_put,
10630 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10631 },
10632 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10633 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10634 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10635 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10636 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010637 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10638 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10639 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010010640 { } /* end */
10641};
10642
Jiang zhe0e31daf2008-03-20 12:12:39 +010010643/* bind hp and internal speaker mute (with plug check) */
10644static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
10645 struct snd_ctl_elem_value *ucontrol)
10646{
10647 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10648 long *valp = ucontrol->value.integer.value;
10649 int change;
10650
10651 change = snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
10652 HDA_AMP_MUTE,
10653 valp ? 0 : HDA_AMP_MUTE);
10654
10655 if (change)
10656 alc262_lenovo_3000_automute(codec, 0);
10657 return change;
10658}
10659
10660static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
10661 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10662 {
10663 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10664 .name = "Master Playback Switch",
10665 .info = snd_hda_mixer_amp_switch_info,
10666 .get = snd_hda_mixer_amp_switch_get,
10667 .put = alc262_lenovo_3000_master_sw_put,
10668 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
10669 },
10670 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10671 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10672 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10673 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10674 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10675 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10676 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10677 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10678 { } /* end */
10679};
10680
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010681static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
10682 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020010683 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010684 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10685 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10686 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10687 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10688 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10689 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10690 { } /* end */
10691};
10692
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010693/* additional init verbs for Benq laptops */
10694static struct hda_verb alc262_EAPD_verbs[] = {
10695 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10696 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
10697 {}
10698};
10699
Kailang Yang83c34212007-07-05 11:43:05 +020010700static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
10701 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10702 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10703
10704 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10705 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
10706 {}
10707};
10708
Tobin Davisf651b502007-10-26 12:40:47 +020010709/* Samsung Q1 Ultra Vista model setup */
10710static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010711 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10712 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010713 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10714 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10715 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010716 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010717 { } /* end */
10718};
10719
10720static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010721 /* output mixer */
10722 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10723 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10724 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10725 /* speaker */
10726 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10727 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10728 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10729 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10730 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020010731 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010732 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10733 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10734 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10735 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10736 /* internal mic */
10737 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10738 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10739 /* ADC, choose mic */
10740 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10741 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10742 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10743 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10744 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10745 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10746 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10747 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10748 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
10749 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020010750 {}
10751};
10752
Tobin Davisf651b502007-10-26 12:40:47 +020010753/* mute/unmute internal speaker according to the hp jack and mute state */
10754static void alc262_ultra_automute(struct hda_codec *codec)
10755{
10756 struct alc_spec *spec = codec->spec;
10757 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020010758
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010759 mute = 0;
10760 /* auto-mute only when HP is used as HP */
10761 if (!spec->cur_mux[0]) {
10762 unsigned int present;
10763 /* need to execute and sync at first */
10764 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
10765 present = snd_hda_codec_read(codec, 0x15, 0,
10766 AC_VERB_GET_PIN_SENSE, 0);
10767 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
10768 if (spec->jack_present)
10769 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020010770 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010771 /* mute/unmute internal speaker */
10772 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10773 HDA_AMP_MUTE, mute);
10774 /* mute/unmute HP */
10775 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10776 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020010777}
10778
10779/* unsolicited event for HP jack sensing */
10780static void alc262_ultra_unsol_event(struct hda_codec *codec,
10781 unsigned int res)
10782{
10783 if ((res >> 26) != ALC880_HP_EVENT)
10784 return;
10785 alc262_ultra_automute(codec);
10786}
10787
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010788static struct hda_input_mux alc262_ultra_capture_source = {
10789 .num_items = 2,
10790 .items = {
10791 { "Mic", 0x1 },
10792 { "Headphone", 0x7 },
10793 },
10794};
10795
10796static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
10797 struct snd_ctl_elem_value *ucontrol)
10798{
10799 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10800 struct alc_spec *spec = codec->spec;
10801 int ret;
10802
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010803 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010804 if (!ret)
10805 return 0;
10806 /* reprogram the HP pin as mic or HP according to the input source */
10807 snd_hda_codec_write_cache(codec, 0x15, 0,
10808 AC_VERB_SET_PIN_WIDGET_CONTROL,
10809 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
10810 alc262_ultra_automute(codec); /* mute/unmute HP */
10811 return ret;
10812}
10813
10814static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
10815 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10816 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10817 {
10818 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10819 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010820 .info = alc_mux_enum_info,
10821 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010822 .put = alc262_ultra_mux_enum_put,
10823 },
10824 { } /* end */
10825};
10826
Kailang Yangdf694da2005-12-05 19:42:22 +010010827/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010828static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
10829 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010010830{
10831 hda_nid_t nid;
10832 int err;
10833
10834 spec->multiout.num_dacs = 1; /* only use one dac */
10835 spec->multiout.dac_nids = spec->private_dac_nids;
10836 spec->multiout.dac_nids[0] = 2;
10837
10838 nid = cfg->line_out_pins[0];
10839 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010840 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10841 "Front Playback Volume",
10842 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
10843 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010844 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010845 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10846 "Front Playback Switch",
10847 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
10848 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010849 return err;
10850 }
10851
Takashi Iwai82bc9552006-03-21 11:24:42 +010010852 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010853 if (nid) {
10854 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010855 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10856 "Speaker Playback Volume",
10857 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10858 HDA_OUTPUT));
10859 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010860 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010861 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10862 "Speaker Playback Switch",
10863 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10864 HDA_OUTPUT));
10865 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010866 return err;
10867 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010868 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10869 "Speaker Playback Switch",
10870 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10871 HDA_OUTPUT));
10872 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010873 return err;
10874 }
10875 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +020010876 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010877 if (nid) {
10878 /* spec->multiout.hp_nid = 2; */
10879 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010880 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10881 "Headphone Playback Volume",
10882 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10883 HDA_OUTPUT));
10884 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010885 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010886 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10887 "Headphone Playback Switch",
10888 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10889 HDA_OUTPUT));
10890 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010891 return err;
10892 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010893 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10894 "Headphone Playback Switch",
10895 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10896 HDA_OUTPUT));
10897 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010898 return err;
10899 }
10900 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010901 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010010902}
10903
10904/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010905#define alc262_auto_create_analog_input_ctls \
10906 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010010907
10908/*
10909 * generic initialization of ADC, input mixers and output mixers
10910 */
10911static struct hda_verb alc262_volume_init_verbs[] = {
10912 /*
10913 * Unmute ADC0-2 and set the default input to mic-in
10914 */
10915 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10916 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10917 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10918 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10919 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10920 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10921
Takashi Iwaicb53c622007-08-10 17:21:45 +020010922 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010923 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010924 * Note: PASD motherboards uses the Line In 2 as the input for
10925 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010926 */
10927 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010928 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10929 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10930 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10931 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10932 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010933
10934 /*
10935 * Set up output mixers (0x0c - 0x0f)
10936 */
10937 /* set vol=0 to output mixers */
10938 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10939 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10940 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020010941
Kailang Yangdf694da2005-12-05 19:42:22 +010010942 /* set up input amps for analog loopback */
10943 /* Amp Indices: DAC = 0, mixer = 1 */
10944 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10945 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10946 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10947 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10948 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10949 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10950
10951 /* FIXME: use matrix-type input source selection */
10952 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10953 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10954 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10955 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10956 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10957 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10958 /* Input mixer2 */
10959 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10960 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10961 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10962 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10963 /* Input mixer3 */
10964 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10965 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10966 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10967 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10968
10969 { }
10970};
10971
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010972static struct hda_verb alc262_HP_BPC_init_verbs[] = {
10973 /*
10974 * Unmute ADC0-2 and set the default input to mic-in
10975 */
10976 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10977 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10978 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10979 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10980 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10981 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10982
Takashi Iwaicb53c622007-08-10 17:21:45 +020010983 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010984 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010985 * Note: PASD motherboards uses the Line In 2 as the input for
10986 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010987 */
10988 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010989 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10990 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10991 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10992 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10993 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10994 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10995 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020010996
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010997 /*
10998 * Set up output mixers (0x0c - 0x0e)
10999 */
11000 /* set vol=0 to output mixers */
11001 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11002 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11003 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11004
11005 /* set up input amps for analog loopback */
11006 /* Amp Indices: DAC = 0, mixer = 1 */
11007 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11008 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11009 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11010 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11011 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11012 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11013
Takashi Iwaice875f02008-01-28 18:17:43 +010011014 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011015 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11016 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11017
11018 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11019 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11020
11021 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11022 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11023
11024 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11025 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11026 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11027 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11028 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11029
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011030 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011031 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11032 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011033 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011034 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11035 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11036
11037
11038 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011039 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
11040 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011041 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011042 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11043 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11044 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11045 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11046 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11047 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11048 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11049 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011050 /* Input mixer2 */
11051 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011052 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11053 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11054 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11055 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11056 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11057 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11058 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11059 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011060 /* Input mixer3 */
11061 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011062 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11063 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11064 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11065 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11066 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11067 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11068 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11069 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011070
Takashi Iwaice875f02008-01-28 18:17:43 +010011071 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11072
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011073 { }
11074};
11075
Kailang Yangcd7509a2007-01-26 18:33:17 +010011076static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
11077 /*
11078 * Unmute ADC0-2 and set the default input to mic-in
11079 */
11080 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11081 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11082 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11083 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11084 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11085 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11086
Takashi Iwaicb53c622007-08-10 17:21:45 +020011087 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010011088 * mixer widget
11089 * Note: PASD motherboards uses the Line In 2 as the input for front
11090 * panel mic (mic 2)
11091 */
11092 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011093 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11094 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11095 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11096 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11097 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11098 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11099 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11100 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010011101 /*
11102 * Set up output mixers (0x0c - 0x0e)
11103 */
11104 /* set vol=0 to output mixers */
11105 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11106 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11107 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11108
11109 /* set up input amps for analog loopback */
11110 /* Amp Indices: DAC = 0, mixer = 1 */
11111 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11112 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11113 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11114 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11115 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11116 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11117
11118
11119 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
11120 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
11121 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
11122 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
11123 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11124 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
11125 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
11126
11127 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11128 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11129
11130 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11131 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11132
11133 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
11134 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11135 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11136 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
11137 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11138 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11139
11140 /* FIXME: use matrix-type input source selection */
11141 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11142 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11143 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
11144 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
11145 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
11146 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
11147 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
11148 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11149 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
11150 /* Input mixer2 */
11151 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11152 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11153 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11154 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11155 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11156 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11157 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11158 /* Input mixer3 */
11159 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11160 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11161 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11162 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11163 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11164 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11165 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11166
Takashi Iwaice875f02008-01-28 18:17:43 +010011167 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11168
Kailang Yangcd7509a2007-01-26 18:33:17 +010011169 { }
11170};
11171
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011172static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
11173
11174 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
11175 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11176 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
11177
11178 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
11179 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11180 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11181 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11182
11183 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
11184 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11185 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11186 {}
11187};
11188
11189
Takashi Iwaicb53c622007-08-10 17:21:45 +020011190#ifdef CONFIG_SND_HDA_POWER_SAVE
11191#define alc262_loopbacks alc880_loopbacks
11192#endif
11193
Sasha Alexandrdef319f2009-06-16 16:00:15 -040011194/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011195#define alc262_pcm_analog_playback alc880_pcm_analog_playback
11196#define alc262_pcm_analog_capture alc880_pcm_analog_capture
11197#define alc262_pcm_digital_playback alc880_pcm_digital_playback
11198#define alc262_pcm_digital_capture alc880_pcm_digital_capture
11199
11200/*
11201 * BIOS auto configuration
11202 */
11203static int alc262_parse_auto_config(struct hda_codec *codec)
11204{
11205 struct alc_spec *spec = codec->spec;
11206 int err;
11207 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
11208
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011209 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11210 alc262_ignore);
11211 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011212 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011213 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011214 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011215 spec->multiout.max_channels = 2;
11216 spec->no_analog = 1;
11217 goto dig_only;
11218 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011219 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011220 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011221 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
11222 if (err < 0)
11223 return err;
11224 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
11225 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011226 return err;
11227
11228 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11229
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011230 dig_only:
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011231 if (spec->autocfg.dig_outs) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011232 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011233 spec->dig_out_type = spec->autocfg.dig_out_type[0];
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011234 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011235 if (spec->autocfg.dig_in_pin)
11236 spec->dig_in_nid = ALC262_DIGIN_NID;
11237
Takashi Iwai603c4012008-07-30 15:01:44 +020011238 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011239 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010011240
Takashi Iwaid88897e2008-10-31 15:01:37 +010011241 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020011242 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011243 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010011244
Takashi Iwai776e1842007-08-29 15:07:11 +020011245 err = alc_auto_add_mic_boost(codec);
11246 if (err < 0)
11247 return err;
11248
Takashi Iwai4a79ba32009-04-22 16:31:35 +020011249 alc_ssid_check(codec, 0x15, 0x14, 0x1b);
11250
Kailang Yangdf694da2005-12-05 19:42:22 +010011251 return 1;
11252}
11253
11254#define alc262_auto_init_multi_out alc882_auto_init_multi_out
11255#define alc262_auto_init_hp_out alc882_auto_init_hp_out
11256#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020011257#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010011258
11259
11260/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011261static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010011262{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011263 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010011264 alc262_auto_init_multi_out(codec);
11265 alc262_auto_init_hp_out(codec);
11266 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020011267 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011268 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020011269 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010011270}
11271
11272/*
11273 * configuration and preset
11274 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011275static const char *alc262_models[ALC262_MODEL_LAST] = {
11276 [ALC262_BASIC] = "basic",
11277 [ALC262_HIPPO] = "hippo",
11278 [ALC262_HIPPO_1] = "hippo_1",
11279 [ALC262_FUJITSU] = "fujitsu",
11280 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010011281 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010011282 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010011283 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011284 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020011285 [ALC262_BENQ_T31] = "benq-t31",
11286 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020011287 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011288 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020011289 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010011290 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011291 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000011292 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011293 [ALC262_AUTO] = "auto",
11294};
11295
11296static struct snd_pci_quirk alc262_cfg_tbl[] = {
11297 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011298 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011299 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
11300 ALC262_HP_BPC),
11301 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
11302 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010011303 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
11304 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011305 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011306 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011307 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011308 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011309 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011310 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011311 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011312 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011313 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
11314 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
11315 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011316 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
11317 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010011318 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011319 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011320 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011321 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010011322 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020011323 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Takashi Iwaif872a912009-02-26 00:57:01 +010011324 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
11325 ALC262_SONY_ASSAMD),
Akio Idehara36ca6e12008-06-09 22:57:40 +090011326 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011327 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020011328 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011329 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010011330 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000011331 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011332 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
11333 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110011334 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010011335 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011336 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020011337 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011338 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010011339 {}
11340};
11341
11342static struct alc_config_preset alc262_presets[] = {
11343 [ALC262_BASIC] = {
11344 .mixers = { alc262_base_mixer },
11345 .init_verbs = { alc262_init_verbs },
11346 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11347 .dac_nids = alc262_dac_nids,
11348 .hp_nid = 0x03,
11349 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11350 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010011351 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010011352 },
Kailang Yangccc656c2006-10-17 12:32:26 +020011353 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011354 .mixers = { alc262_hippo_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +020011355 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
11356 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11357 .dac_nids = alc262_dac_nids,
11358 .hp_nid = 0x03,
11359 .dig_out_nid = ALC262_DIGOUT_NID,
11360 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11361 .channel_mode = alc262_modes,
11362 .input_mux = &alc262_capture_source,
11363 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011364 .init_hook = alc262_hippo_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +020011365 },
11366 [ALC262_HIPPO_1] = {
11367 .mixers = { alc262_hippo1_mixer },
11368 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
11369 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11370 .dac_nids = alc262_dac_nids,
11371 .hp_nid = 0x02,
11372 .dig_out_nid = ALC262_DIGOUT_NID,
11373 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11374 .channel_mode = alc262_modes,
11375 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020011376 .unsol_event = alc262_hippo_unsol_event,
11377 .init_hook = alc262_hippo1_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +020011378 },
Takashi Iwai834be882006-03-01 14:16:17 +010011379 [ALC262_FUJITSU] = {
11380 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011381 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11382 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010011383 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11384 .dac_nids = alc262_dac_nids,
11385 .hp_nid = 0x03,
11386 .dig_out_nid = ALC262_DIGOUT_NID,
11387 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11388 .channel_mode = alc262_modes,
11389 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011390 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011391 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010011392 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011393 [ALC262_HP_BPC] = {
11394 .mixers = { alc262_HP_BPC_mixer },
11395 .init_verbs = { alc262_HP_BPC_init_verbs },
11396 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11397 .dac_nids = alc262_dac_nids,
11398 .hp_nid = 0x03,
11399 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11400 .channel_mode = alc262_modes,
11401 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011402 .unsol_event = alc262_hp_bpc_unsol_event,
11403 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011404 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011405 [ALC262_HP_BPC_D7000_WF] = {
11406 .mixers = { alc262_HP_BPC_WildWest_mixer },
11407 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11408 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11409 .dac_nids = alc262_dac_nids,
11410 .hp_nid = 0x03,
11411 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11412 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011413 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011414 .unsol_event = alc262_hp_wildwest_unsol_event,
11415 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011416 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011417 [ALC262_HP_BPC_D7000_WL] = {
11418 .mixers = { alc262_HP_BPC_WildWest_mixer,
11419 alc262_HP_BPC_WildWest_option_mixer },
11420 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11421 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11422 .dac_nids = alc262_dac_nids,
11423 .hp_nid = 0x03,
11424 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11425 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011426 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011427 .unsol_event = alc262_hp_wildwest_unsol_event,
11428 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011429 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011430 [ALC262_HP_TC_T5735] = {
11431 .mixers = { alc262_hp_t5735_mixer },
11432 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
11433 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11434 .dac_nids = alc262_dac_nids,
11435 .hp_nid = 0x03,
11436 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11437 .channel_mode = alc262_modes,
11438 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011439 .unsol_event = alc_automute_amp_unsol_event,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011440 .init_hook = alc262_hp_t5735_init_hook,
Kailang Yang8c427222008-01-10 13:03:59 +010011441 },
11442 [ALC262_HP_RP5700] = {
11443 .mixers = { alc262_hp_rp5700_mixer },
11444 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
11445 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11446 .dac_nids = alc262_dac_nids,
11447 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11448 .channel_mode = alc262_modes,
11449 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011450 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011451 [ALC262_BENQ_ED8] = {
11452 .mixers = { alc262_base_mixer },
11453 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
11454 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11455 .dac_nids = alc262_dac_nids,
11456 .hp_nid = 0x03,
11457 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11458 .channel_mode = alc262_modes,
11459 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011460 },
Kailang Yang272a5272007-05-14 11:00:38 +020011461 [ALC262_SONY_ASSAMD] = {
11462 .mixers = { alc262_sony_mixer },
11463 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
11464 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11465 .dac_nids = alc262_dac_nids,
11466 .hp_nid = 0x02,
11467 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11468 .channel_mode = alc262_modes,
11469 .input_mux = &alc262_capture_source,
11470 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011471 .init_hook = alc262_hippo_init_hook,
Kailang Yang83c34212007-07-05 11:43:05 +020011472 },
11473 [ALC262_BENQ_T31] = {
11474 .mixers = { alc262_benq_t31_mixer },
11475 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
11476 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11477 .dac_nids = alc262_dac_nids,
11478 .hp_nid = 0x03,
11479 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11480 .channel_mode = alc262_modes,
11481 .input_mux = &alc262_capture_source,
11482 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011483 .init_hook = alc262_hippo_init_hook,
Kailang Yangea1fb292008-08-26 12:58:38 +020011484 },
Tobin Davisf651b502007-10-26 12:40:47 +020011485 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011486 .mixers = { alc262_ultra_mixer },
11487 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011488 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020011489 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11490 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020011491 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11492 .channel_mode = alc262_modes,
11493 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011494 .adc_nids = alc262_adc_nids, /* ADC0 */
11495 .capsrc_nids = alc262_capsrc_nids,
11496 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020011497 .unsol_event = alc262_ultra_unsol_event,
11498 .init_hook = alc262_ultra_automute,
11499 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010011500 [ALC262_LENOVO_3000] = {
11501 .mixers = { alc262_lenovo_3000_mixer },
11502 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11503 alc262_lenovo_3000_unsol_verbs },
11504 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11505 .dac_nids = alc262_dac_nids,
11506 .hp_nid = 0x03,
11507 .dig_out_nid = ALC262_DIGOUT_NID,
11508 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11509 .channel_mode = alc262_modes,
11510 .input_mux = &alc262_fujitsu_capture_source,
11511 .unsol_event = alc262_lenovo_3000_unsol_event,
11512 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011513 [ALC262_NEC] = {
11514 .mixers = { alc262_nec_mixer },
11515 .init_verbs = { alc262_nec_verbs },
11516 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11517 .dac_nids = alc262_dac_nids,
11518 .hp_nid = 0x03,
11519 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11520 .channel_mode = alc262_modes,
11521 .input_mux = &alc262_capture_source,
11522 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020011523 [ALC262_TOSHIBA_S06] = {
11524 .mixers = { alc262_toshiba_s06_mixer },
11525 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
11526 alc262_eapd_verbs },
11527 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11528 .capsrc_nids = alc262_dmic_capsrc_nids,
11529 .dac_nids = alc262_dac_nids,
11530 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020011531 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020011532 .dig_out_nid = ALC262_DIGOUT_NID,
11533 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11534 .channel_mode = alc262_modes,
11535 .input_mux = &alc262_dmic_capture_source,
11536 .unsol_event = alc262_toshiba_s06_unsol_event,
11537 .init_hook = alc262_toshiba_s06_init_hook,
11538 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011539 [ALC262_TOSHIBA_RX1] = {
11540 .mixers = { alc262_toshiba_rx1_mixer },
11541 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
11542 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11543 .dac_nids = alc262_dac_nids,
11544 .hp_nid = 0x03,
11545 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11546 .channel_mode = alc262_modes,
11547 .input_mux = &alc262_capture_source,
11548 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011549 .init_hook = alc262_hippo_init_hook,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011550 },
Tony Vroonba340e82009-02-02 19:01:30 +000011551 [ALC262_TYAN] = {
11552 .mixers = { alc262_tyan_mixer },
11553 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
11554 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11555 .dac_nids = alc262_dac_nids,
11556 .hp_nid = 0x02,
11557 .dig_out_nid = ALC262_DIGOUT_NID,
11558 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11559 .channel_mode = alc262_modes,
11560 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011561 .unsol_event = alc_automute_amp_unsol_event,
11562 .init_hook = alc262_tyan_init_hook,
Tony Vroonba340e82009-02-02 19:01:30 +000011563 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011564};
11565
11566static int patch_alc262(struct hda_codec *codec)
11567{
11568 struct alc_spec *spec;
11569 int board_config;
11570 int err;
11571
Robert P. J. Daydc041e02006-12-19 14:44:15 +010011572 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010011573 if (spec == NULL)
11574 return -ENOMEM;
11575
11576 codec->spec = spec;
11577#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011578 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
11579 * under-run
11580 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011581 {
11582 int tmp;
11583 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11584 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
11585 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11586 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
11587 }
11588#endif
11589
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020011590 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
11591
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011592 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
11593 alc262_models,
11594 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010011595
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011596 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020011597 printk(KERN_INFO "hda_codec: Unknown model for %s, "
11598 "trying auto-probe from BIOS...\n", codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010011599 board_config = ALC262_AUTO;
11600 }
11601
11602 if (board_config == ALC262_AUTO) {
11603 /* automatic parse from the BIOS config */
11604 err = alc262_parse_auto_config(codec);
11605 if (err < 0) {
11606 alc_free(codec);
11607 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011608 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011609 printk(KERN_INFO
11610 "hda_codec: Cannot set up configuration "
11611 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011612 board_config = ALC262_BASIC;
11613 }
11614 }
11615
Takashi Iwai07eba612009-02-19 08:06:35 +010011616 if (!spec->no_analog) {
11617 err = snd_hda_attach_beep_device(codec, 0x1);
11618 if (err < 0) {
11619 alc_free(codec);
11620 return err;
11621 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090011622 }
11623
Kailang Yangdf694da2005-12-05 19:42:22 +010011624 if (board_config != ALC262_AUTO)
11625 setup_preset(spec, &alc262_presets[board_config]);
11626
Kailang Yangdf694da2005-12-05 19:42:22 +010011627 spec->stream_analog_playback = &alc262_pcm_analog_playback;
11628 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020011629
Kailang Yangdf694da2005-12-05 19:42:22 +010011630 spec->stream_digital_playback = &alc262_pcm_digital_playback;
11631 spec->stream_digital_capture = &alc262_pcm_digital_capture;
11632
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011633 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011634 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +010011635 unsigned int wcap = get_wcaps(codec, 0x07);
11636
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011637 /* get type */
11638 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +010011639 if (wcap != AC_WID_AUD_IN) {
11640 spec->adc_nids = alc262_adc_nids_alt;
11641 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwai88c71a92008-02-14 17:27:17 +010011642 spec->capsrc_nids = alc262_capsrc_nids_alt;
Kailang Yangdf694da2005-12-05 19:42:22 +010011643 } else {
11644 spec->adc_nids = alc262_adc_nids;
11645 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
Takashi Iwai88c71a92008-02-14 17:27:17 +010011646 spec->capsrc_nids = alc262_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010011647 }
11648 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011649 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011650 set_capture_mixer(spec);
Takashi Iwai07eba612009-02-19 08:06:35 +010011651 if (!spec->no_analog)
11652 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010011653
Takashi Iwai2134ea42008-01-10 16:53:55 +010011654 spec->vmaster_nid = 0x0c;
11655
Kailang Yangdf694da2005-12-05 19:42:22 +010011656 codec->patch_ops = alc_patch_ops;
11657 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011658 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011659#ifdef CONFIG_SND_HDA_POWER_SAVE
11660 if (!spec->loopback.amplist)
11661 spec->loopback.amplist = alc262_loopbacks;
11662#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010011663 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020011664
Kailang Yangdf694da2005-12-05 19:42:22 +010011665 return 0;
11666}
11667
Kailang Yangdf694da2005-12-05 19:42:22 +010011668/*
Kailang Yanga361d842007-06-05 12:30:55 +020011669 * ALC268 channel source setting (2 channel)
11670 */
11671#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
11672#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020011673
Kailang Yanga361d842007-06-05 12:30:55 +020011674static hda_nid_t alc268_dac_nids[2] = {
11675 /* front, hp */
11676 0x02, 0x03
11677};
11678
11679static hda_nid_t alc268_adc_nids[2] = {
11680 /* ADC0-1 */
11681 0x08, 0x07
11682};
11683
11684static hda_nid_t alc268_adc_nids_alt[1] = {
11685 /* ADC0 */
11686 0x08
11687};
11688
Takashi Iwaie1406342008-02-11 18:32:32 +010011689static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
11690
Kailang Yanga361d842007-06-05 12:30:55 +020011691static struct snd_kcontrol_new alc268_base_mixer[] = {
11692 /* output mixer control */
11693 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11694 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11695 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11696 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011697 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11698 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11699 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020011700 { }
11701};
11702
Takashi Iwai42171c12009-05-08 14:11:43 +020011703static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
11704 /* output mixer control */
11705 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11706 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11707 ALC262_HIPPO_MASTER_SWITCH,
11708 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11709 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11710 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11711 { }
11712};
11713
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011714/* bind Beep switches of both NID 0x0f and 0x10 */
11715static struct hda_bind_ctls alc268_bind_beep_sw = {
11716 .ops = &snd_hda_bind_sw,
11717 .values = {
11718 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
11719 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
11720 0
11721 },
11722};
11723
11724static struct snd_kcontrol_new alc268_beep_mixer[] = {
11725 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
11726 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
11727 { }
11728};
11729
Kailang Yangd1a991a2007-08-15 16:21:59 +020011730static struct hda_verb alc268_eapd_verbs[] = {
11731 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11732 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11733 { }
11734};
11735
Takashi Iwaid2738092007-08-16 14:59:45 +020011736/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020011737static struct hda_verb alc268_toshiba_verbs[] = {
11738 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11739 { } /* end */
11740};
11741
Kailang Yang8ef355d2008-08-26 13:10:22 +020011742static struct hda_input_mux alc268_acer_lc_capture_source = {
11743 .num_items = 2,
11744 .items = {
11745 { "i-Mic", 0x6 },
11746 { "E-Mic", 0x0 },
11747 },
11748};
11749
Takashi Iwaid2738092007-08-16 14:59:45 +020011750/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020011751/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020011752static struct hda_bind_ctls alc268_acer_bind_master_vol = {
11753 .ops = &snd_hda_bind_vol,
11754 .values = {
11755 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
11756 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
11757 0
11758 },
11759};
11760
Takashi Iwai889c4392007-08-23 18:56:52 +020011761/* mute/unmute internal speaker according to the hp jack and mute state */
11762static void alc268_acer_automute(struct hda_codec *codec, int force)
11763{
11764 struct alc_spec *spec = codec->spec;
11765 unsigned int mute;
11766
11767 if (force || !spec->sense_updated) {
11768 unsigned int present;
11769 present = snd_hda_codec_read(codec, 0x14, 0,
11770 AC_VERB_GET_PIN_SENSE, 0);
11771 spec->jack_present = (present & 0x80000000) != 0;
11772 spec->sense_updated = 1;
11773 }
11774 if (spec->jack_present)
11775 mute = HDA_AMP_MUTE; /* mute internal speaker */
11776 else /* unmute internal speaker if necessary */
11777 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
11778 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11779 HDA_AMP_MUTE, mute);
11780}
11781
11782
11783/* bind hp and internal speaker mute (with plug check) */
11784static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
11785 struct snd_ctl_elem_value *ucontrol)
11786{
11787 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11788 long *valp = ucontrol->value.integer.value;
11789 int change;
11790
11791 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
11792 HDA_AMP_MUTE,
11793 valp[0] ? 0 : HDA_AMP_MUTE);
11794 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
11795 HDA_AMP_MUTE,
11796 valp[1] ? 0 : HDA_AMP_MUTE);
11797 if (change)
11798 alc268_acer_automute(codec, 0);
11799 return change;
11800}
Takashi Iwaid2738092007-08-16 14:59:45 +020011801
Kailang Yang8ef355d2008-08-26 13:10:22 +020011802static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
11803 /* output mixer control */
11804 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11805 {
11806 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11807 .name = "Master Playback Switch",
11808 .info = snd_hda_mixer_amp_switch_info,
11809 .get = snd_hda_mixer_amp_switch_get,
11810 .put = alc268_acer_master_sw_put,
11811 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11812 },
11813 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
11814 { }
11815};
11816
Takashi Iwaid2738092007-08-16 14:59:45 +020011817static struct snd_kcontrol_new alc268_acer_mixer[] = {
11818 /* output mixer control */
11819 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11820 {
11821 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11822 .name = "Master Playback Switch",
11823 .info = snd_hda_mixer_amp_switch_info,
11824 .get = snd_hda_mixer_amp_switch_get,
11825 .put = alc268_acer_master_sw_put,
11826 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11827 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011828 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11829 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11830 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020011831 { }
11832};
11833
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011834static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
11835 /* output mixer control */
11836 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11837 {
11838 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11839 .name = "Master Playback Switch",
11840 .info = snd_hda_mixer_amp_switch_info,
11841 .get = snd_hda_mixer_amp_switch_get,
11842 .put = alc268_acer_master_sw_put,
11843 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11844 },
11845 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11846 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11847 { }
11848};
11849
Kailang Yang8ef355d2008-08-26 13:10:22 +020011850static struct hda_verb alc268_acer_aspire_one_verbs[] = {
11851 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11852 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11853 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11854 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11855 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
11856 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
11857 { }
11858};
11859
Takashi Iwaid2738092007-08-16 14:59:45 +020011860static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011861 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
11862 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020011863 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11864 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011865 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11866 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020011867 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11868 { }
11869};
11870
11871/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020011872#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
11873#define alc268_toshiba_init_hook alc262_hippo_init_hook
Takashi Iwaid2738092007-08-16 14:59:45 +020011874
11875static void alc268_acer_unsol_event(struct hda_codec *codec,
11876 unsigned int res)
11877{
Takashi Iwai889c4392007-08-23 18:56:52 +020011878 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020011879 return;
11880 alc268_acer_automute(codec, 1);
11881}
11882
Takashi Iwai889c4392007-08-23 18:56:52 +020011883static void alc268_acer_init_hook(struct hda_codec *codec)
11884{
11885 alc268_acer_automute(codec, 1);
11886}
11887
Kailang Yang8ef355d2008-08-26 13:10:22 +020011888/* toggle speaker-output according to the hp-jack state */
11889static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
11890{
11891 unsigned int present;
11892 unsigned char bits;
11893
11894 present = snd_hda_codec_read(codec, 0x15, 0,
11895 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11896 bits = present ? AMP_IN_MUTE(0) : 0;
11897 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
11898 AMP_IN_MUTE(0), bits);
11899 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
11900 AMP_IN_MUTE(0), bits);
11901}
11902
11903
11904static void alc268_acer_mic_automute(struct hda_codec *codec)
11905{
11906 unsigned int present;
11907
11908 present = snd_hda_codec_read(codec, 0x18, 0,
11909 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11910 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_CONNECT_SEL,
11911 present ? 0x0 : 0x6);
11912}
11913
11914static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
11915 unsigned int res)
11916{
11917 if ((res >> 26) == ALC880_HP_EVENT)
11918 alc268_aspire_one_speaker_automute(codec);
11919 if ((res >> 26) == ALC880_MIC_EVENT)
11920 alc268_acer_mic_automute(codec);
11921}
11922
11923static void alc268_acer_lc_init_hook(struct hda_codec *codec)
11924{
11925 alc268_aspire_one_speaker_automute(codec);
11926 alc268_acer_mic_automute(codec);
11927}
11928
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011929static struct snd_kcontrol_new alc268_dell_mixer[] = {
11930 /* output mixer control */
11931 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11932 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11933 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11934 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11935 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11936 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11937 { }
11938};
11939
11940static struct hda_verb alc268_dell_verbs[] = {
11941 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11942 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11943 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11944 { }
11945};
11946
11947/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011948static void alc268_dell_init_hook(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011949{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011950 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011951
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011952 spec->autocfg.hp_pins[0] = 0x15;
11953 spec->autocfg.speaker_pins[0] = 0x14;
11954 alc_automute_pin(codec);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011955}
11956
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011957static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
11958 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11959 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11960 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11961 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11962 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11963 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
11964 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
11965 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11966 { }
11967};
11968
11969static struct hda_verb alc267_quanta_il1_verbs[] = {
11970 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11971 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
11972 { }
11973};
11974
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011975static void alc267_quanta_il1_mic_automute(struct hda_codec *codec)
11976{
11977 unsigned int present;
11978
11979 present = snd_hda_codec_read(codec, 0x18, 0,
11980 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11981 snd_hda_codec_write(codec, 0x23, 0,
11982 AC_VERB_SET_CONNECT_SEL,
11983 present ? 0x00 : 0x01);
11984}
11985
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011986static void alc267_quanta_il1_init_hook(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011987{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011988 struct alc_spec *spec = codec->spec;
11989
11990 spec->autocfg.hp_pins[0] = 0x15;
11991 spec->autocfg.speaker_pins[0] = 0x14;
11992 alc_automute_pin(codec);
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011993 alc267_quanta_il1_mic_automute(codec);
11994}
11995
11996static void alc267_quanta_il1_unsol_event(struct hda_codec *codec,
11997 unsigned int res)
11998{
11999 switch (res >> 26) {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012000 case ALC880_MIC_EVENT:
12001 alc267_quanta_il1_mic_automute(codec);
12002 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012003 default:
12004 alc_sku_unsol_event(codec, res);
12005 break;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012006 }
12007}
12008
Kailang Yanga361d842007-06-05 12:30:55 +020012009/*
12010 * generic initialization of ADC, input mixers and output mixers
12011 */
12012static struct hda_verb alc268_base_init_verbs[] = {
12013 /* Unmute DAC0-1 and set vol = 0 */
12014 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012015 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012016
12017 /*
12018 * Set up output mixers (0x0c - 0x0e)
12019 */
12020 /* set vol=0 to output mixers */
12021 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012022 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
12023
12024 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12025 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12026
12027 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12028 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
12029 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12030 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12031 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12032 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12033 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12034 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12035
12036 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12037 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12038 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12039 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012040 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012041
12042 /* set PCBEEP vol = 0, mute connections */
12043 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12044 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12045 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012046
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012047 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020012048
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012049 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
12050 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12051 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
12052 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012053
Kailang Yanga361d842007-06-05 12:30:55 +020012054 { }
12055};
12056
12057/*
12058 * generic initialization of ADC, input mixers and output mixers
12059 */
12060static struct hda_verb alc268_volume_init_verbs[] = {
12061 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010012062 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12063 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012064
12065 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12066 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12067 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12068 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12069 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12070
Kailang Yanga361d842007-06-05 12:30:55 +020012071 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012072 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12073 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12074
12075 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012076 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012077
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012078 /* set PCBEEP vol = 0, mute connections */
12079 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12080 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12081 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012082
12083 { }
12084};
12085
Kailang Yanga361d842007-06-05 12:30:55 +020012086static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
12087 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12088 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12089 {
12090 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12091 /* The multiple "Capture Source" controls confuse alsamixer
12092 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020012093 */
12094 /* .name = "Capture Source", */
12095 .name = "Input Source",
12096 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010012097 .info = alc_mux_enum_info,
12098 .get = alc_mux_enum_get,
12099 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020012100 },
12101 { } /* end */
12102};
12103
12104static struct snd_kcontrol_new alc268_capture_mixer[] = {
12105 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12106 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12107 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
12108 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
12109 {
12110 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12111 /* The multiple "Capture Source" controls confuse alsamixer
12112 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020012113 */
12114 /* .name = "Capture Source", */
12115 .name = "Input Source",
12116 .count = 2,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010012117 .info = alc_mux_enum_info,
12118 .get = alc_mux_enum_get,
12119 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020012120 },
12121 { } /* end */
12122};
12123
12124static struct hda_input_mux alc268_capture_source = {
12125 .num_items = 4,
12126 .items = {
12127 { "Mic", 0x0 },
12128 { "Front Mic", 0x1 },
12129 { "Line", 0x2 },
12130 { "CD", 0x3 },
12131 },
12132};
12133
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012134static struct hda_input_mux alc268_acer_capture_source = {
12135 .num_items = 3,
12136 .items = {
12137 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012138 { "Internal Mic", 0x1 },
12139 { "Line", 0x2 },
12140 },
12141};
12142
12143static struct hda_input_mux alc268_acer_dmic_capture_source = {
12144 .num_items = 3,
12145 .items = {
12146 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012147 { "Internal Mic", 0x6 },
12148 { "Line", 0x2 },
12149 },
12150};
12151
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012152#ifdef CONFIG_SND_DEBUG
12153static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012154 /* Volume widgets */
12155 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12156 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12157 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
12158 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
12159 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
12160 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
12161 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
12162 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
12163 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
12164 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
12165 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
12166 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
12167 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010012168 /* The below appears problematic on some hardwares */
12169 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012170 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12171 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
12172 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
12173 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
12174
12175 /* Modes for retasking pin widgets */
12176 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
12177 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
12178 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
12179 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
12180
12181 /* Controls for GPIO pins, assuming they are configured as outputs */
12182 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
12183 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
12184 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
12185 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
12186
12187 /* Switches to allow the digital SPDIF output pin to be enabled.
12188 * The ALC268 does not have an SPDIF input.
12189 */
12190 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
12191
12192 /* A switch allowing EAPD to be enabled. Some laptops seem to use
12193 * this output to turn on an external amplifier.
12194 */
12195 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
12196 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
12197
12198 { } /* end */
12199};
12200#endif
12201
Kailang Yanga361d842007-06-05 12:30:55 +020012202/* create input playback/capture controls for the given pin */
12203static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
12204 const char *ctlname, int idx)
12205{
12206 char name[32];
12207 int err;
12208
12209 sprintf(name, "%s Playback Volume", ctlname);
12210 if (nid == 0x14) {
12211 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
12212 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
12213 HDA_OUTPUT));
12214 if (err < 0)
12215 return err;
12216 } else if (nid == 0x15) {
12217 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
12218 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
12219 HDA_OUTPUT));
12220 if (err < 0)
12221 return err;
12222 } else
12223 return -1;
12224 sprintf(name, "%s Playback Switch", ctlname);
12225 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
12226 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
12227 if (err < 0)
12228 return err;
12229 return 0;
12230}
12231
12232/* add playback controls from the parsed DAC table */
12233static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
12234 const struct auto_pin_cfg *cfg)
12235{
12236 hda_nid_t nid;
12237 int err;
12238
12239 spec->multiout.num_dacs = 2; /* only use one dac */
12240 spec->multiout.dac_nids = spec->private_dac_nids;
12241 spec->multiout.dac_nids[0] = 2;
12242 spec->multiout.dac_nids[1] = 3;
12243
12244 nid = cfg->line_out_pins[0];
12245 if (nid)
Kailang Yangea1fb292008-08-26 12:58:38 +020012246 alc268_new_analog_output(spec, nid, "Front", 0);
Kailang Yanga361d842007-06-05 12:30:55 +020012247
12248 nid = cfg->speaker_pins[0];
12249 if (nid == 0x1d) {
12250 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12251 "Speaker Playback Volume",
12252 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
12253 if (err < 0)
12254 return err;
12255 }
12256 nid = cfg->hp_pins[0];
12257 if (nid)
12258 alc268_new_analog_output(spec, nid, "Headphone", 0);
12259
12260 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
12261 if (nid == 0x16) {
12262 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12263 "Mono Playback Switch",
12264 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
12265 if (err < 0)
12266 return err;
12267 }
Kailang Yangea1fb292008-08-26 12:58:38 +020012268 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020012269}
12270
12271/* create playback/capture controls for input pins */
12272static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
12273 const struct auto_pin_cfg *cfg)
12274{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012275 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020012276 int i, idx1;
12277
12278 for (i = 0; i < AUTO_PIN_LAST; i++) {
12279 switch(cfg->input_pins[i]) {
12280 case 0x18:
12281 idx1 = 0; /* Mic 1 */
12282 break;
12283 case 0x19:
12284 idx1 = 1; /* Mic 2 */
12285 break;
12286 case 0x1a:
12287 idx1 = 2; /* Line In */
12288 break;
Kailang Yangea1fb292008-08-26 12:58:38 +020012289 case 0x1c:
Kailang Yanga361d842007-06-05 12:30:55 +020012290 idx1 = 3; /* CD */
12291 break;
Takashi Iwai7194cae2008-03-06 16:58:17 +010012292 case 0x12:
12293 case 0x13:
12294 idx1 = 6; /* digital mics */
12295 break;
Kailang Yanga361d842007-06-05 12:30:55 +020012296 default:
12297 continue;
12298 }
12299 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
12300 imux->items[imux->num_items].index = idx1;
Kailang Yangea1fb292008-08-26 12:58:38 +020012301 imux->num_items++;
Kailang Yanga361d842007-06-05 12:30:55 +020012302 }
12303 return 0;
12304}
12305
12306static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
12307{
12308 struct alc_spec *spec = codec->spec;
12309 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
12310 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
12311 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
12312 unsigned int dac_vol1, dac_vol2;
12313
12314 if (speaker_nid) {
12315 snd_hda_codec_write(codec, speaker_nid, 0,
12316 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
12317 snd_hda_codec_write(codec, 0x0f, 0,
12318 AC_VERB_SET_AMP_GAIN_MUTE,
12319 AMP_IN_UNMUTE(1));
12320 snd_hda_codec_write(codec, 0x10, 0,
12321 AC_VERB_SET_AMP_GAIN_MUTE,
12322 AMP_IN_UNMUTE(1));
12323 } else {
12324 snd_hda_codec_write(codec, 0x0f, 0,
12325 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12326 snd_hda_codec_write(codec, 0x10, 0,
12327 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12328 }
12329
12330 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020012331 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012332 dac_vol2 = AMP_OUT_ZERO;
12333 else if (line_nid == 0x15)
12334 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020012335 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012336 dac_vol2 = AMP_OUT_ZERO;
12337 else if (hp_nid == 0x15)
12338 dac_vol1 = AMP_OUT_ZERO;
12339 if (line_nid != 0x16 || hp_nid != 0x16 ||
12340 spec->autocfg.line_out_pins[1] != 0x16 ||
12341 spec->autocfg.line_out_pins[2] != 0x16)
12342 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
12343
12344 snd_hda_codec_write(codec, 0x02, 0,
12345 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
12346 snd_hda_codec_write(codec, 0x03, 0,
12347 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
12348}
12349
Sasha Alexandrdef319f2009-06-16 16:00:15 -040012350/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020012351#define alc268_pcm_analog_playback alc880_pcm_analog_playback
12352#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010012353#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020012354#define alc268_pcm_digital_playback alc880_pcm_digital_playback
12355
12356/*
12357 * BIOS auto configuration
12358 */
12359static int alc268_parse_auto_config(struct hda_codec *codec)
12360{
12361 struct alc_spec *spec = codec->spec;
12362 int err;
12363 static hda_nid_t alc268_ignore[] = { 0 };
12364
12365 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12366 alc268_ignore);
12367 if (err < 0)
12368 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012369 if (!spec->autocfg.line_outs) {
12370 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
12371 spec->multiout.max_channels = 2;
12372 spec->no_analog = 1;
12373 goto dig_only;
12374 }
Kailang Yanga361d842007-06-05 12:30:55 +020012375 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012376 }
Kailang Yanga361d842007-06-05 12:30:55 +020012377 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
12378 if (err < 0)
12379 return err;
12380 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
12381 if (err < 0)
12382 return err;
12383
12384 spec->multiout.max_channels = 2;
12385
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012386 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020012387 /* digital only support output */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012388 if (spec->autocfg.dig_outs) {
Kailang Yanga361d842007-06-05 12:30:55 +020012389 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012390 spec->dig_out_type = spec->autocfg.dig_out_type[0];
12391 }
Takashi Iwai603c4012008-07-30 15:01:44 +020012392 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012393 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020012394
Takashi Iwai892981f2009-03-02 08:04:35 +010012395 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012396 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012397
Takashi Iwaid88897e2008-10-31 15:01:37 +010012398 add_verb(spec, alc268_volume_init_verbs);
Kailang Yanga361d842007-06-05 12:30:55 +020012399 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012400 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020012401
Takashi Iwai776e1842007-08-29 15:07:11 +020012402 err = alc_auto_add_mic_boost(codec);
12403 if (err < 0)
12404 return err;
12405
Kailang Yanga361d842007-06-05 12:30:55 +020012406 return 1;
12407}
12408
12409#define alc268_auto_init_multi_out alc882_auto_init_multi_out
12410#define alc268_auto_init_hp_out alc882_auto_init_hp_out
12411#define alc268_auto_init_analog_input alc882_auto_init_analog_input
12412
12413/* init callback for auto-configuration model -- overriding the default init */
12414static void alc268_auto_init(struct hda_codec *codec)
12415{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012416 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020012417 alc268_auto_init_multi_out(codec);
12418 alc268_auto_init_hp_out(codec);
12419 alc268_auto_init_mono_speaker_out(codec);
12420 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012421 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012422 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020012423}
12424
12425/*
12426 * configuration and preset
12427 */
12428static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012429 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020012430 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012431 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020012432 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012433 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020012434 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012435 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012436 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012437#ifdef CONFIG_SND_DEBUG
12438 [ALC268_TEST] = "test",
12439#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012440 [ALC268_AUTO] = "auto",
12441};
12442
12443static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020012444 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012445 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010012446 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012447 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010012448 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020012449 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
12450 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012451 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Takashi Iwai57d13922009-01-08 15:52:09 +010012452 SND_PCI_QUIRK(0x1028, 0x02b0, "Dell Inspiron Mini9", ALC268_DELL),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012453 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
12454 ALC268_TOSHIBA),
Kailang Yanga361d842007-06-05 12:30:55 +020012455 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012456 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
12457 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
12458 ALC268_TOSHIBA),
Tony Vroon378bd6a2008-06-04 12:08:30 +020012459 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020012460 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012461 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012462 SND_PCI_QUIRK(0x1854, 0x1775, "LG R510", ALC268_DELL),
Kailang Yanga361d842007-06-05 12:30:55 +020012463 {}
12464};
12465
12466static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012467 [ALC267_QUANTA_IL1] = {
Takashi Iwai22971e32009-02-10 11:56:44 +010012468 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012469 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12470 alc267_quanta_il1_verbs },
12471 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12472 .dac_nids = alc268_dac_nids,
12473 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12474 .adc_nids = alc268_adc_nids_alt,
12475 .hp_nid = 0x03,
12476 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12477 .channel_mode = alc268_modes,
12478 .input_mux = &alc268_capture_source,
12479 .unsol_event = alc267_quanta_il1_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012480 .init_hook = alc267_quanta_il1_init_hook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012481 },
Kailang Yanga361d842007-06-05 12:30:55 +020012482 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012483 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12484 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020012485 .init_verbs = { alc268_base_init_verbs },
12486 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12487 .dac_nids = alc268_dac_nids,
12488 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12489 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012490 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020012491 .hp_nid = 0x03,
12492 .dig_out_nid = ALC268_DIGOUT_NID,
12493 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12494 .channel_mode = alc268_modes,
12495 .input_mux = &alc268_capture_source,
12496 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012497 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012498 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012499 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012500 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12501 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012502 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12503 .dac_nids = alc268_dac_nids,
12504 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12505 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012506 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012507 .hp_nid = 0x03,
12508 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12509 .channel_mode = alc268_modes,
12510 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012511 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020012512 .init_hook = alc268_toshiba_init_hook,
Takashi Iwaid2738092007-08-16 14:59:45 +020012513 },
12514 [ALC268_ACER] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012515 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
12516 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012517 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12518 alc268_acer_verbs },
12519 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12520 .dac_nids = alc268_dac_nids,
12521 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12522 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012523 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020012524 .hp_nid = 0x02,
12525 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12526 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012527 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012528 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020012529 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012530 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012531 [ALC268_ACER_DMIC] = {
12532 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
12533 alc268_beep_mixer },
12534 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12535 alc268_acer_verbs },
12536 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12537 .dac_nids = alc268_dac_nids,
12538 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12539 .adc_nids = alc268_adc_nids_alt,
12540 .capsrc_nids = alc268_capsrc_nids,
12541 .hp_nid = 0x02,
12542 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12543 .channel_mode = alc268_modes,
12544 .input_mux = &alc268_acer_dmic_capture_source,
12545 .unsol_event = alc268_acer_unsol_event,
12546 .init_hook = alc268_acer_init_hook,
12547 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012548 [ALC268_ACER_ASPIRE_ONE] = {
12549 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010012550 alc268_beep_mixer,
12551 alc268_capture_alt_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012552 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12553 alc268_acer_aspire_one_verbs },
12554 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12555 .dac_nids = alc268_dac_nids,
12556 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12557 .adc_nids = alc268_adc_nids_alt,
12558 .capsrc_nids = alc268_capsrc_nids,
12559 .hp_nid = 0x03,
12560 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12561 .channel_mode = alc268_modes,
12562 .input_mux = &alc268_acer_lc_capture_source,
12563 .unsol_event = alc268_acer_lc_unsol_event,
12564 .init_hook = alc268_acer_lc_init_hook,
12565 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012566 [ALC268_DELL] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012567 .mixers = { alc268_dell_mixer, alc268_beep_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012568 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12569 alc268_dell_verbs },
12570 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12571 .dac_nids = alc268_dac_nids,
12572 .hp_nid = 0x02,
12573 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12574 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012575 .unsol_event = alc_sku_unsol_event,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012576 .init_hook = alc268_dell_init_hook,
12577 .input_mux = &alc268_capture_source,
12578 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012579 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012580 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12581 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012582 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12583 alc268_toshiba_verbs },
12584 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12585 .dac_nids = alc268_dac_nids,
12586 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12587 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012588 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012589 .hp_nid = 0x03,
12590 .dig_out_nid = ALC268_DIGOUT_NID,
12591 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12592 .channel_mode = alc268_modes,
12593 .input_mux = &alc268_capture_source,
12594 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020012595 .init_hook = alc268_toshiba_init_hook
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012596 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012597#ifdef CONFIG_SND_DEBUG
12598 [ALC268_TEST] = {
12599 .mixers = { alc268_test_mixer, alc268_capture_mixer },
12600 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12601 alc268_volume_init_verbs },
12602 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12603 .dac_nids = alc268_dac_nids,
12604 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12605 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012606 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012607 .hp_nid = 0x03,
12608 .dig_out_nid = ALC268_DIGOUT_NID,
12609 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12610 .channel_mode = alc268_modes,
12611 .input_mux = &alc268_capture_source,
12612 },
12613#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012614};
12615
12616static int patch_alc268(struct hda_codec *codec)
12617{
12618 struct alc_spec *spec;
12619 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010012620 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020012621
12622 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
12623 if (spec == NULL)
12624 return -ENOMEM;
12625
12626 codec->spec = spec;
12627
12628 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
12629 alc268_models,
12630 alc268_cfg_tbl);
12631
12632 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020012633 printk(KERN_INFO "hda_codec: Unknown model for %s, "
12634 "trying auto-probe from BIOS...\n", codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020012635 board_config = ALC268_AUTO;
12636 }
12637
12638 if (board_config == ALC268_AUTO) {
12639 /* automatic parse from the BIOS config */
12640 err = alc268_parse_auto_config(codec);
12641 if (err < 0) {
12642 alc_free(codec);
12643 return err;
12644 } else if (!err) {
12645 printk(KERN_INFO
12646 "hda_codec: Cannot set up configuration "
12647 "from BIOS. Using base mode...\n");
12648 board_config = ALC268_3ST;
12649 }
12650 }
12651
12652 if (board_config != ALC268_AUTO)
12653 setup_preset(spec, &alc268_presets[board_config]);
12654
Kailang Yanga361d842007-06-05 12:30:55 +020012655 spec->stream_analog_playback = &alc268_pcm_analog_playback;
12656 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010012657 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020012658
Kailang Yanga361d842007-06-05 12:30:55 +020012659 spec->stream_digital_playback = &alc268_pcm_digital_playback;
12660
Takashi Iwai22971e32009-02-10 11:56:44 +010012661 has_beep = 0;
12662 for (i = 0; i < spec->num_mixers; i++) {
12663 if (spec->mixers[i] == alc268_beep_mixer) {
12664 has_beep = 1;
12665 break;
12666 }
12667 }
12668
12669 if (has_beep) {
12670 err = snd_hda_attach_beep_device(codec, 0x1);
12671 if (err < 0) {
12672 alc_free(codec);
12673 return err;
12674 }
12675 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
12676 /* override the amp caps for beep generator */
12677 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012678 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
12679 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
12680 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
12681 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010012682 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012683
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012684 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012685 /* check whether NID 0x07 is valid */
12686 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010012687 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020012688
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012689 /* get type */
12690 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwai67ebcb02008-02-19 15:03:57 +010012691 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012692 spec->adc_nids = alc268_adc_nids_alt;
12693 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012694 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012695 } else {
12696 spec->adc_nids = alc268_adc_nids;
12697 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012698 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020012699 }
Takashi Iwaie1406342008-02-11 18:32:32 +010012700 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai85860c02008-02-19 15:00:15 +010012701 /* set default input source */
12702 for (i = 0; i < spec->num_adc_nids; i++)
12703 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
12704 0, AC_VERB_SET_CONNECT_SEL,
12705 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020012706 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010012707
12708 spec->vmaster_nid = 0x02;
12709
Kailang Yanga361d842007-06-05 12:30:55 +020012710 codec->patch_ops = alc_patch_ops;
12711 if (board_config == ALC268_AUTO)
12712 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020012713
Takashi Iwaidaead532008-11-28 12:55:36 +010012714 codec->proc_widget_hook = print_realtek_coef;
12715
Kailang Yanga361d842007-06-05 12:30:55 +020012716 return 0;
12717}
12718
12719/*
Kailang Yangf6a92242007-12-13 16:52:54 +010012720 * ALC269 channel source setting (2 channel)
12721 */
12722#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
12723
12724#define alc269_dac_nids alc260_dac_nids
12725
12726static hda_nid_t alc269_adc_nids[1] = {
12727 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020012728 0x08,
12729};
12730
Takashi Iwaie01bf502008-08-21 16:25:07 +020012731static hda_nid_t alc269_capsrc_nids[1] = {
12732 0x23,
12733};
12734
12735/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
12736 * not a mux!
12737 */
12738
Kailang Yangf53281e2008-07-18 12:36:43 +020012739static struct hda_input_mux alc269_eeepc_dmic_capture_source = {
12740 .num_items = 2,
12741 .items = {
12742 { "i-Mic", 0x5 },
12743 { "e-Mic", 0x0 },
12744 },
12745};
12746
12747static struct hda_input_mux alc269_eeepc_amic_capture_source = {
12748 .num_items = 2,
12749 .items = {
12750 { "i-Mic", 0x1 },
12751 { "e-Mic", 0x0 },
12752 },
Kailang Yangf6a92242007-12-13 16:52:54 +010012753};
12754
12755#define alc269_modes alc260_modes
12756#define alc269_capture_source alc880_lg_lw_capture_source
12757
12758static struct snd_kcontrol_new alc269_base_mixer[] = {
12759 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12760 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12761 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12762 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12763 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12764 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12765 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12766 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12767 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12768 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12769 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12770 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
12771 { } /* end */
12772};
12773
Kailang Yang60db6b52008-08-26 13:13:00 +020012774static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
12775 /* output mixer control */
12776 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12777 {
12778 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12779 .name = "Master Playback Switch",
12780 .info = snd_hda_mixer_amp_switch_info,
12781 .get = snd_hda_mixer_amp_switch_get,
12782 .put = alc268_acer_master_sw_put,
12783 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12784 },
12785 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12786 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12787 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12788 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12789 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12790 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020012791 { }
12792};
12793
Tony Vroon64154832008-11-06 15:08:49 +000012794static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
12795 /* output mixer control */
12796 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12797 {
12798 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12799 .name = "Master Playback Switch",
12800 .info = snd_hda_mixer_amp_switch_info,
12801 .get = snd_hda_mixer_amp_switch_get,
12802 .put = alc268_acer_master_sw_put,
12803 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12804 },
12805 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12806 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12807 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12808 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12809 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12810 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12811 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
12812 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
12813 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000012814 { }
12815};
12816
Kailang Yangf53281e2008-07-18 12:36:43 +020012817/* bind volumes of both NID 0x0c and 0x0d */
12818static struct hda_bind_ctls alc269_epc_bind_vol = {
12819 .ops = &snd_hda_bind_vol,
12820 .values = {
12821 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
12822 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
12823 0
12824 },
12825};
12826
12827static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
12828 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12829 HDA_BIND_VOL("LineOut Playback Volume", &alc269_epc_bind_vol),
12830 HDA_CODEC_MUTE("LineOut Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12831 { } /* end */
12832};
12833
Kailang Yangf6a92242007-12-13 16:52:54 +010012834/* capture mixer elements */
Kailang Yangf53281e2008-07-18 12:36:43 +020012835static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
12836 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12837 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012838 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12839 { } /* end */
12840};
12841
12842/* FSC amilo */
12843static struct snd_kcontrol_new alc269_fujitsu_mixer[] = {
12844 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12845 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12846 HDA_BIND_VOL("PCM Playback Volume", &alc269_epc_bind_vol),
Kailang Yangf53281e2008-07-18 12:36:43 +020012847 { } /* end */
12848};
12849
Kailang Yang60db6b52008-08-26 13:13:00 +020012850static struct hda_verb alc269_quanta_fl1_verbs[] = {
12851 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12852 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12853 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12854 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12855 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12856 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12857 { }
12858};
12859
Tony Vroon64154832008-11-06 15:08:49 +000012860static struct hda_verb alc269_lifebook_verbs[] = {
12861 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12862 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
12863 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12864 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12865 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12866 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12867 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12868 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12869 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12870 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12871 { }
12872};
12873
Kailang Yang60db6b52008-08-26 13:13:00 +020012874/* toggle speaker-output according to the hp-jack state */
12875static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
12876{
12877 unsigned int present;
12878 unsigned char bits;
12879
12880 present = snd_hda_codec_read(codec, 0x15, 0,
12881 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12882 bits = present ? AMP_IN_MUTE(0) : 0;
12883 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12884 AMP_IN_MUTE(0), bits);
12885 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12886 AMP_IN_MUTE(0), bits);
12887
12888 snd_hda_codec_write(codec, 0x20, 0,
12889 AC_VERB_SET_COEF_INDEX, 0x0c);
12890 snd_hda_codec_write(codec, 0x20, 0,
12891 AC_VERB_SET_PROC_COEF, 0x680);
12892
12893 snd_hda_codec_write(codec, 0x20, 0,
12894 AC_VERB_SET_COEF_INDEX, 0x0c);
12895 snd_hda_codec_write(codec, 0x20, 0,
12896 AC_VERB_SET_PROC_COEF, 0x480);
12897}
12898
Tony Vroon64154832008-11-06 15:08:49 +000012899/* toggle speaker-output according to the hp-jacks state */
12900static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
12901{
12902 unsigned int present;
12903 unsigned char bits;
12904
12905 /* Check laptop headphone socket */
12906 present = snd_hda_codec_read(codec, 0x15, 0,
12907 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12908
12909 /* Check port replicator headphone socket */
12910 present |= snd_hda_codec_read(codec, 0x1a, 0,
12911 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12912
12913 bits = present ? AMP_IN_MUTE(0) : 0;
12914 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12915 AMP_IN_MUTE(0), bits);
12916 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12917 AMP_IN_MUTE(0), bits);
12918
12919 snd_hda_codec_write(codec, 0x20, 0,
12920 AC_VERB_SET_COEF_INDEX, 0x0c);
12921 snd_hda_codec_write(codec, 0x20, 0,
12922 AC_VERB_SET_PROC_COEF, 0x680);
12923
12924 snd_hda_codec_write(codec, 0x20, 0,
12925 AC_VERB_SET_COEF_INDEX, 0x0c);
12926 snd_hda_codec_write(codec, 0x20, 0,
12927 AC_VERB_SET_PROC_COEF, 0x480);
12928}
12929
Kailang Yang60db6b52008-08-26 13:13:00 +020012930static void alc269_quanta_fl1_mic_automute(struct hda_codec *codec)
12931{
12932 unsigned int present;
12933
12934 present = snd_hda_codec_read(codec, 0x18, 0,
12935 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12936 snd_hda_codec_write(codec, 0x23, 0,
12937 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x1);
12938}
12939
Tony Vroon64154832008-11-06 15:08:49 +000012940static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
12941{
12942 unsigned int present_laptop;
12943 unsigned int present_dock;
12944
12945 present_laptop = snd_hda_codec_read(codec, 0x18, 0,
12946 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12947
12948 present_dock = snd_hda_codec_read(codec, 0x1b, 0,
12949 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12950
12951 /* Laptop mic port overrides dock mic port, design decision */
12952 if (present_dock)
12953 snd_hda_codec_write(codec, 0x23, 0,
12954 AC_VERB_SET_CONNECT_SEL, 0x3);
12955 if (present_laptop)
12956 snd_hda_codec_write(codec, 0x23, 0,
12957 AC_VERB_SET_CONNECT_SEL, 0x0);
12958 if (!present_dock && !present_laptop)
12959 snd_hda_codec_write(codec, 0x23, 0,
12960 AC_VERB_SET_CONNECT_SEL, 0x1);
12961}
12962
Kailang Yang60db6b52008-08-26 13:13:00 +020012963static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
12964 unsigned int res)
12965{
12966 if ((res >> 26) == ALC880_HP_EVENT)
12967 alc269_quanta_fl1_speaker_automute(codec);
12968 if ((res >> 26) == ALC880_MIC_EVENT)
12969 alc269_quanta_fl1_mic_automute(codec);
12970}
12971
Tony Vroon64154832008-11-06 15:08:49 +000012972static void alc269_lifebook_unsol_event(struct hda_codec *codec,
12973 unsigned int res)
12974{
12975 if ((res >> 26) == ALC880_HP_EVENT)
12976 alc269_lifebook_speaker_automute(codec);
12977 if ((res >> 26) == ALC880_MIC_EVENT)
12978 alc269_lifebook_mic_autoswitch(codec);
12979}
12980
Kailang Yang60db6b52008-08-26 13:13:00 +020012981static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
12982{
12983 alc269_quanta_fl1_speaker_automute(codec);
12984 alc269_quanta_fl1_mic_automute(codec);
12985}
12986
Tony Vroon64154832008-11-06 15:08:49 +000012987static void alc269_lifebook_init_hook(struct hda_codec *codec)
12988{
12989 alc269_lifebook_speaker_automute(codec);
12990 alc269_lifebook_mic_autoswitch(codec);
12991}
12992
Kailang Yang60db6b52008-08-26 13:13:00 +020012993static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
12994 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12995 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
12996 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12997 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
12998 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12999 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13000 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13001 {}
13002};
13003
13004static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
13005 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13006 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
13007 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13008 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
13009 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13010 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13011 {}
13012};
13013
13014/* toggle speaker-output according to the hp-jack state */
13015static void alc269_speaker_automute(struct hda_codec *codec)
13016{
13017 unsigned int present;
13018 unsigned char bits;
13019
13020 present = snd_hda_codec_read(codec, 0x15, 0,
13021 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13022 bits = present ? AMP_IN_MUTE(0) : 0;
13023 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13024 AMP_IN_MUTE(0), bits);
13025 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13026 AMP_IN_MUTE(0), bits);
13027}
13028
13029static void alc269_eeepc_dmic_automute(struct hda_codec *codec)
13030{
13031 unsigned int present;
13032
13033 present = snd_hda_codec_read(codec, 0x18, 0,
13034 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13035 snd_hda_codec_write(codec, 0x23, 0,
13036 AC_VERB_SET_CONNECT_SEL, (present ? 0 : 5));
13037}
13038
13039static void alc269_eeepc_amic_automute(struct hda_codec *codec)
13040{
13041 unsigned int present;
13042
13043 present = snd_hda_codec_read(codec, 0x18, 0,
13044 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13045 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13046 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
13047 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13048 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
13049}
13050
13051/* unsolicited event for HP jack sensing */
13052static void alc269_eeepc_dmic_unsol_event(struct hda_codec *codec,
13053 unsigned int res)
13054{
13055 if ((res >> 26) == ALC880_HP_EVENT)
13056 alc269_speaker_automute(codec);
13057
13058 if ((res >> 26) == ALC880_MIC_EVENT)
13059 alc269_eeepc_dmic_automute(codec);
13060}
13061
13062static void alc269_eeepc_dmic_inithook(struct hda_codec *codec)
13063{
13064 alc269_speaker_automute(codec);
13065 alc269_eeepc_dmic_automute(codec);
13066}
13067
13068/* unsolicited event for HP jack sensing */
13069static void alc269_eeepc_amic_unsol_event(struct hda_codec *codec,
13070 unsigned int res)
13071{
13072 if ((res >> 26) == ALC880_HP_EVENT)
13073 alc269_speaker_automute(codec);
13074
13075 if ((res >> 26) == ALC880_MIC_EVENT)
13076 alc269_eeepc_amic_automute(codec);
13077}
13078
13079static void alc269_eeepc_amic_inithook(struct hda_codec *codec)
13080{
13081 alc269_speaker_automute(codec);
13082 alc269_eeepc_amic_automute(codec);
13083}
13084
Kailang Yangf6a92242007-12-13 16:52:54 +010013085/*
13086 * generic initialization of ADC, input mixers and output mixers
13087 */
13088static struct hda_verb alc269_init_verbs[] = {
13089 /*
13090 * Unmute ADC0 and set the default input to mic-in
13091 */
Kailang Yang60db6b52008-08-26 13:13:00 +020013092 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010013093
13094 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
13095 * analog-loopback mixer widget
13096 * Note: PASD motherboards uses the Line In 2 as the input for
13097 * front panel mic (mic 2)
13098 */
13099 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
13100 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13101 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13102 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13103 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13104 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
13105
13106 /*
13107 * Set up output mixers (0x0c - 0x0e)
13108 */
13109 /* set vol=0 to output mixers */
13110 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13111 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13112
13113 /* set up input amps for analog loopback */
13114 /* Amp Indices: DAC = 0, mixer = 1 */
13115 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13116 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13117 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13118 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13119 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13120 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13121
13122 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13123 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13124 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13125 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13126 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13127 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13128 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13129
13130 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13131 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13132 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13133 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13134 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13135 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13136 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13137
13138 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
13139 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
13140
13141 /* FIXME: use matrix-type input source selection */
13142 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
13143 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang60db6b52008-08-26 13:13:00 +020013144 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13145 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangf6a92242007-12-13 16:52:54 +010013146 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13147 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13148
13149 /* set EAPD */
13150 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13151 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
13152 { }
13153};
13154
13155/* add playback controls from the parsed DAC table */
13156static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
13157 const struct auto_pin_cfg *cfg)
13158{
13159 hda_nid_t nid;
13160 int err;
13161
13162 spec->multiout.num_dacs = 1; /* only use one dac */
13163 spec->multiout.dac_nids = spec->private_dac_nids;
13164 spec->multiout.dac_nids[0] = 2;
13165
13166 nid = cfg->line_out_pins[0];
13167 if (nid) {
13168 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13169 "Front Playback Volume",
13170 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
13171 if (err < 0)
13172 return err;
13173 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13174 "Front Playback Switch",
13175 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
13176 if (err < 0)
13177 return err;
13178 }
13179
13180 nid = cfg->speaker_pins[0];
13181 if (nid) {
13182 if (!cfg->line_out_pins[0]) {
13183 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13184 "Speaker Playback Volume",
13185 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
13186 HDA_OUTPUT));
13187 if (err < 0)
13188 return err;
13189 }
13190 if (nid == 0x16) {
13191 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13192 "Speaker Playback Switch",
13193 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13194 HDA_OUTPUT));
13195 if (err < 0)
13196 return err;
13197 } else {
13198 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13199 "Speaker Playback Switch",
13200 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13201 HDA_OUTPUT));
13202 if (err < 0)
13203 return err;
13204 }
13205 }
13206 nid = cfg->hp_pins[0];
13207 if (nid) {
13208 /* spec->multiout.hp_nid = 2; */
13209 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
13210 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13211 "Headphone Playback Volume",
13212 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
13213 HDA_OUTPUT));
13214 if (err < 0)
13215 return err;
13216 }
13217 if (nid == 0x16) {
13218 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13219 "Headphone Playback Switch",
13220 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13221 HDA_OUTPUT));
13222 if (err < 0)
13223 return err;
13224 } else {
13225 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13226 "Headphone Playback Switch",
13227 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13228 HDA_OUTPUT));
13229 if (err < 0)
13230 return err;
13231 }
13232 }
13233 return 0;
13234}
13235
Takashi Iwaiee956e02008-10-31 17:16:31 +010013236static int alc269_auto_create_analog_input_ctls(struct alc_spec *spec,
13237 const struct auto_pin_cfg *cfg)
13238{
13239 int err;
13240
13241 err = alc880_auto_create_analog_input_ctls(spec, cfg);
13242 if (err < 0)
13243 return err;
13244 /* digital-mic input pin is excluded in alc880_auto_create..()
13245 * because it's under 0x18
13246 */
13247 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
13248 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013249 struct hda_input_mux *imux = &spec->private_imux[0];
Takashi Iwaiee956e02008-10-31 17:16:31 +010013250 imux->items[imux->num_items].label = "Int Mic";
13251 imux->items[imux->num_items].index = 0x05;
13252 imux->num_items++;
13253 }
13254 return 0;
13255}
Kailang Yangf6a92242007-12-13 16:52:54 +010013256
13257#ifdef CONFIG_SND_HDA_POWER_SAVE
13258#define alc269_loopbacks alc880_loopbacks
13259#endif
13260
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013261/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010013262#define alc269_pcm_analog_playback alc880_pcm_analog_playback
13263#define alc269_pcm_analog_capture alc880_pcm_analog_capture
13264#define alc269_pcm_digital_playback alc880_pcm_digital_playback
13265#define alc269_pcm_digital_capture alc880_pcm_digital_capture
13266
Takashi Iwaif03d3112009-03-05 14:18:16 +010013267static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
13268 .substreams = 1,
13269 .channels_min = 2,
13270 .channels_max = 8,
13271 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13272 /* NID is set in alc_build_pcms */
13273 .ops = {
13274 .open = alc880_playback_pcm_open,
13275 .prepare = alc880_playback_pcm_prepare,
13276 .cleanup = alc880_playback_pcm_cleanup
13277 },
13278};
13279
13280static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
13281 .substreams = 1,
13282 .channels_min = 2,
13283 .channels_max = 2,
13284 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13285 /* NID is set in alc_build_pcms */
13286};
13287
Kailang Yangf6a92242007-12-13 16:52:54 +010013288/*
13289 * BIOS auto configuration
13290 */
13291static int alc269_parse_auto_config(struct hda_codec *codec)
13292{
13293 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010013294 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010013295 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
13296
13297 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13298 alc269_ignore);
13299 if (err < 0)
13300 return err;
13301
13302 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
13303 if (err < 0)
13304 return err;
13305 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
13306 if (err < 0)
13307 return err;
13308
13309 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13310
Takashi Iwai0852d7a2009-02-11 11:35:15 +010013311 if (spec->autocfg.dig_outs)
Kailang Yangf6a92242007-12-13 16:52:54 +010013312 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
13313
Takashi Iwai603c4012008-07-30 15:01:44 +020013314 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013315 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010013316
Takashi Iwaid88897e2008-10-31 15:01:37 +010013317 add_verb(spec, alc269_init_verbs);
Kailang Yangf6a92242007-12-13 16:52:54 +010013318 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013319 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie01bf502008-08-21 16:25:07 +020013320 /* set default input source */
13321 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
13322 0, AC_VERB_SET_CONNECT_SEL,
13323 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010013324
13325 err = alc_auto_add_mic_boost(codec);
13326 if (err < 0)
13327 return err;
13328
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013329 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013330 set_capture_mixer(spec);
Kailang Yangf53281e2008-07-18 12:36:43 +020013331
Kailang Yangf6a92242007-12-13 16:52:54 +010013332 return 1;
13333}
13334
13335#define alc269_auto_init_multi_out alc882_auto_init_multi_out
13336#define alc269_auto_init_hp_out alc882_auto_init_hp_out
13337#define alc269_auto_init_analog_input alc882_auto_init_analog_input
13338
13339
13340/* init callback for auto-configuration model -- overriding the default init */
13341static void alc269_auto_init(struct hda_codec *codec)
13342{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013343 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010013344 alc269_auto_init_multi_out(codec);
13345 alc269_auto_init_hp_out(codec);
13346 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013347 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013348 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010013349}
13350
13351/*
13352 * configuration and preset
13353 */
13354static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013355 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020013356 [ALC269_QUANTA_FL1] = "quanta",
13357 [ALC269_ASUS_EEEPC_P703] = "eeepc-p703",
Takashi Iwai26f5df22008-11-03 17:39:46 +010013358 [ALC269_ASUS_EEEPC_P901] = "eeepc-p901",
Tony Vroon64154832008-11-06 15:08:49 +000013359 [ALC269_FUJITSU] = "fujitsu",
13360 [ALC269_LIFEBOOK] = "lifebook"
Kailang Yangf6a92242007-12-13 16:52:54 +010013361};
13362
13363static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013364 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020013365 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
13366 ALC269_ASUS_EEEPC_P703),
Kailang Yang622e84c2009-04-21 07:39:04 +020013367 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_ASUS_EEEPC_P703),
13368 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_ASUS_EEEPC_P703),
13369 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_ASUS_EEEPC_P703),
13370 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_ASUS_EEEPC_P703),
13371 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_ASUS_EEEPC_P703),
13372 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_ASUS_EEEPC_P703),
Kailang Yangf53281e2008-07-18 12:36:43 +020013373 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
13374 ALC269_ASUS_EEEPC_P901),
Kailang Yang60db6b52008-08-26 13:13:00 +020013375 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
13376 ALC269_ASUS_EEEPC_P901),
Kailang Yang622e84c2009-04-21 07:39:04 +020013377 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_ASUS_EEEPC_P901),
Takashi Iwai26f5df22008-11-03 17:39:46 +010013378 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
Tony Vroon64154832008-11-06 15:08:49 +000013379 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yangf6a92242007-12-13 16:52:54 +010013380 {}
13381};
13382
13383static struct alc_config_preset alc269_presets[] = {
13384 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013385 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010013386 .init_verbs = { alc269_init_verbs },
13387 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13388 .dac_nids = alc269_dac_nids,
13389 .hp_nid = 0x03,
13390 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13391 .channel_mode = alc269_modes,
13392 .input_mux = &alc269_capture_source,
13393 },
Kailang Yang60db6b52008-08-26 13:13:00 +020013394 [ALC269_QUANTA_FL1] = {
13395 .mixers = { alc269_quanta_fl1_mixer },
13396 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
13397 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13398 .dac_nids = alc269_dac_nids,
13399 .hp_nid = 0x03,
13400 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13401 .channel_mode = alc269_modes,
13402 .input_mux = &alc269_capture_source,
13403 .unsol_event = alc269_quanta_fl1_unsol_event,
13404 .init_hook = alc269_quanta_fl1_init_hook,
13405 },
Kailang Yangf53281e2008-07-18 12:36:43 +020013406 [ALC269_ASUS_EEEPC_P703] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013407 .mixers = { alc269_eeepc_mixer },
13408 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013409 .init_verbs = { alc269_init_verbs,
13410 alc269_eeepc_amic_init_verbs },
13411 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13412 .dac_nids = alc269_dac_nids,
13413 .hp_nid = 0x03,
13414 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13415 .channel_mode = alc269_modes,
13416 .input_mux = &alc269_eeepc_amic_capture_source,
13417 .unsol_event = alc269_eeepc_amic_unsol_event,
13418 .init_hook = alc269_eeepc_amic_inithook,
13419 },
13420 [ALC269_ASUS_EEEPC_P901] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013421 .mixers = { alc269_eeepc_mixer },
13422 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013423 .init_verbs = { alc269_init_verbs,
13424 alc269_eeepc_dmic_init_verbs },
13425 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13426 .dac_nids = alc269_dac_nids,
13427 .hp_nid = 0x03,
13428 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13429 .channel_mode = alc269_modes,
13430 .input_mux = &alc269_eeepc_dmic_capture_source,
13431 .unsol_event = alc269_eeepc_dmic_unsol_event,
13432 .init_hook = alc269_eeepc_dmic_inithook,
13433 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013434 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013435 .mixers = { alc269_fujitsu_mixer },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013436 .cap_mixer = alc269_epc_capture_mixer,
13437 .init_verbs = { alc269_init_verbs,
13438 alc269_eeepc_dmic_init_verbs },
13439 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13440 .dac_nids = alc269_dac_nids,
13441 .hp_nid = 0x03,
13442 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13443 .channel_mode = alc269_modes,
13444 .input_mux = &alc269_eeepc_dmic_capture_source,
13445 .unsol_event = alc269_eeepc_dmic_unsol_event,
13446 .init_hook = alc269_eeepc_dmic_inithook,
13447 },
Tony Vroon64154832008-11-06 15:08:49 +000013448 [ALC269_LIFEBOOK] = {
13449 .mixers = { alc269_lifebook_mixer },
13450 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
13451 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13452 .dac_nids = alc269_dac_nids,
13453 .hp_nid = 0x03,
13454 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13455 .channel_mode = alc269_modes,
13456 .input_mux = &alc269_capture_source,
13457 .unsol_event = alc269_lifebook_unsol_event,
13458 .init_hook = alc269_lifebook_init_hook,
13459 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013460};
13461
13462static int patch_alc269(struct hda_codec *codec)
13463{
13464 struct alc_spec *spec;
13465 int board_config;
13466 int err;
13467
13468 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13469 if (spec == NULL)
13470 return -ENOMEM;
13471
13472 codec->spec = spec;
13473
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020013474 alc_fix_pll_init(codec, 0x20, 0x04, 15);
13475
Kailang Yangf6a92242007-12-13 16:52:54 +010013476 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
13477 alc269_models,
13478 alc269_cfg_tbl);
13479
13480 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020013481 printk(KERN_INFO "hda_codec: Unknown model for %s, "
13482 "trying auto-probe from BIOS...\n", codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010013483 board_config = ALC269_AUTO;
13484 }
13485
13486 if (board_config == ALC269_AUTO) {
13487 /* automatic parse from the BIOS config */
13488 err = alc269_parse_auto_config(codec);
13489 if (err < 0) {
13490 alc_free(codec);
13491 return err;
13492 } else if (!err) {
13493 printk(KERN_INFO
13494 "hda_codec: Cannot set up configuration "
13495 "from BIOS. Using base mode...\n");
13496 board_config = ALC269_BASIC;
13497 }
13498 }
13499
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090013500 err = snd_hda_attach_beep_device(codec, 0x1);
13501 if (err < 0) {
13502 alc_free(codec);
13503 return err;
13504 }
13505
Kailang Yangf6a92242007-12-13 16:52:54 +010013506 if (board_config != ALC269_AUTO)
13507 setup_preset(spec, &alc269_presets[board_config]);
13508
Takashi Iwaif03d3112009-03-05 14:18:16 +010013509 if (codec->subsystem_id == 0x17aa3bf8) {
13510 /* Due to a hardware problem on Lenovo Ideadpad, we need to
13511 * fix the sample rate of analog I/O to 44.1kHz
13512 */
13513 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
13514 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
13515 } else {
13516 spec->stream_analog_playback = &alc269_pcm_analog_playback;
13517 spec->stream_analog_capture = &alc269_pcm_analog_capture;
13518 }
Kailang Yangf6a92242007-12-13 16:52:54 +010013519 spec->stream_digital_playback = &alc269_pcm_digital_playback;
13520 spec->stream_digital_capture = &alc269_pcm_digital_capture;
13521
13522 spec->adc_nids = alc269_adc_nids;
13523 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
Takashi Iwaie01bf502008-08-21 16:25:07 +020013524 spec->capsrc_nids = alc269_capsrc_nids;
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013525 if (!spec->cap_mixer)
13526 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013527 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010013528
13529 codec->patch_ops = alc_patch_ops;
13530 if (board_config == ALC269_AUTO)
13531 spec->init_hook = alc269_auto_init;
13532#ifdef CONFIG_SND_HDA_POWER_SAVE
13533 if (!spec->loopback.amplist)
13534 spec->loopback.amplist = alc269_loopbacks;
13535#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010013536 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010013537
13538 return 0;
13539}
13540
13541/*
Kailang Yangdf694da2005-12-05 19:42:22 +010013542 * ALC861 channel source setting (2/6 channel selection for 3-stack)
13543 */
13544
13545/*
13546 * set the path ways for 2 channel output
13547 * need to set the codec line out and mic 1 pin widgets to inputs
13548 */
13549static struct hda_verb alc861_threestack_ch2_init[] = {
13550 /* set pin widget 1Ah (line in) for input */
13551 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013552 /* set pin widget 18h (mic1/2) for input, for mic also enable
13553 * the vref
13554 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013555 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13556
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013557 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13558#if 0
13559 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13560 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13561#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013562 { } /* end */
13563};
13564/*
13565 * 6ch mode
13566 * need to set the codec line out and mic 1 pin widgets to outputs
13567 */
13568static struct hda_verb alc861_threestack_ch6_init[] = {
13569 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13570 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13571 /* set pin widget 18h (mic1) for output (CLFE)*/
13572 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13573
13574 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013575 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013576
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013577 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13578#if 0
13579 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13580 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13581#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013582 { } /* end */
13583};
13584
13585static struct hda_channel_mode alc861_threestack_modes[2] = {
13586 { 2, alc861_threestack_ch2_init },
13587 { 6, alc861_threestack_ch6_init },
13588};
Takashi Iwai22309c32006-08-09 16:57:28 +020013589/* Set mic1 as input and unmute the mixer */
13590static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
13591 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13592 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13593 { } /* end */
13594};
13595/* Set mic1 as output and mute mixer */
13596static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
13597 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13598 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13599 { } /* end */
13600};
13601
13602static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
13603 { 2, alc861_uniwill_m31_ch2_init },
13604 { 4, alc861_uniwill_m31_ch4_init },
13605};
Kailang Yangdf694da2005-12-05 19:42:22 +010013606
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013607/* Set mic1 and line-in as input and unmute the mixer */
13608static struct hda_verb alc861_asus_ch2_init[] = {
13609 /* set pin widget 1Ah (line in) for input */
13610 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013611 /* set pin widget 18h (mic1/2) for input, for mic also enable
13612 * the vref
13613 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013614 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13615
13616 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13617#if 0
13618 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13619 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13620#endif
13621 { } /* end */
13622};
13623/* Set mic1 nad line-in as output and mute mixer */
13624static struct hda_verb alc861_asus_ch6_init[] = {
13625 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13626 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13627 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13628 /* set pin widget 18h (mic1) for output (CLFE)*/
13629 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13630 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13631 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
13632 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
13633
13634 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13635#if 0
13636 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13637 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13638#endif
13639 { } /* end */
13640};
13641
13642static struct hda_channel_mode alc861_asus_modes[2] = {
13643 { 2, alc861_asus_ch2_init },
13644 { 6, alc861_asus_ch6_init },
13645};
13646
Kailang Yangdf694da2005-12-05 19:42:22 +010013647/* patch-ALC861 */
13648
13649static struct snd_kcontrol_new alc861_base_mixer[] = {
13650 /* output mixer control */
13651 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13652 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13653 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13654 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13655 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13656
13657 /*Input mixer control */
13658 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13659 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13660 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13661 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13662 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13663 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13664 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13665 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13666 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13667 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013668
Kailang Yangdf694da2005-12-05 19:42:22 +010013669 { } /* end */
13670};
13671
13672static struct snd_kcontrol_new alc861_3ST_mixer[] = {
13673 /* output mixer control */
13674 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13675 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13676 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13677 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13678 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13679
13680 /* Input mixer control */
13681 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13682 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13683 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13684 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13685 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13686 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13687 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13688 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13689 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13690 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013691
Kailang Yangdf694da2005-12-05 19:42:22 +010013692 {
13693 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13694 .name = "Channel Mode",
13695 .info = alc_ch_mode_info,
13696 .get = alc_ch_mode_get,
13697 .put = alc_ch_mode_put,
13698 .private_value = ARRAY_SIZE(alc861_threestack_modes),
13699 },
13700 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013701};
13702
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013703static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013704 /* output mixer control */
13705 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13706 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13707 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020013708
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013709 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013710};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013711
Takashi Iwai22309c32006-08-09 16:57:28 +020013712static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
13713 /* output mixer control */
13714 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13715 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13716 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13717 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13718 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13719
13720 /* Input mixer control */
13721 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13722 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13723 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13724 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13725 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13726 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13727 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13728 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13729 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13730 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013731
Takashi Iwai22309c32006-08-09 16:57:28 +020013732 {
13733 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13734 .name = "Channel Mode",
13735 .info = alc_ch_mode_info,
13736 .get = alc_ch_mode_get,
13737 .put = alc_ch_mode_put,
13738 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
13739 },
13740 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013741};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013742
13743static struct snd_kcontrol_new alc861_asus_mixer[] = {
13744 /* output mixer control */
13745 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13746 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13747 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13748 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13749 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13750
13751 /* Input mixer control */
13752 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13753 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13754 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13755 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13756 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13757 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13758 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13759 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13760 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013761 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
13762
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013763 {
13764 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13765 .name = "Channel Mode",
13766 .info = alc_ch_mode_info,
13767 .get = alc_ch_mode_get,
13768 .put = alc_ch_mode_put,
13769 .private_value = ARRAY_SIZE(alc861_asus_modes),
13770 },
13771 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013772};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013773
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013774/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013775static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013776 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13777 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013778 { }
13779};
13780
Kailang Yangdf694da2005-12-05 19:42:22 +010013781/*
13782 * generic initialization of ADC, input mixers and output mixers
13783 */
13784static struct hda_verb alc861_base_init_verbs[] = {
13785 /*
13786 * Unmute ADC0 and set the default input to mic-in
13787 */
13788 /* port-A for surround (rear panel) */
13789 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13790 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
13791 /* port-B for mic-in (rear panel) with vref */
13792 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13793 /* port-C for line-in (rear panel) */
13794 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13795 /* port-D for Front */
13796 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13797 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13798 /* port-E for HP out (front panel) */
13799 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13800 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013801 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013802 /* port-F for mic-in (front panel) with vref */
13803 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13804 /* port-G for CLFE (rear panel) */
13805 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13806 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13807 /* port-H for side (rear panel) */
13808 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13809 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
13810 /* CD-in */
13811 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13812 /* route front mic to ADC1*/
13813 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13814 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013815
Kailang Yangdf694da2005-12-05 19:42:22 +010013816 /* Unmute DAC0~3 & spdif out*/
13817 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13818 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13819 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13820 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13821 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013822
Kailang Yangdf694da2005-12-05 19:42:22 +010013823 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13824 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13825 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13826 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13827 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013828
Kailang Yangdf694da2005-12-05 19:42:22 +010013829 /* Unmute Stereo Mixer 15 */
13830 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13831 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13832 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013833 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013834
13835 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13836 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13837 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13838 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13839 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13840 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13841 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13842 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013843 /* hp used DAC 3 (Front) */
13844 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013845 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13846
13847 { }
13848};
13849
13850static struct hda_verb alc861_threestack_init_verbs[] = {
13851 /*
13852 * Unmute ADC0 and set the default input to mic-in
13853 */
13854 /* port-A for surround (rear panel) */
13855 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13856 /* port-B for mic-in (rear panel) with vref */
13857 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13858 /* port-C for line-in (rear panel) */
13859 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13860 /* port-D for Front */
13861 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13862 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13863 /* port-E for HP out (front panel) */
13864 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13865 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013866 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013867 /* port-F for mic-in (front panel) with vref */
13868 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13869 /* port-G for CLFE (rear panel) */
13870 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13871 /* port-H for side (rear panel) */
13872 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13873 /* CD-in */
13874 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13875 /* route front mic to ADC1*/
13876 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13877 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13878 /* Unmute DAC0~3 & spdif out*/
13879 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13880 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13881 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13882 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13883 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013884
Kailang Yangdf694da2005-12-05 19:42:22 +010013885 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13886 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13887 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13888 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13889 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013890
Kailang Yangdf694da2005-12-05 19:42:22 +010013891 /* Unmute Stereo Mixer 15 */
13892 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13893 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13894 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013895 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013896
13897 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13898 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13899 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13900 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13901 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13902 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13903 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13904 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013905 /* hp used DAC 3 (Front) */
13906 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013907 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13908 { }
13909};
Takashi Iwai22309c32006-08-09 16:57:28 +020013910
13911static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
13912 /*
13913 * Unmute ADC0 and set the default input to mic-in
13914 */
13915 /* port-A for surround (rear panel) */
13916 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13917 /* port-B for mic-in (rear panel) with vref */
13918 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13919 /* port-C for line-in (rear panel) */
13920 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13921 /* port-D for Front */
13922 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13923 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13924 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013925 /* this has to be set to VREF80 */
13926 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013927 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013928 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013929 /* port-F for mic-in (front panel) with vref */
13930 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13931 /* port-G for CLFE (rear panel) */
13932 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13933 /* port-H for side (rear panel) */
13934 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13935 /* CD-in */
13936 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13937 /* route front mic to ADC1*/
13938 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13939 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13940 /* Unmute DAC0~3 & spdif out*/
13941 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13942 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13943 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13944 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13945 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013946
Takashi Iwai22309c32006-08-09 16:57:28 +020013947 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13948 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13949 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13950 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13951 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013952
Takashi Iwai22309c32006-08-09 16:57:28 +020013953 /* Unmute Stereo Mixer 15 */
13954 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13955 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13956 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013957 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020013958
13959 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13960 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13961 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13962 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13963 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13964 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13965 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13966 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013967 /* hp used DAC 3 (Front) */
13968 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020013969 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13970 { }
13971};
13972
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013973static struct hda_verb alc861_asus_init_verbs[] = {
13974 /*
13975 * Unmute ADC0 and set the default input to mic-in
13976 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013977 /* port-A for surround (rear panel)
13978 * according to codec#0 this is the HP jack
13979 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013980 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
13981 /* route front PCM to HP */
13982 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
13983 /* port-B for mic-in (rear panel) with vref */
13984 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13985 /* port-C for line-in (rear panel) */
13986 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13987 /* port-D for Front */
13988 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13989 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13990 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013991 /* this has to be set to VREF80 */
13992 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013993 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013994 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013995 /* port-F for mic-in (front panel) with vref */
13996 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13997 /* port-G for CLFE (rear panel) */
13998 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13999 /* port-H for side (rear panel) */
14000 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14001 /* CD-in */
14002 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14003 /* route front mic to ADC1*/
14004 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14005 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14006 /* Unmute DAC0~3 & spdif out*/
14007 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14008 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14009 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14010 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14011 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14012 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14013 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14014 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14015 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14016 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014017
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014018 /* Unmute Stereo Mixer 15 */
14019 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14020 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14021 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014022 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014023
14024 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14025 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14026 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14027 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14028 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14029 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14030 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14031 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014032 /* hp used DAC 3 (Front) */
14033 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014034 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14035 { }
14036};
14037
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014038/* additional init verbs for ASUS laptops */
14039static struct hda_verb alc861_asus_laptop_init_verbs[] = {
14040 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
14041 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
14042 { }
14043};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014044
Kailang Yangdf694da2005-12-05 19:42:22 +010014045/*
14046 * generic initialization of ADC, input mixers and output mixers
14047 */
14048static struct hda_verb alc861_auto_init_verbs[] = {
14049 /*
14050 * Unmute ADC0 and set the default input to mic-in
14051 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014052 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010014053 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014054
Kailang Yangdf694da2005-12-05 19:42:22 +010014055 /* Unmute DAC0~3 & spdif out*/
14056 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14057 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14058 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14059 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14060 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014061
Kailang Yangdf694da2005-12-05 19:42:22 +010014062 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14063 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14064 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14065 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14066 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014067
Kailang Yangdf694da2005-12-05 19:42:22 +010014068 /* Unmute Stereo Mixer 15 */
14069 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14070 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14071 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14072 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
14073
14074 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14075 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14076 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14077 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14078 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14079 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14080 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14081 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14082
14083 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14084 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014085 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14086 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014087 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14088 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014089 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14090 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014091
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014092 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014093
14094 { }
14095};
14096
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014097static struct hda_verb alc861_toshiba_init_verbs[] = {
14098 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014099
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014100 { }
14101};
14102
14103/* toggle speaker-output according to the hp-jack state */
14104static void alc861_toshiba_automute(struct hda_codec *codec)
14105{
14106 unsigned int present;
14107
14108 present = snd_hda_codec_read(codec, 0x0f, 0,
14109 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014110 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
14111 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
14112 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
14113 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014114}
14115
14116static void alc861_toshiba_unsol_event(struct hda_codec *codec,
14117 unsigned int res)
14118{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014119 if ((res >> 26) == ALC880_HP_EVENT)
14120 alc861_toshiba_automute(codec);
14121}
14122
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014123/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014124#define alc861_pcm_analog_playback alc880_pcm_analog_playback
14125#define alc861_pcm_analog_capture alc880_pcm_analog_capture
14126#define alc861_pcm_digital_playback alc880_pcm_digital_playback
14127#define alc861_pcm_digital_capture alc880_pcm_digital_capture
14128
14129
14130#define ALC861_DIGOUT_NID 0x07
14131
14132static struct hda_channel_mode alc861_8ch_modes[1] = {
14133 { 8, NULL }
14134};
14135
14136static hda_nid_t alc861_dac_nids[4] = {
14137 /* front, surround, clfe, side */
14138 0x03, 0x06, 0x05, 0x04
14139};
14140
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014141static hda_nid_t alc660_dac_nids[3] = {
14142 /* front, clfe, surround */
14143 0x03, 0x05, 0x06
14144};
14145
Kailang Yangdf694da2005-12-05 19:42:22 +010014146static hda_nid_t alc861_adc_nids[1] = {
14147 /* ADC0-2 */
14148 0x08,
14149};
14150
14151static struct hda_input_mux alc861_capture_source = {
14152 .num_items = 5,
14153 .items = {
14154 { "Mic", 0x0 },
14155 { "Front Mic", 0x3 },
14156 { "Line", 0x1 },
14157 { "CD", 0x4 },
14158 { "Mixer", 0x5 },
14159 },
14160};
14161
14162/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014163static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
14164 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014165{
14166 int i;
14167 hda_nid_t nid;
14168
14169 spec->multiout.dac_nids = spec->private_dac_nids;
14170 for (i = 0; i < cfg->line_outs; i++) {
14171 nid = cfg->line_out_pins[i];
14172 if (nid) {
14173 if (i >= ARRAY_SIZE(alc861_dac_nids))
14174 continue;
14175 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
14176 }
14177 }
14178 spec->multiout.num_dacs = cfg->line_outs;
14179 return 0;
14180}
14181
14182/* add playback controls from the parsed DAC table */
14183static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
14184 const struct auto_pin_cfg *cfg)
14185{
14186 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014187 static const char *chname[4] = {
14188 "Front", "Surround", NULL /*CLFE*/, "Side"
14189 };
Kailang Yangdf694da2005-12-05 19:42:22 +010014190 hda_nid_t nid;
14191 int i, idx, err;
14192
14193 for (i = 0; i < cfg->line_outs; i++) {
14194 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014195 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010014196 continue;
14197 if (nid == 0x05) {
14198 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014199 err = add_control(spec, ALC_CTL_BIND_MUTE,
14200 "Center Playback Switch",
14201 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
14202 HDA_OUTPUT));
14203 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014204 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014205 err = add_control(spec, ALC_CTL_BIND_MUTE,
14206 "LFE Playback Switch",
14207 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
14208 HDA_OUTPUT));
14209 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014210 return err;
14211 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014212 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
14213 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +010014214 if (nid == alc861_dac_nids[idx])
14215 break;
14216 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014217 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
14218 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
14219 HDA_OUTPUT));
14220 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014221 return err;
14222 }
14223 }
14224 return 0;
14225}
14226
14227static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
14228{
14229 int err;
14230 hda_nid_t nid;
14231
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014232 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010014233 return 0;
14234
14235 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
14236 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014237 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
14238 "Headphone Playback Switch",
14239 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
14240 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014241 return err;
14242 spec->multiout.hp_nid = nid;
14243 }
14244 return 0;
14245}
14246
14247/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014248static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
14249 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014250{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014251 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010014252 int i, err, idx, idx1;
14253
14254 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014255 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010014256 case 0x0c:
14257 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014258 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010014259 break;
14260 case 0x0f:
14261 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014262 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010014263 break;
14264 case 0x0d:
14265 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014266 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010014267 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014268 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010014269 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014270 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010014271 break;
14272 case 0x11:
14273 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014274 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010014275 break;
14276 default:
14277 continue;
14278 }
14279
Takashi Iwai4a471b72005-12-07 13:56:29 +010014280 err = new_analog_input(spec, cfg->input_pins[i],
14281 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010014282 if (err < 0)
14283 return err;
14284
Takashi Iwai4a471b72005-12-07 13:56:29 +010014285 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010014286 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014287 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010014288 }
14289 return 0;
14290}
14291
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014292static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
14293 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +010014294 int pin_type, int dac_idx)
14295{
Jacek Luczak564c5be2008-05-03 18:41:23 +020014296 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
14297 pin_type);
14298 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14299 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +010014300}
14301
14302static void alc861_auto_init_multi_out(struct hda_codec *codec)
14303{
14304 struct alc_spec *spec = codec->spec;
14305 int i;
14306
14307 for (i = 0; i < spec->autocfg.line_outs; i++) {
14308 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014309 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010014310 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014311 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014312 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014313 }
14314}
14315
14316static void alc861_auto_init_hp_out(struct hda_codec *codec)
14317{
14318 struct alc_spec *spec = codec->spec;
14319 hda_nid_t pin;
14320
Takashi Iwaieb06ed82006-09-20 17:10:27 +020014321 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010014322 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014323 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
14324 spec->multiout.dac_nids[0]);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014325 pin = spec->autocfg.speaker_pins[0];
14326 if (pin)
14327 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010014328}
14329
14330static void alc861_auto_init_analog_input(struct hda_codec *codec)
14331{
14332 struct alc_spec *spec = codec->spec;
14333 int i;
14334
14335 for (i = 0; i < AUTO_PIN_LAST; i++) {
14336 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai23f0c042009-02-26 13:03:58 +010014337 if (nid >= 0x0c && nid <= 0x11)
14338 alc_set_input_pin(codec, nid, i);
Kailang Yangdf694da2005-12-05 19:42:22 +010014339 }
14340}
14341
14342/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014343/* return 1 if successful, 0 if the proper config is not found,
14344 * or a negative error code
14345 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014346static int alc861_parse_auto_config(struct hda_codec *codec)
14347{
14348 struct alc_spec *spec = codec->spec;
14349 int err;
14350 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
14351
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014352 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14353 alc861_ignore);
14354 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014355 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014356 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014357 return 0; /* can't find valid BIOS pin config */
14358
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014359 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
14360 if (err < 0)
14361 return err;
14362 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
14363 if (err < 0)
14364 return err;
14365 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
14366 if (err < 0)
14367 return err;
14368 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
14369 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014370 return err;
14371
14372 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14373
Takashi Iwai0852d7a2009-02-11 11:35:15 +010014374 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014375 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
14376
Takashi Iwai603c4012008-07-30 15:01:44 +020014377 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014378 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010014379
Takashi Iwaid88897e2008-10-31 15:01:37 +010014380 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010014381
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020014382 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014383 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010014384
14385 spec->adc_nids = alc861_adc_nids;
14386 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014387 set_capture_mixer(spec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014388
Takashi Iwai4a79ba32009-04-22 16:31:35 +020014389 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b);
14390
Kailang Yangdf694da2005-12-05 19:42:22 +010014391 return 1;
14392}
14393
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014394/* additional initialization for auto-configuration model */
14395static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010014396{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014397 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014398 alc861_auto_init_multi_out(codec);
14399 alc861_auto_init_hp_out(codec);
14400 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014401 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014402 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014403}
14404
Takashi Iwaicb53c622007-08-10 17:21:45 +020014405#ifdef CONFIG_SND_HDA_POWER_SAVE
14406static struct hda_amp_list alc861_loopbacks[] = {
14407 { 0x15, HDA_INPUT, 0 },
14408 { 0x15, HDA_INPUT, 1 },
14409 { 0x15, HDA_INPUT, 2 },
14410 { 0x15, HDA_INPUT, 3 },
14411 { } /* end */
14412};
14413#endif
14414
Kailang Yangdf694da2005-12-05 19:42:22 +010014415
14416/*
14417 * configuration and preset
14418 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014419static const char *alc861_models[ALC861_MODEL_LAST] = {
14420 [ALC861_3ST] = "3stack",
14421 [ALC660_3ST] = "3stack-660",
14422 [ALC861_3ST_DIG] = "3stack-dig",
14423 [ALC861_6ST_DIG] = "6stack-dig",
14424 [ALC861_UNIWILL_M31] = "uniwill-m31",
14425 [ALC861_TOSHIBA] = "toshiba",
14426 [ALC861_ASUS] = "asus",
14427 [ALC861_ASUS_LAPTOP] = "asus-laptop",
14428 [ALC861_AUTO] = "auto",
14429};
14430
14431static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010014432 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014433 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14434 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14435 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014436 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020014437 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010014438 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020014439 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
14440 * Any other models that need this preset?
14441 */
14442 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020014443 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
14444 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014445 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
14446 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
14447 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
14448 /* FIXME: the below seems conflict */
14449 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
14450 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
14451 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010014452 {}
14453};
14454
14455static struct alc_config_preset alc861_presets[] = {
14456 [ALC861_3ST] = {
14457 .mixers = { alc861_3ST_mixer },
14458 .init_verbs = { alc861_threestack_init_verbs },
14459 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14460 .dac_nids = alc861_dac_nids,
14461 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14462 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014463 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014464 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14465 .adc_nids = alc861_adc_nids,
14466 .input_mux = &alc861_capture_source,
14467 },
14468 [ALC861_3ST_DIG] = {
14469 .mixers = { alc861_base_mixer },
14470 .init_verbs = { alc861_threestack_init_verbs },
14471 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14472 .dac_nids = alc861_dac_nids,
14473 .dig_out_nid = ALC861_DIGOUT_NID,
14474 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14475 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014476 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014477 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14478 .adc_nids = alc861_adc_nids,
14479 .input_mux = &alc861_capture_source,
14480 },
14481 [ALC861_6ST_DIG] = {
14482 .mixers = { alc861_base_mixer },
14483 .init_verbs = { alc861_base_init_verbs },
14484 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14485 .dac_nids = alc861_dac_nids,
14486 .dig_out_nid = ALC861_DIGOUT_NID,
14487 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
14488 .channel_mode = alc861_8ch_modes,
14489 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14490 .adc_nids = alc861_adc_nids,
14491 .input_mux = &alc861_capture_source,
14492 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014493 [ALC660_3ST] = {
14494 .mixers = { alc861_3ST_mixer },
14495 .init_verbs = { alc861_threestack_init_verbs },
14496 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
14497 .dac_nids = alc660_dac_nids,
14498 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14499 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014500 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014501 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14502 .adc_nids = alc861_adc_nids,
14503 .input_mux = &alc861_capture_source,
14504 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014505 [ALC861_UNIWILL_M31] = {
14506 .mixers = { alc861_uniwill_m31_mixer },
14507 .init_verbs = { alc861_uniwill_m31_init_verbs },
14508 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14509 .dac_nids = alc861_dac_nids,
14510 .dig_out_nid = ALC861_DIGOUT_NID,
14511 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
14512 .channel_mode = alc861_uniwill_m31_modes,
14513 .need_dac_fix = 1,
14514 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14515 .adc_nids = alc861_adc_nids,
14516 .input_mux = &alc861_capture_source,
14517 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014518 [ALC861_TOSHIBA] = {
14519 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014520 .init_verbs = { alc861_base_init_verbs,
14521 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014522 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14523 .dac_nids = alc861_dac_nids,
14524 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14525 .channel_mode = alc883_3ST_2ch_modes,
14526 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14527 .adc_nids = alc861_adc_nids,
14528 .input_mux = &alc861_capture_source,
14529 .unsol_event = alc861_toshiba_unsol_event,
14530 .init_hook = alc861_toshiba_automute,
14531 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014532 [ALC861_ASUS] = {
14533 .mixers = { alc861_asus_mixer },
14534 .init_verbs = { alc861_asus_init_verbs },
14535 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14536 .dac_nids = alc861_dac_nids,
14537 .dig_out_nid = ALC861_DIGOUT_NID,
14538 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
14539 .channel_mode = alc861_asus_modes,
14540 .need_dac_fix = 1,
14541 .hp_nid = 0x06,
14542 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14543 .adc_nids = alc861_adc_nids,
14544 .input_mux = &alc861_capture_source,
14545 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014546 [ALC861_ASUS_LAPTOP] = {
14547 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
14548 .init_verbs = { alc861_asus_init_verbs,
14549 alc861_asus_laptop_init_verbs },
14550 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14551 .dac_nids = alc861_dac_nids,
14552 .dig_out_nid = ALC861_DIGOUT_NID,
14553 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14554 .channel_mode = alc883_3ST_2ch_modes,
14555 .need_dac_fix = 1,
14556 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14557 .adc_nids = alc861_adc_nids,
14558 .input_mux = &alc861_capture_source,
14559 },
14560};
Kailang Yangdf694da2005-12-05 19:42:22 +010014561
14562
14563static int patch_alc861(struct hda_codec *codec)
14564{
14565 struct alc_spec *spec;
14566 int board_config;
14567 int err;
14568
Robert P. J. Daydc041e02006-12-19 14:44:15 +010014569 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010014570 if (spec == NULL)
14571 return -ENOMEM;
14572
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014573 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014574
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014575 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
14576 alc861_models,
14577 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014578
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014579 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020014580 printk(KERN_INFO "hda_codec: Unknown model for %s, "
14581 "trying auto-probe from BIOS...\n", codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010014582 board_config = ALC861_AUTO;
14583 }
14584
14585 if (board_config == ALC861_AUTO) {
14586 /* automatic parse from the BIOS config */
14587 err = alc861_parse_auto_config(codec);
14588 if (err < 0) {
14589 alc_free(codec);
14590 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014591 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014592 printk(KERN_INFO
14593 "hda_codec: Cannot set up configuration "
14594 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010014595 board_config = ALC861_3ST_DIG;
14596 }
14597 }
14598
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014599 err = snd_hda_attach_beep_device(codec, 0x23);
14600 if (err < 0) {
14601 alc_free(codec);
14602 return err;
14603 }
14604
Kailang Yangdf694da2005-12-05 19:42:22 +010014605 if (board_config != ALC861_AUTO)
14606 setup_preset(spec, &alc861_presets[board_config]);
14607
Kailang Yangdf694da2005-12-05 19:42:22 +010014608 spec->stream_analog_playback = &alc861_pcm_analog_playback;
14609 spec->stream_analog_capture = &alc861_pcm_analog_capture;
14610
Kailang Yangdf694da2005-12-05 19:42:22 +010014611 spec->stream_digital_playback = &alc861_pcm_digital_playback;
14612 spec->stream_digital_capture = &alc861_pcm_digital_capture;
14613
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014614 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
14615
Takashi Iwai2134ea42008-01-10 16:53:55 +010014616 spec->vmaster_nid = 0x03;
14617
Kailang Yangdf694da2005-12-05 19:42:22 +010014618 codec->patch_ops = alc_patch_ops;
14619 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014620 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014621#ifdef CONFIG_SND_HDA_POWER_SAVE
14622 if (!spec->loopback.amplist)
14623 spec->loopback.amplist = alc861_loopbacks;
14624#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010014625 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020014626
Kailang Yangdf694da2005-12-05 19:42:22 +010014627 return 0;
14628}
14629
14630/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014631 * ALC861-VD support
14632 *
14633 * Based on ALC882
14634 *
14635 * In addition, an independent DAC
14636 */
14637#define ALC861VD_DIGOUT_NID 0x06
14638
14639static hda_nid_t alc861vd_dac_nids[4] = {
14640 /* front, surr, clfe, side surr */
14641 0x02, 0x03, 0x04, 0x05
14642};
14643
14644/* dac_nids for ALC660vd are in a different order - according to
14645 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014646 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014647 * of ALC660vd codecs, but for now there is only 3stack mixer
14648 * - and it is the same as in 861vd.
14649 * adc_nids in ALC660vd are (is) the same as in 861vd
14650 */
14651static hda_nid_t alc660vd_dac_nids[3] = {
14652 /* front, rear, clfe, rear_surr */
14653 0x02, 0x04, 0x03
14654};
14655
14656static hda_nid_t alc861vd_adc_nids[1] = {
14657 /* ADC0 */
14658 0x09,
14659};
14660
Takashi Iwaie1406342008-02-11 18:32:32 +010014661static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
14662
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014663/* input MUX */
14664/* FIXME: should be a matrix-type input source selection */
14665static struct hda_input_mux alc861vd_capture_source = {
14666 .num_items = 4,
14667 .items = {
14668 { "Mic", 0x0 },
14669 { "Front Mic", 0x1 },
14670 { "Line", 0x2 },
14671 { "CD", 0x4 },
14672 },
14673};
14674
Kailang Yang272a5272007-05-14 11:00:38 +020014675static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010014676 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020014677 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010014678 { "Ext Mic", 0x0 },
14679 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020014680 },
14681};
14682
Kailang Yangd1a991a2007-08-15 16:21:59 +020014683static struct hda_input_mux alc861vd_hp_capture_source = {
14684 .num_items = 2,
14685 .items = {
14686 { "Front Mic", 0x0 },
14687 { "ATAPI Mic", 0x1 },
14688 },
14689};
14690
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014691/*
14692 * 2ch mode
14693 */
14694static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
14695 { 2, NULL }
14696};
14697
14698/*
14699 * 6ch mode
14700 */
14701static struct hda_verb alc861vd_6stack_ch6_init[] = {
14702 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14703 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14704 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14705 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14706 { } /* end */
14707};
14708
14709/*
14710 * 8ch mode
14711 */
14712static struct hda_verb alc861vd_6stack_ch8_init[] = {
14713 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14714 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14715 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14716 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14717 { } /* end */
14718};
14719
14720static struct hda_channel_mode alc861vd_6stack_modes[2] = {
14721 { 6, alc861vd_6stack_ch6_init },
14722 { 8, alc861vd_6stack_ch8_init },
14723};
14724
14725static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
14726 {
14727 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14728 .name = "Channel Mode",
14729 .info = alc_ch_mode_info,
14730 .get = alc_ch_mode_get,
14731 .put = alc_ch_mode_put,
14732 },
14733 { } /* end */
14734};
14735
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014736/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
14737 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
14738 */
14739static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
14740 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14741 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14742
14743 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14744 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
14745
14746 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
14747 HDA_OUTPUT),
14748 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
14749 HDA_OUTPUT),
14750 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
14751 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
14752
14753 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
14754 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
14755
14756 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14757
14758 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14759 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14760 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14761
14762 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14763 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14764 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14765
14766 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14767 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14768
14769 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14770 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14771
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014772 { } /* end */
14773};
14774
14775static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
14776 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14777 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14778
14779 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14780
14781 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14782 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14783 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14784
14785 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14786 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14787 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14788
14789 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14790 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14791
14792 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14793 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14794
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014795 { } /* end */
14796};
14797
Kailang Yangbdd148a2007-05-08 15:19:08 +020014798static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
14799 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14800 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
14801 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14802
14803 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14804
14805 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14806 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14807 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14808
14809 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14810 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14811 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14812
14813 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14814 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14815
14816 { } /* end */
14817};
14818
Tobin Davisb419f342008-03-07 11:57:51 +010014819/* Pin assignment: Speaker=0x14, HP = 0x15,
14820 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020014821 */
14822static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010014823 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14824 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014825 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14826 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010014827 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
14828 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14829 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14830 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
14831 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14832 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014833 { } /* end */
14834};
14835
Kailang Yangd1a991a2007-08-15 16:21:59 +020014836/* Pin assignment: Speaker=0x14, Line-out = 0x15,
14837 * Front Mic=0x18, ATAPI Mic = 0x19,
14838 */
14839static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
14840 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14841 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14842 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14843 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
14844 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14845 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14846 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14847 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020014848
Kailang Yangd1a991a2007-08-15 16:21:59 +020014849 { } /* end */
14850};
14851
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014852/*
14853 * generic initialization of ADC, input mixers and output mixers
14854 */
14855static struct hda_verb alc861vd_volume_init_verbs[] = {
14856 /*
14857 * Unmute ADC0 and set the default input to mic-in
14858 */
14859 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14860 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14861
14862 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
14863 * the analog-loopback mixer widget
14864 */
14865 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020014866 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14867 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14868 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14869 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14870 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014871
14872 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020014873 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14874 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14875 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014876 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014877
14878 /*
14879 * Set up output mixers (0x02 - 0x05)
14880 */
14881 /* set vol=0 to output mixers */
14882 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14883 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14884 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14885 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14886
14887 /* set up input amps for analog loopback */
14888 /* Amp Indices: DAC = 0, mixer = 1 */
14889 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14890 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14891 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14892 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14893 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14894 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14895 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14896 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14897
14898 { }
14899};
14900
14901/*
14902 * 3-stack pin configuration:
14903 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
14904 */
14905static struct hda_verb alc861vd_3stack_init_verbs[] = {
14906 /*
14907 * Set pin mode and muting
14908 */
14909 /* set front pin widgets 0x14 for output */
14910 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14911 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14912 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14913
14914 /* Mic (rear) pin: input vref at 80% */
14915 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14916 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14917 /* Front Mic pin: input vref at 80% */
14918 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14919 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14920 /* Line In pin: input */
14921 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14922 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14923 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14924 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14925 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14926 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14927 /* CD pin widget for input */
14928 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14929
14930 { }
14931};
14932
14933/*
14934 * 6-stack pin configuration:
14935 */
14936static struct hda_verb alc861vd_6stack_init_verbs[] = {
14937 /*
14938 * Set pin mode and muting
14939 */
14940 /* set front pin widgets 0x14 for output */
14941 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14942 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14943 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14944
14945 /* Rear Pin: output 1 (0x0d) */
14946 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14947 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14948 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14949 /* CLFE Pin: output 2 (0x0e) */
14950 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14951 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14952 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
14953 /* Side Pin: output 3 (0x0f) */
14954 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14955 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14956 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
14957
14958 /* Mic (rear) pin: input vref at 80% */
14959 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14960 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14961 /* Front Mic pin: input vref at 80% */
14962 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14963 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14964 /* Line In pin: input */
14965 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14966 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14967 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14968 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14969 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14970 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14971 /* CD pin widget for input */
14972 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14973
14974 { }
14975};
14976
Kailang Yangbdd148a2007-05-08 15:19:08 +020014977static struct hda_verb alc861vd_eapd_verbs[] = {
14978 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14979 { }
14980};
14981
Kailang Yangf9423e72008-05-27 12:32:25 +020014982static struct hda_verb alc660vd_eapd_verbs[] = {
14983 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14984 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
14985 { }
14986};
14987
Kailang Yangbdd148a2007-05-08 15:19:08 +020014988static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
14989 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14990 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14991 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
14992 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020014993 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020014994 {}
14995};
14996
Kailang Yangbdd148a2007-05-08 15:19:08 +020014997static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
14998{
14999 unsigned int present;
15000 unsigned char bits;
15001
15002 present = snd_hda_codec_read(codec, 0x18, 0,
15003 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020015004 bits = present ? HDA_AMP_MUTE : 0;
15005 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
15006 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020015007}
15008
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015009static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020015010{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015011 struct alc_spec *spec = codec->spec;
15012
15013 spec->autocfg.hp_pins[0] = 0x1b;
15014 spec->autocfg.speaker_pins[0] = 0x14;
15015 alc_automute_amp(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020015016 alc861vd_lenovo_mic_automute(codec);
15017}
15018
15019static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
15020 unsigned int res)
15021{
15022 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020015023 case ALC880_MIC_EVENT:
15024 alc861vd_lenovo_mic_automute(codec);
15025 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015026 default:
15027 alc_automute_amp_unsol_event(codec, res);
15028 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020015029 }
15030}
15031
Kailang Yang272a5272007-05-14 11:00:38 +020015032static struct hda_verb alc861vd_dallas_verbs[] = {
15033 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15034 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15035 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15036 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15037
15038 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15039 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15040 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15041 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15042 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15043 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15044 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15045 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015046
Kailang Yang272a5272007-05-14 11:00:38 +020015047 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15048 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15049 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15050 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15051 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15052 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15053 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15054 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15055
15056 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15057 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15058 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15059 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15060 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15061 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15062 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15063 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15064
15065 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15066 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15067 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15068 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
15069
15070 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015071 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020015072 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15073
15074 { } /* end */
15075};
15076
15077/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015078static void alc861vd_dallas_init_hook(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020015079{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015080 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020015081
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015082 spec->autocfg.hp_pins[0] = 0x15;
15083 spec->autocfg.speaker_pins[0] = 0x14;
15084 alc_automute_amp(codec);
Kailang Yang272a5272007-05-14 11:00:38 +020015085}
15086
Takashi Iwaicb53c622007-08-10 17:21:45 +020015087#ifdef CONFIG_SND_HDA_POWER_SAVE
15088#define alc861vd_loopbacks alc880_loopbacks
15089#endif
15090
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015091/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015092#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
15093#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
15094#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
15095#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
15096
15097/*
15098 * configuration and preset
15099 */
15100static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
15101 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015102 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010015103 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015104 [ALC861VD_3ST] = "3stack",
15105 [ALC861VD_3ST_DIG] = "3stack-digout",
15106 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020015107 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020015108 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015109 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015110 [ALC861VD_AUTO] = "auto",
15111};
15112
15113static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015114 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
15115 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010015116 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015117 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Takashi Iwai13c94742008-11-05 08:06:08 +010015118 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020015119 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015120 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015121 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020015122 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Kailang Yang272a5272007-05-14 11:00:38 +020015123 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Takashi Iwai542d7c62007-08-16 18:57:30 +020015124 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010015125 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020015126 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010015127 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020015128 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015129 {}
15130};
15131
15132static struct alc_config_preset alc861vd_presets[] = {
15133 [ALC660VD_3ST] = {
15134 .mixers = { alc861vd_3st_mixer },
15135 .init_verbs = { alc861vd_volume_init_verbs,
15136 alc861vd_3stack_init_verbs },
15137 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15138 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015139 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15140 .channel_mode = alc861vd_3stack_2ch_modes,
15141 .input_mux = &alc861vd_capture_source,
15142 },
Mike Crash6963f842007-06-25 12:12:51 +020015143 [ALC660VD_3ST_DIG] = {
15144 .mixers = { alc861vd_3st_mixer },
15145 .init_verbs = { alc861vd_volume_init_verbs,
15146 alc861vd_3stack_init_verbs },
15147 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15148 .dac_nids = alc660vd_dac_nids,
15149 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020015150 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15151 .channel_mode = alc861vd_3stack_2ch_modes,
15152 .input_mux = &alc861vd_capture_source,
15153 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015154 [ALC861VD_3ST] = {
15155 .mixers = { alc861vd_3st_mixer },
15156 .init_verbs = { alc861vd_volume_init_verbs,
15157 alc861vd_3stack_init_verbs },
15158 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15159 .dac_nids = alc861vd_dac_nids,
15160 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15161 .channel_mode = alc861vd_3stack_2ch_modes,
15162 .input_mux = &alc861vd_capture_source,
15163 },
15164 [ALC861VD_3ST_DIG] = {
15165 .mixers = { alc861vd_3st_mixer },
15166 .init_verbs = { alc861vd_volume_init_verbs,
15167 alc861vd_3stack_init_verbs },
15168 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15169 .dac_nids = alc861vd_dac_nids,
15170 .dig_out_nid = ALC861VD_DIGOUT_NID,
15171 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15172 .channel_mode = alc861vd_3stack_2ch_modes,
15173 .input_mux = &alc861vd_capture_source,
15174 },
15175 [ALC861VD_6ST_DIG] = {
15176 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
15177 .init_verbs = { alc861vd_volume_init_verbs,
15178 alc861vd_6stack_init_verbs },
15179 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15180 .dac_nids = alc861vd_dac_nids,
15181 .dig_out_nid = ALC861VD_DIGOUT_NID,
15182 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
15183 .channel_mode = alc861vd_6stack_modes,
15184 .input_mux = &alc861vd_capture_source,
15185 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020015186 [ALC861VD_LENOVO] = {
15187 .mixers = { alc861vd_lenovo_mixer },
15188 .init_verbs = { alc861vd_volume_init_verbs,
15189 alc861vd_3stack_init_verbs,
15190 alc861vd_eapd_verbs,
15191 alc861vd_lenovo_unsol_verbs },
15192 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15193 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015194 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15195 .channel_mode = alc861vd_3stack_2ch_modes,
15196 .input_mux = &alc861vd_capture_source,
15197 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015198 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015199 },
Kailang Yang272a5272007-05-14 11:00:38 +020015200 [ALC861VD_DALLAS] = {
15201 .mixers = { alc861vd_dallas_mixer },
15202 .init_verbs = { alc861vd_dallas_verbs },
15203 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15204 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020015205 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15206 .channel_mode = alc861vd_3stack_2ch_modes,
15207 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015208 .unsol_event = alc_automute_amp_unsol_event,
15209 .init_hook = alc861vd_dallas_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015210 },
15211 [ALC861VD_HP] = {
15212 .mixers = { alc861vd_hp_mixer },
15213 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
15214 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15215 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015216 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015217 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15218 .channel_mode = alc861vd_3stack_2ch_modes,
15219 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015220 .unsol_event = alc_automute_amp_unsol_event,
15221 .init_hook = alc861vd_dallas_init_hook,
Kailang Yangea1fb292008-08-26 12:58:38 +020015222 },
Takashi Iwai13c94742008-11-05 08:06:08 +010015223 [ALC660VD_ASUS_V1S] = {
15224 .mixers = { alc861vd_lenovo_mixer },
15225 .init_verbs = { alc861vd_volume_init_verbs,
15226 alc861vd_3stack_init_verbs,
15227 alc861vd_eapd_verbs,
15228 alc861vd_lenovo_unsol_verbs },
15229 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15230 .dac_nids = alc660vd_dac_nids,
15231 .dig_out_nid = ALC861VD_DIGOUT_NID,
15232 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15233 .channel_mode = alc861vd_3stack_2ch_modes,
15234 .input_mux = &alc861vd_capture_source,
15235 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015236 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010015237 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015238};
15239
15240/*
15241 * BIOS auto configuration
15242 */
15243static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
15244 hda_nid_t nid, int pin_type, int dac_idx)
15245{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015246 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015247}
15248
15249static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
15250{
15251 struct alc_spec *spec = codec->spec;
15252 int i;
15253
15254 for (i = 0; i <= HDA_SIDE; i++) {
15255 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015256 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015257 if (nid)
15258 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015259 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015260 }
15261}
15262
15263
15264static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
15265{
15266 struct alc_spec *spec = codec->spec;
15267 hda_nid_t pin;
15268
15269 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015270 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015271 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015272 pin = spec->autocfg.speaker_pins[0];
15273 if (pin)
15274 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015275}
15276
15277#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
15278#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
15279
15280static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
15281{
15282 struct alc_spec *spec = codec->spec;
15283 int i;
15284
15285 for (i = 0; i < AUTO_PIN_LAST; i++) {
15286 hda_nid_t nid = spec->autocfg.input_pins[i];
15287 if (alc861vd_is_input_pin(nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010015288 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +010015289 if (nid != ALC861VD_PIN_CD_NID &&
15290 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015291 snd_hda_codec_write(codec, nid, 0,
15292 AC_VERB_SET_AMP_GAIN_MUTE,
15293 AMP_OUT_MUTE);
15294 }
15295 }
15296}
15297
Takashi Iwaif511b012008-08-15 16:46:42 +020015298#define alc861vd_auto_init_input_src alc882_auto_init_input_src
15299
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015300#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
15301#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
15302
15303/* add playback controls from the parsed DAC table */
15304/* Based on ALC880 version. But ALC861VD has separate,
15305 * different NIDs for mute/unmute switch and volume control */
15306static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
15307 const struct auto_pin_cfg *cfg)
15308{
15309 char name[32];
15310 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
15311 hda_nid_t nid_v, nid_s;
15312 int i, err;
15313
15314 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015315 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015316 continue;
15317 nid_v = alc861vd_idx_to_mixer_vol(
15318 alc880_dac_to_idx(
15319 spec->multiout.dac_nids[i]));
15320 nid_s = alc861vd_idx_to_mixer_switch(
15321 alc880_dac_to_idx(
15322 spec->multiout.dac_nids[i]));
15323
15324 if (i == 2) {
15325 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015326 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15327 "Center Playback Volume",
15328 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
15329 HDA_OUTPUT));
15330 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015331 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015332 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15333 "LFE Playback Volume",
15334 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
15335 HDA_OUTPUT));
15336 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015337 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015338 err = add_control(spec, ALC_CTL_BIND_MUTE,
15339 "Center Playback Switch",
15340 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
15341 HDA_INPUT));
15342 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015343 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015344 err = add_control(spec, ALC_CTL_BIND_MUTE,
15345 "LFE Playback Switch",
15346 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
15347 HDA_INPUT));
15348 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015349 return err;
15350 } else {
15351 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015352 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
15353 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
15354 HDA_OUTPUT));
15355 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015356 return err;
15357 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015358 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015359 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015360 HDA_INPUT));
15361 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015362 return err;
15363 }
15364 }
15365 return 0;
15366}
15367
15368/* add playback controls for speaker and HP outputs */
15369/* Based on ALC880 version. But ALC861VD has separate,
15370 * different NIDs for mute/unmute switch and volume control */
15371static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
15372 hda_nid_t pin, const char *pfx)
15373{
15374 hda_nid_t nid_v, nid_s;
15375 int err;
15376 char name[32];
15377
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015378 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015379 return 0;
15380
15381 if (alc880_is_fixed_pin(pin)) {
15382 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
15383 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015384 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015385 spec->multiout.hp_nid = nid_v;
15386 else
15387 spec->multiout.extra_out_nid[0] = nid_v;
15388 /* control HP volume/switch on the output mixer amp */
15389 nid_v = alc861vd_idx_to_mixer_vol(
15390 alc880_fixed_pin_idx(pin));
15391 nid_s = alc861vd_idx_to_mixer_switch(
15392 alc880_fixed_pin_idx(pin));
15393
15394 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015395 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
15396 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
15397 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015398 return err;
15399 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015400 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
15401 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
15402 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015403 return err;
15404 } else if (alc880_is_multi_pin(pin)) {
15405 /* set manual connection */
15406 /* we have only a switch on HP-out PIN */
15407 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015408 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
15409 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
15410 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015411 return err;
15412 }
15413 return 0;
15414}
15415
15416/* parse the BIOS configuration and set up the alc_spec
15417 * return 1 if successful, 0 if the proper config is not found,
15418 * or a negative error code
15419 * Based on ALC880 version - had to change it to override
15420 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
15421static int alc861vd_parse_auto_config(struct hda_codec *codec)
15422{
15423 struct alc_spec *spec = codec->spec;
15424 int err;
15425 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
15426
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015427 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15428 alc861vd_ignore);
15429 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015430 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015431 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015432 return 0; /* can't find valid BIOS pin config */
15433
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015434 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
15435 if (err < 0)
15436 return err;
15437 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
15438 if (err < 0)
15439 return err;
15440 err = alc861vd_auto_create_extra_out(spec,
15441 spec->autocfg.speaker_pins[0],
15442 "Speaker");
15443 if (err < 0)
15444 return err;
15445 err = alc861vd_auto_create_extra_out(spec,
15446 spec->autocfg.hp_pins[0],
15447 "Headphone");
15448 if (err < 0)
15449 return err;
15450 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
15451 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015452 return err;
15453
15454 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15455
Takashi Iwai0852d7a2009-02-11 11:35:15 +010015456 if (spec->autocfg.dig_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015457 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
15458
Takashi Iwai603c4012008-07-30 15:01:44 +020015459 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010015460 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015461
Takashi Iwaid88897e2008-10-31 15:01:37 +010015462 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015463
15464 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015465 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015466
Takashi Iwai776e1842007-08-29 15:07:11 +020015467 err = alc_auto_add_mic_boost(codec);
15468 if (err < 0)
15469 return err;
15470
Takashi Iwai4a79ba32009-04-22 16:31:35 +020015471 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
15472
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015473 return 1;
15474}
15475
15476/* additional initialization for auto-configuration model */
15477static void alc861vd_auto_init(struct hda_codec *codec)
15478{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015479 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015480 alc861vd_auto_init_multi_out(codec);
15481 alc861vd_auto_init_hp_out(codec);
15482 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020015483 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015484 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020015485 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015486}
15487
15488static int patch_alc861vd(struct hda_codec *codec)
15489{
15490 struct alc_spec *spec;
15491 int err, board_config;
15492
15493 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15494 if (spec == NULL)
15495 return -ENOMEM;
15496
15497 codec->spec = spec;
15498
15499 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
15500 alc861vd_models,
15501 alc861vd_cfg_tbl);
15502
15503 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020015504 printk(KERN_INFO "hda_codec: Unknown model for %s, "
15505 "trying auto-probe from BIOS...\n", codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015506 board_config = ALC861VD_AUTO;
15507 }
15508
15509 if (board_config == ALC861VD_AUTO) {
15510 /* automatic parse from the BIOS config */
15511 err = alc861vd_parse_auto_config(codec);
15512 if (err < 0) {
15513 alc_free(codec);
15514 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015515 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015516 printk(KERN_INFO
15517 "hda_codec: Cannot set up configuration "
15518 "from BIOS. Using base mode...\n");
15519 board_config = ALC861VD_3ST;
15520 }
15521 }
15522
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015523 err = snd_hda_attach_beep_device(codec, 0x23);
15524 if (err < 0) {
15525 alc_free(codec);
15526 return err;
15527 }
15528
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015529 if (board_config != ALC861VD_AUTO)
15530 setup_preset(spec, &alc861vd_presets[board_config]);
15531
Kailang Yang2f893282008-05-27 12:14:47 +020015532 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020015533 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010015534 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020015535 }
15536
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015537 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
15538 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
15539
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015540 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
15541 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
15542
15543 spec->adc_nids = alc861vd_adc_nids;
15544 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +010015545 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015546
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015547 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015548 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015549
Takashi Iwai2134ea42008-01-10 16:53:55 +010015550 spec->vmaster_nid = 0x02;
15551
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015552 codec->patch_ops = alc_patch_ops;
15553
15554 if (board_config == ALC861VD_AUTO)
15555 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015556#ifdef CONFIG_SND_HDA_POWER_SAVE
15557 if (!spec->loopback.amplist)
15558 spec->loopback.amplist = alc861vd_loopbacks;
15559#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010015560 codec->proc_widget_hook = print_realtek_coef;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015561
15562 return 0;
15563}
15564
15565/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015566 * ALC662 support
15567 *
15568 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
15569 * configuration. Each pin widget can choose any input DACs and a mixer.
15570 * Each ADC is connected from a mixer of all inputs. This makes possible
15571 * 6-channel independent captures.
15572 *
15573 * In addition, an independent DAC for the multi-playback (not used in this
15574 * driver yet).
15575 */
15576#define ALC662_DIGOUT_NID 0x06
15577#define ALC662_DIGIN_NID 0x0a
15578
15579static hda_nid_t alc662_dac_nids[4] = {
15580 /* front, rear, clfe, rear_surr */
15581 0x02, 0x03, 0x04
15582};
15583
Kailang Yang622e84c2009-04-21 07:39:04 +020015584static hda_nid_t alc272_dac_nids[2] = {
15585 0x02, 0x03
15586};
15587
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015588static hda_nid_t alc662_adc_nids[1] = {
15589 /* ADC1-2 */
15590 0x09,
15591};
Takashi Iwaie1406342008-02-11 18:32:32 +010015592
Kailang Yang622e84c2009-04-21 07:39:04 +020015593static hda_nid_t alc272_adc_nids[1] = {
15594 /* ADC1-2 */
15595 0x08,
15596};
15597
Kailang Yang77a261b2008-02-19 11:38:05 +010015598static hda_nid_t alc662_capsrc_nids[1] = { 0x22 };
Kailang Yang622e84c2009-04-21 07:39:04 +020015599static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
15600
Takashi Iwaie1406342008-02-11 18:32:32 +010015601
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015602/* input MUX */
15603/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015604static struct hda_input_mux alc662_capture_source = {
15605 .num_items = 4,
15606 .items = {
15607 { "Mic", 0x0 },
15608 { "Front Mic", 0x1 },
15609 { "Line", 0x2 },
15610 { "CD", 0x4 },
15611 },
15612};
15613
15614static struct hda_input_mux alc662_lenovo_101e_capture_source = {
15615 .num_items = 2,
15616 .items = {
15617 { "Mic", 0x1 },
15618 { "Line", 0x2 },
15619 },
15620};
Kailang Yang291702f2007-10-16 14:28:03 +020015621
15622static struct hda_input_mux alc662_eeepc_capture_source = {
15623 .num_items = 2,
15624 .items = {
15625 { "i-Mic", 0x1 },
15626 { "e-Mic", 0x0 },
15627 },
15628};
15629
Kailang Yang6dda9f42008-05-27 12:05:31 +020015630static struct hda_input_mux alc663_capture_source = {
15631 .num_items = 3,
15632 .items = {
15633 { "Mic", 0x0 },
15634 { "Front Mic", 0x1 },
15635 { "Line", 0x2 },
15636 },
15637};
15638
15639static struct hda_input_mux alc663_m51va_capture_source = {
15640 .num_items = 2,
15641 .items = {
15642 { "Ext-Mic", 0x0 },
15643 { "D-Mic", 0x9 },
15644 },
15645};
15646
Chris Pockelé9541ba12009-05-12 08:08:53 +020015647#if 1 /* set to 0 for testing other input sources below */
15648static struct hda_input_mux alc272_nc10_capture_source = {
15649 .num_items = 2,
15650 .items = {
15651 { "Autoselect Mic", 0x0 },
15652 { "Internal Mic", 0x1 },
15653 },
15654};
15655#else
15656static struct hda_input_mux alc272_nc10_capture_source = {
15657 .num_items = 16,
15658 .items = {
15659 { "Autoselect Mic", 0x0 },
15660 { "Internal Mic", 0x1 },
15661 { "In-0x02", 0x2 },
15662 { "In-0x03", 0x3 },
15663 { "In-0x04", 0x4 },
15664 { "In-0x05", 0x5 },
15665 { "In-0x06", 0x6 },
15666 { "In-0x07", 0x7 },
15667 { "In-0x08", 0x8 },
15668 { "In-0x09", 0x9 },
15669 { "In-0x0a", 0x0a },
15670 { "In-0x0b", 0x0b },
15671 { "In-0x0c", 0x0c },
15672 { "In-0x0d", 0x0d },
15673 { "In-0x0e", 0x0e },
15674 { "In-0x0f", 0x0f },
15675 },
15676};
15677#endif
15678
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015679/*
15680 * 2ch mode
15681 */
15682static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
15683 { 2, NULL }
15684};
15685
15686/*
15687 * 2ch mode
15688 */
15689static struct hda_verb alc662_3ST_ch2_init[] = {
15690 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
15691 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15692 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
15693 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15694 { } /* end */
15695};
15696
15697/*
15698 * 6ch mode
15699 */
15700static struct hda_verb alc662_3ST_ch6_init[] = {
15701 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15702 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15703 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
15704 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15705 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15706 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
15707 { } /* end */
15708};
15709
15710static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
15711 { 2, alc662_3ST_ch2_init },
15712 { 6, alc662_3ST_ch6_init },
15713};
15714
15715/*
15716 * 2ch mode
15717 */
15718static struct hda_verb alc662_sixstack_ch6_init[] = {
15719 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15720 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15721 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15722 { } /* end */
15723};
15724
15725/*
15726 * 6ch mode
15727 */
15728static struct hda_verb alc662_sixstack_ch8_init[] = {
15729 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15730 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15731 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15732 { } /* end */
15733};
15734
15735static struct hda_channel_mode alc662_5stack_modes[2] = {
15736 { 2, alc662_sixstack_ch6_init },
15737 { 6, alc662_sixstack_ch8_init },
15738};
15739
15740/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15741 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15742 */
15743
15744static struct snd_kcontrol_new alc662_base_mixer[] = {
15745 /* output mixer control */
15746 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015747 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015748 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015749 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015750 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15751 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015752 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15753 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015754 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15755
15756 /*Input mixer control */
15757 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
15758 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
15759 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
15760 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
15761 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
15762 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
15763 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
15764 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015765 { } /* end */
15766};
15767
15768static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
15769 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015770 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015771 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15772 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15773 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15774 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15775 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15776 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15777 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15778 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15779 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015780 { } /* end */
15781};
15782
15783static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
15784 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015785 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015786 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015787 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015788 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15789 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015790 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15791 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015792 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15793 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15794 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15795 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15796 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15797 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15798 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15799 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15800 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015801 { } /* end */
15802};
15803
15804static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
15805 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15806 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010015807 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15808 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015809 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15810 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15811 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15812 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15813 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015814 { } /* end */
15815};
15816
Kailang Yang291702f2007-10-16 14:28:03 +020015817static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020015818 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15819 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020015820
15821 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
15822 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15823 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15824
15825 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
15826 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15827 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15828 { } /* end */
15829};
15830
Kailang Yang8c427222008-01-10 13:03:59 +010015831static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020015832 ALC262_HIPPO_MASTER_SWITCH,
15833 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015834 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015835 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15836 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015837 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
15838 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15839 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15840 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15841 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15842 { } /* end */
15843};
15844
Kailang Yangf1d4e282008-08-26 14:03:29 +020015845static struct hda_bind_ctls alc663_asus_bind_master_vol = {
15846 .ops = &snd_hda_bind_vol,
15847 .values = {
15848 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15849 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
15850 0
15851 },
15852};
15853
15854static struct hda_bind_ctls alc663_asus_one_bind_switch = {
15855 .ops = &snd_hda_bind_sw,
15856 .values = {
15857 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15858 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15859 0
15860 },
15861};
15862
Kailang Yang6dda9f42008-05-27 12:05:31 +020015863static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015864 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15865 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
15866 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15867 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15868 { } /* end */
15869};
15870
15871static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
15872 .ops = &snd_hda_bind_sw,
15873 .values = {
15874 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15875 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15876 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15877 0
15878 },
15879};
15880
15881static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
15882 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15883 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
15884 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15885 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15886 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15887 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15888
15889 { } /* end */
15890};
15891
15892static struct hda_bind_ctls alc663_asus_four_bind_switch = {
15893 .ops = &snd_hda_bind_sw,
15894 .values = {
15895 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15896 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15897 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
15898 0
15899 },
15900};
15901
15902static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
15903 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15904 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
15905 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15906 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15907 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15908 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15909 { } /* end */
15910};
15911
15912static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020015913 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15914 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015915 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15916 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15917 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15918 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15919 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15920 { } /* end */
15921};
15922
15923static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
15924 .ops = &snd_hda_bind_vol,
15925 .values = {
15926 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15927 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
15928 0
15929 },
15930};
15931
15932static struct hda_bind_ctls alc663_asus_two_bind_switch = {
15933 .ops = &snd_hda_bind_sw,
15934 .values = {
15935 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15936 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
15937 0
15938 },
15939};
15940
15941static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
15942 HDA_BIND_VOL("Master Playback Volume",
15943 &alc663_asus_two_bind_master_vol),
15944 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15945 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015946 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15947 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15948 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015949 { } /* end */
15950};
15951
15952static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
15953 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15954 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15955 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15956 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15957 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15958 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015959 { } /* end */
15960};
15961
15962static struct snd_kcontrol_new alc663_g71v_mixer[] = {
15963 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15964 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15965 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15966 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15967 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15968
15969 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15970 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15971 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15972 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15973 { } /* end */
15974};
15975
15976static struct snd_kcontrol_new alc663_g50v_mixer[] = {
15977 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15978 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15979 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15980
15981 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15982 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15983 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15984 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15985 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15986 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15987 { } /* end */
15988};
15989
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015990static struct snd_kcontrol_new alc662_chmode_mixer[] = {
15991 {
15992 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15993 .name = "Channel Mode",
15994 .info = alc_ch_mode_info,
15995 .get = alc_ch_mode_get,
15996 .put = alc_ch_mode_put,
15997 },
15998 { } /* end */
15999};
16000
16001static struct hda_verb alc662_init_verbs[] = {
16002 /* ADC: mute amp left and right */
16003 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16004 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16005 /* Front mixer: unmute input/output amp left and right (volume = 0) */
16006
Takashi Iwaicb53c622007-08-10 17:21:45 +020016007 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16008 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16009 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16010 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16011 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016012
Kailang Yangb60dd392007-09-20 12:50:29 +020016013 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16014 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16015 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16016 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16017 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16018 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016019
16020 /* Front Pin: output 0 (0x0c) */
16021 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16022 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16023
16024 /* Rear Pin: output 1 (0x0d) */
16025 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16026 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16027
16028 /* CLFE Pin: output 2 (0x0e) */
16029 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16030 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16031
16032 /* Mic (rear) pin: input vref at 80% */
16033 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16034 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16035 /* Front Mic pin: input vref at 80% */
16036 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16037 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16038 /* Line In pin: input */
16039 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16040 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16041 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16042 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16043 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16044 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16045 /* CD pin widget for input */
16046 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16047
16048 /* FIXME: use matrix-type input source selection */
16049 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
16050 /* Input mixer */
16051 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020016052 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016053
16054 /* always trun on EAPD */
16055 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16056 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
16057
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016058 { }
16059};
16060
16061static struct hda_verb alc662_sue_init_verbs[] = {
16062 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16063 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020016064 {}
16065};
16066
16067static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
16068 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16069 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16070 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016071};
16072
Kailang Yang8c427222008-01-10 13:03:59 +010016073/* Set Unsolicited Event*/
16074static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
16075 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16076 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16077 {}
16078};
16079
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016080/*
16081 * generic initialization of ADC, input mixers and output mixers
16082 */
16083static struct hda_verb alc662_auto_init_verbs[] = {
16084 /*
16085 * Unmute ADC and set the default input to mic-in
16086 */
16087 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16088 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16089
16090 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
16091 * mixer widget
16092 * Note: PASD motherboards uses the Line In 2 as the input for front
16093 * panel mic (mic 2)
16094 */
16095 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020016096 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16097 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16098 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16099 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16100 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016101
16102 /*
16103 * Set up output mixers (0x0c - 0x0f)
16104 */
16105 /* set vol=0 to output mixers */
16106 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16107 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16108 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16109
16110 /* set up input amps for analog loopback */
16111 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020016112 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16113 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16114 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16115 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16116 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16117 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016118
16119
16120 /* FIXME: use matrix-type input source selection */
16121 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
16122 /* Input mixer */
16123 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020016124 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016125 { }
16126};
16127
Takashi Iwai24fb9172008-09-02 14:48:20 +020016128/* additional verbs for ALC663 */
16129static struct hda_verb alc663_auto_init_verbs[] = {
16130 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16131 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16132 { }
16133};
16134
Kailang Yang6dda9f42008-05-27 12:05:31 +020016135static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020016136 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16137 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016138 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16139 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020016140 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16141 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16142 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016143 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16144 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16145 {}
16146};
16147
Kailang Yangf1d4e282008-08-26 14:03:29 +020016148static struct hda_verb alc663_21jd_amic_init_verbs[] = {
16149 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16150 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16151 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16152 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16153 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16154 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16155 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16156 {}
16157};
16158
16159static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
16160 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16161 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16162 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16163 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16164 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16165 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16166 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16167 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16168 {}
16169};
16170
16171static struct hda_verb alc663_15jd_amic_init_verbs[] = {
16172 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16173 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16174 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16175 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16176 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16177 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16178 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16179 {}
16180};
16181
16182static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
16183 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16184 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16185 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16186 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16187 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16188 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16189 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16190 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16191 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16192 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16193 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16194 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16195 {}
16196};
16197
16198static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
16199 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16200 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16201 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16202 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16203 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16204 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16205 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16206 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16207 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16208 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16209 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16210 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16211 {}
16212};
16213
Kailang Yang6dda9f42008-05-27 12:05:31 +020016214static struct hda_verb alc663_g71v_init_verbs[] = {
16215 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16216 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
16217 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
16218
16219 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16220 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16221 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16222
16223 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16224 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
16225 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
16226 {}
16227};
16228
16229static struct hda_verb alc663_g50v_init_verbs[] = {
16230 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16231 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16232 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16233
16234 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16235 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16236 {}
16237};
16238
Kailang Yangf1d4e282008-08-26 14:03:29 +020016239static struct hda_verb alc662_ecs_init_verbs[] = {
16240 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
16241 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16242 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16243 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16244 {}
16245};
16246
Kailang Yang622e84c2009-04-21 07:39:04 +020016247static struct hda_verb alc272_dell_zm1_init_verbs[] = {
16248 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16249 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16250 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16251 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16252 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16253 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16254 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16255 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16256 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16257 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16258 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16259 {}
16260};
16261
16262static struct hda_verb alc272_dell_init_verbs[] = {
16263 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16264 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16265 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16266 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16267 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16268 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16269 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16270 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16271 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16272 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16273 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16274 {}
16275};
16276
Kailang Yangf1d4e282008-08-26 14:03:29 +020016277static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
16278 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
16279 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
16280 { } /* end */
16281};
16282
Kailang Yang622e84c2009-04-21 07:39:04 +020016283static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
16284 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
16285 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
16286 { } /* end */
16287};
16288
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016289static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
16290{
16291 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016292 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016293
16294 present = snd_hda_codec_read(codec, 0x14, 0,
16295 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020016296 bits = present ? HDA_AMP_MUTE : 0;
16297 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16298 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016299}
16300
16301static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
16302{
16303 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016304 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016305
16306 present = snd_hda_codec_read(codec, 0x1b, 0,
16307 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020016308 bits = present ? HDA_AMP_MUTE : 0;
16309 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16310 HDA_AMP_MUTE, bits);
16311 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16312 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016313}
16314
16315static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
16316 unsigned int res)
16317{
16318 if ((res >> 26) == ALC880_HP_EVENT)
16319 alc662_lenovo_101e_all_automute(codec);
16320 if ((res >> 26) == ALC880_FRONT_EVENT)
16321 alc662_lenovo_101e_ispeaker_automute(codec);
16322}
16323
Kailang Yang291702f2007-10-16 14:28:03 +020016324static void alc662_eeepc_mic_automute(struct hda_codec *codec)
16325{
16326 unsigned int present;
16327
16328 present = snd_hda_codec_read(codec, 0x18, 0,
16329 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
16330 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16331 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
16332 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16333 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
16334 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16335 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
16336 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16337 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
16338}
16339
16340/* unsolicited event for HP jack sensing */
16341static void alc662_eeepc_unsol_event(struct hda_codec *codec,
16342 unsigned int res)
16343{
Kailang Yang291702f2007-10-16 14:28:03 +020016344 if ((res >> 26) == ALC880_MIC_EVENT)
16345 alc662_eeepc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020016346 else
16347 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020016348}
16349
16350static void alc662_eeepc_inithook(struct hda_codec *codec)
16351{
Takashi Iwai42171c12009-05-08 14:11:43 +020016352 alc262_hippo1_init_hook(codec);
Kailang Yang291702f2007-10-16 14:28:03 +020016353 alc662_eeepc_mic_automute(codec);
16354}
16355
Kailang Yang8c427222008-01-10 13:03:59 +010016356static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
16357{
Takashi Iwai42171c12009-05-08 14:11:43 +020016358 struct alc_spec *spec = codec->spec;
16359
16360 spec->autocfg.hp_pins[0] = 0x14;
16361 spec->autocfg.speaker_pins[0] = 0x1b;
16362 alc262_hippo_master_update(codec);
Kailang Yang8c427222008-01-10 13:03:59 +010016363}
16364
Kailang Yang6dda9f42008-05-27 12:05:31 +020016365static void alc663_m51va_speaker_automute(struct hda_codec *codec)
16366{
16367 unsigned int present;
16368 unsigned char bits;
16369
16370 present = snd_hda_codec_read(codec, 0x21, 0,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016371 AC_VERB_GET_PIN_SENSE, 0)
16372 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020016373 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020016374 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16375 AMP_IN_MUTE(0), bits);
16376 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16377 AMP_IN_MUTE(0), bits);
16378}
16379
16380static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
16381{
16382 unsigned int present;
16383 unsigned char bits;
16384
16385 present = snd_hda_codec_read(codec, 0x21, 0,
16386 AC_VERB_GET_PIN_SENSE, 0)
16387 & AC_PINSENSE_PRESENCE;
16388 bits = present ? HDA_AMP_MUTE : 0;
16389 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16390 AMP_IN_MUTE(0), bits);
16391 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16392 AMP_IN_MUTE(0), bits);
16393 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16394 AMP_IN_MUTE(0), bits);
16395 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16396 AMP_IN_MUTE(0), bits);
16397}
16398
16399static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
16400{
16401 unsigned int present;
16402 unsigned char bits;
16403
16404 present = snd_hda_codec_read(codec, 0x15, 0,
16405 AC_VERB_GET_PIN_SENSE, 0)
16406 & AC_PINSENSE_PRESENCE;
16407 bits = present ? HDA_AMP_MUTE : 0;
16408 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16409 AMP_IN_MUTE(0), bits);
16410 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16411 AMP_IN_MUTE(0), bits);
16412 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16413 AMP_IN_MUTE(0), bits);
16414 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16415 AMP_IN_MUTE(0), bits);
16416}
16417
16418static void alc662_f5z_speaker_automute(struct hda_codec *codec)
16419{
16420 unsigned int present;
16421 unsigned char bits;
16422
16423 present = snd_hda_codec_read(codec, 0x1b, 0,
16424 AC_VERB_GET_PIN_SENSE, 0)
16425 & AC_PINSENSE_PRESENCE;
16426 bits = present ? 0 : PIN_OUT;
16427 snd_hda_codec_write(codec, 0x14, 0,
16428 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
16429}
16430
16431static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
16432{
16433 unsigned int present1, present2;
16434
16435 present1 = snd_hda_codec_read(codec, 0x21, 0,
16436 AC_VERB_GET_PIN_SENSE, 0)
16437 & AC_PINSENSE_PRESENCE;
16438 present2 = snd_hda_codec_read(codec, 0x15, 0,
16439 AC_VERB_GET_PIN_SENSE, 0)
16440 & AC_PINSENSE_PRESENCE;
16441
16442 if (present1 || present2) {
16443 snd_hda_codec_write_cache(codec, 0x14, 0,
16444 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16445 } else {
16446 snd_hda_codec_write_cache(codec, 0x14, 0,
16447 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16448 }
16449}
16450
16451static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
16452{
16453 unsigned int present1, present2;
16454
16455 present1 = snd_hda_codec_read(codec, 0x1b, 0,
16456 AC_VERB_GET_PIN_SENSE, 0)
16457 & AC_PINSENSE_PRESENCE;
16458 present2 = snd_hda_codec_read(codec, 0x15, 0,
16459 AC_VERB_GET_PIN_SENSE, 0)
16460 & AC_PINSENSE_PRESENCE;
16461
16462 if (present1 || present2) {
16463 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16464 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16465 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16466 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16467 } else {
16468 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16469 AMP_IN_MUTE(0), 0);
16470 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16471 AMP_IN_MUTE(0), 0);
16472 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020016473}
16474
16475static void alc663_m51va_mic_automute(struct hda_codec *codec)
16476{
16477 unsigned int present;
16478
16479 present = snd_hda_codec_read(codec, 0x18, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020016480 AC_VERB_GET_PIN_SENSE, 0)
16481 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020016482 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016483 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016484 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016485 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016486 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016487 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016488 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016489 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016490}
16491
16492static void alc663_m51va_unsol_event(struct hda_codec *codec,
16493 unsigned int res)
16494{
16495 switch (res >> 26) {
16496 case ALC880_HP_EVENT:
16497 alc663_m51va_speaker_automute(codec);
16498 break;
16499 case ALC880_MIC_EVENT:
16500 alc663_m51va_mic_automute(codec);
16501 break;
16502 }
16503}
16504
16505static void alc663_m51va_inithook(struct hda_codec *codec)
16506{
16507 alc663_m51va_speaker_automute(codec);
16508 alc663_m51va_mic_automute(codec);
16509}
16510
Kailang Yangf1d4e282008-08-26 14:03:29 +020016511/* ***************** Mode1 ******************************/
16512static void alc663_mode1_unsol_event(struct hda_codec *codec,
16513 unsigned int res)
16514{
16515 switch (res >> 26) {
16516 case ALC880_HP_EVENT:
16517 alc663_m51va_speaker_automute(codec);
16518 break;
16519 case ALC880_MIC_EVENT:
16520 alc662_eeepc_mic_automute(codec);
16521 break;
16522 }
16523}
16524
16525static void alc663_mode1_inithook(struct hda_codec *codec)
16526{
16527 alc663_m51va_speaker_automute(codec);
16528 alc662_eeepc_mic_automute(codec);
16529}
16530/* ***************** Mode2 ******************************/
16531static void alc662_mode2_unsol_event(struct hda_codec *codec,
16532 unsigned int res)
16533{
16534 switch (res >> 26) {
16535 case ALC880_HP_EVENT:
16536 alc662_f5z_speaker_automute(codec);
16537 break;
16538 case ALC880_MIC_EVENT:
16539 alc662_eeepc_mic_automute(codec);
16540 break;
16541 }
16542}
16543
16544static void alc662_mode2_inithook(struct hda_codec *codec)
16545{
16546 alc662_f5z_speaker_automute(codec);
16547 alc662_eeepc_mic_automute(codec);
16548}
16549/* ***************** Mode3 ******************************/
16550static void alc663_mode3_unsol_event(struct hda_codec *codec,
16551 unsigned int res)
16552{
16553 switch (res >> 26) {
16554 case ALC880_HP_EVENT:
16555 alc663_two_hp_m1_speaker_automute(codec);
16556 break;
16557 case ALC880_MIC_EVENT:
16558 alc662_eeepc_mic_automute(codec);
16559 break;
16560 }
16561}
16562
16563static void alc663_mode3_inithook(struct hda_codec *codec)
16564{
16565 alc663_two_hp_m1_speaker_automute(codec);
16566 alc662_eeepc_mic_automute(codec);
16567}
16568/* ***************** Mode4 ******************************/
16569static void alc663_mode4_unsol_event(struct hda_codec *codec,
16570 unsigned int res)
16571{
16572 switch (res >> 26) {
16573 case ALC880_HP_EVENT:
16574 alc663_21jd_two_speaker_automute(codec);
16575 break;
16576 case ALC880_MIC_EVENT:
16577 alc662_eeepc_mic_automute(codec);
16578 break;
16579 }
16580}
16581
16582static void alc663_mode4_inithook(struct hda_codec *codec)
16583{
16584 alc663_21jd_two_speaker_automute(codec);
16585 alc662_eeepc_mic_automute(codec);
16586}
16587/* ***************** Mode5 ******************************/
16588static void alc663_mode5_unsol_event(struct hda_codec *codec,
16589 unsigned int res)
16590{
16591 switch (res >> 26) {
16592 case ALC880_HP_EVENT:
16593 alc663_15jd_two_speaker_automute(codec);
16594 break;
16595 case ALC880_MIC_EVENT:
16596 alc662_eeepc_mic_automute(codec);
16597 break;
16598 }
16599}
16600
16601static void alc663_mode5_inithook(struct hda_codec *codec)
16602{
16603 alc663_15jd_two_speaker_automute(codec);
16604 alc662_eeepc_mic_automute(codec);
16605}
16606/* ***************** Mode6 ******************************/
16607static void alc663_mode6_unsol_event(struct hda_codec *codec,
16608 unsigned int res)
16609{
16610 switch (res >> 26) {
16611 case ALC880_HP_EVENT:
16612 alc663_two_hp_m2_speaker_automute(codec);
16613 break;
16614 case ALC880_MIC_EVENT:
16615 alc662_eeepc_mic_automute(codec);
16616 break;
16617 }
16618}
16619
16620static void alc663_mode6_inithook(struct hda_codec *codec)
16621{
16622 alc663_two_hp_m2_speaker_automute(codec);
16623 alc662_eeepc_mic_automute(codec);
16624}
16625
Kailang Yang6dda9f42008-05-27 12:05:31 +020016626static void alc663_g71v_hp_automute(struct hda_codec *codec)
16627{
16628 unsigned int present;
16629 unsigned char bits;
16630
16631 present = snd_hda_codec_read(codec, 0x21, 0,
16632 AC_VERB_GET_PIN_SENSE, 0)
16633 & AC_PINSENSE_PRESENCE;
16634 bits = present ? HDA_AMP_MUTE : 0;
16635 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16636 HDA_AMP_MUTE, bits);
16637 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16638 HDA_AMP_MUTE, bits);
16639}
16640
16641static void alc663_g71v_front_automute(struct hda_codec *codec)
16642{
16643 unsigned int present;
16644 unsigned char bits;
16645
16646 present = snd_hda_codec_read(codec, 0x15, 0,
16647 AC_VERB_GET_PIN_SENSE, 0)
16648 & AC_PINSENSE_PRESENCE;
16649 bits = present ? HDA_AMP_MUTE : 0;
16650 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16651 HDA_AMP_MUTE, bits);
16652}
16653
16654static void alc663_g71v_unsol_event(struct hda_codec *codec,
16655 unsigned int res)
16656{
16657 switch (res >> 26) {
16658 case ALC880_HP_EVENT:
16659 alc663_g71v_hp_automute(codec);
16660 break;
16661 case ALC880_FRONT_EVENT:
16662 alc663_g71v_front_automute(codec);
16663 break;
16664 case ALC880_MIC_EVENT:
16665 alc662_eeepc_mic_automute(codec);
16666 break;
16667 }
16668}
16669
16670static void alc663_g71v_inithook(struct hda_codec *codec)
16671{
16672 alc663_g71v_front_automute(codec);
16673 alc663_g71v_hp_automute(codec);
16674 alc662_eeepc_mic_automute(codec);
16675}
16676
16677static void alc663_g50v_unsol_event(struct hda_codec *codec,
16678 unsigned int res)
16679{
16680 switch (res >> 26) {
16681 case ALC880_HP_EVENT:
16682 alc663_m51va_speaker_automute(codec);
16683 break;
16684 case ALC880_MIC_EVENT:
16685 alc662_eeepc_mic_automute(codec);
16686 break;
16687 }
16688}
16689
16690static void alc663_g50v_inithook(struct hda_codec *codec)
16691{
16692 alc663_m51va_speaker_automute(codec);
16693 alc662_eeepc_mic_automute(codec);
16694}
16695
Kailang Yangf1d4e282008-08-26 14:03:29 +020016696static struct snd_kcontrol_new alc662_ecs_mixer[] = {
16697 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020016698 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016699
16700 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
16701 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
16702 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
16703
16704 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16705 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16706 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16707 { } /* end */
16708};
16709
Chris Pockelé9541ba12009-05-12 08:08:53 +020016710static struct snd_kcontrol_new alc272_nc10_mixer[] = {
16711 /* Master Playback automatically created from Speaker and Headphone */
16712 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16713 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16714 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16715 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16716
16717 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16718 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16719 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
16720
16721 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16722 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16723 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
16724 { } /* end */
16725};
16726
Takashi Iwaicb53c622007-08-10 17:21:45 +020016727#ifdef CONFIG_SND_HDA_POWER_SAVE
16728#define alc662_loopbacks alc880_loopbacks
16729#endif
16730
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016731
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016732/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016733#define alc662_pcm_analog_playback alc880_pcm_analog_playback
16734#define alc662_pcm_analog_capture alc880_pcm_analog_capture
16735#define alc662_pcm_digital_playback alc880_pcm_digital_playback
16736#define alc662_pcm_digital_capture alc880_pcm_digital_capture
16737
16738/*
16739 * configuration and preset
16740 */
16741static const char *alc662_models[ALC662_MODEL_LAST] = {
16742 [ALC662_3ST_2ch_DIG] = "3stack-dig",
16743 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
16744 [ALC662_3ST_6ch] = "3stack-6ch",
16745 [ALC662_5ST_DIG] = "6stack-dig",
16746 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020016747 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010016748 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016749 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020016750 [ALC663_ASUS_M51VA] = "m51va",
16751 [ALC663_ASUS_G71V] = "g71v",
16752 [ALC663_ASUS_H13] = "h13",
16753 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016754 [ALC663_ASUS_MODE1] = "asus-mode1",
16755 [ALC662_ASUS_MODE2] = "asus-mode2",
16756 [ALC663_ASUS_MODE3] = "asus-mode3",
16757 [ALC663_ASUS_MODE4] = "asus-mode4",
16758 [ALC663_ASUS_MODE5] = "asus-mode5",
16759 [ALC663_ASUS_MODE6] = "asus-mode6",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020016760 [ALC272_DELL] = "dell",
16761 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020016762 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016763 [ALC662_AUTO] = "auto",
16764};
16765
16766static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010016767 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020016768 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
16769 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016770 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
16771 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
16772 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
16773 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
16774 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
16775 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
16776 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
16777 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
16778 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
16779 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
16780 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
16781 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016782 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
16783 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
16784 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016785 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
16786 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
16787 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
16788 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016789 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016790 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
16791 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016792 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016793 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
16794 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
16795 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020016796 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
16797 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
16798 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016799 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
16800 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
16801 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016802 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016803 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
16804 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020016805 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016806 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020016807 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016808 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
16809 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
16810 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016811 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016812 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
16813 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010016814 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020016815 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010016816 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016817 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030016818 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
16819 ALC662_3ST_6ch_DIG),
Chris Pockelé9541ba12009-05-12 08:08:53 +020016820 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030016821 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
16822 ALC662_3ST_6ch_DIG),
Vedran Miletic19c009a2008-09-29 20:29:25 +020016823 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020016824 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016825 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020016826 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020016827 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016828 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
16829 ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016830 {}
16831};
16832
16833static struct alc_config_preset alc662_presets[] = {
16834 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016835 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016836 .init_verbs = { alc662_init_verbs },
16837 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16838 .dac_nids = alc662_dac_nids,
16839 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016840 .dig_in_nid = ALC662_DIGIN_NID,
16841 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16842 .channel_mode = alc662_3ST_2ch_modes,
16843 .input_mux = &alc662_capture_source,
16844 },
16845 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016846 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016847 .init_verbs = { alc662_init_verbs },
16848 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16849 .dac_nids = alc662_dac_nids,
16850 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016851 .dig_in_nid = ALC662_DIGIN_NID,
16852 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16853 .channel_mode = alc662_3ST_6ch_modes,
16854 .need_dac_fix = 1,
16855 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016856 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016857 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016858 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016859 .init_verbs = { alc662_init_verbs },
16860 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16861 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016862 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16863 .channel_mode = alc662_3ST_6ch_modes,
16864 .need_dac_fix = 1,
16865 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016866 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016867 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016868 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016869 .init_verbs = { alc662_init_verbs },
16870 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16871 .dac_nids = alc662_dac_nids,
16872 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016873 .dig_in_nid = ALC662_DIGIN_NID,
16874 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
16875 .channel_mode = alc662_5stack_modes,
16876 .input_mux = &alc662_capture_source,
16877 },
16878 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016879 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016880 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
16881 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16882 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016883 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16884 .channel_mode = alc662_3ST_2ch_modes,
16885 .input_mux = &alc662_lenovo_101e_capture_source,
16886 .unsol_event = alc662_lenovo_101e_unsol_event,
16887 .init_hook = alc662_lenovo_101e_all_automute,
16888 },
Kailang Yang291702f2007-10-16 14:28:03 +020016889 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016890 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020016891 .init_verbs = { alc662_init_verbs,
16892 alc662_eeepc_sue_init_verbs },
16893 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16894 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020016895 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16896 .channel_mode = alc662_3ST_2ch_modes,
16897 .input_mux = &alc662_eeepc_capture_source,
16898 .unsol_event = alc662_eeepc_unsol_event,
16899 .init_hook = alc662_eeepc_inithook,
16900 },
Kailang Yang8c427222008-01-10 13:03:59 +010016901 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016902 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010016903 alc662_chmode_mixer },
16904 .init_verbs = { alc662_init_verbs,
16905 alc662_eeepc_ep20_sue_init_verbs },
16906 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16907 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010016908 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16909 .channel_mode = alc662_3ST_6ch_modes,
16910 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020016911 .unsol_event = alc662_eeepc_unsol_event,
Kailang Yang8c427222008-01-10 13:03:59 +010016912 .init_hook = alc662_eeepc_ep20_inithook,
16913 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016914 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016915 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016916 .init_verbs = { alc662_init_verbs,
16917 alc662_ecs_init_verbs },
16918 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16919 .dac_nids = alc662_dac_nids,
16920 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16921 .channel_mode = alc662_3ST_2ch_modes,
16922 .input_mux = &alc662_eeepc_capture_source,
16923 .unsol_event = alc662_eeepc_unsol_event,
16924 .init_hook = alc662_eeepc_inithook,
16925 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016926 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016927 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016928 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16929 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16930 .dac_nids = alc662_dac_nids,
16931 .dig_out_nid = ALC662_DIGOUT_NID,
16932 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16933 .channel_mode = alc662_3ST_2ch_modes,
16934 .input_mux = &alc663_m51va_capture_source,
16935 .unsol_event = alc663_m51va_unsol_event,
16936 .init_hook = alc663_m51va_inithook,
16937 },
16938 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016939 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016940 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
16941 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16942 .dac_nids = alc662_dac_nids,
16943 .dig_out_nid = ALC662_DIGOUT_NID,
16944 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16945 .channel_mode = alc662_3ST_2ch_modes,
16946 .input_mux = &alc662_eeepc_capture_source,
16947 .unsol_event = alc663_g71v_unsol_event,
16948 .init_hook = alc663_g71v_inithook,
16949 },
16950 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016951 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016952 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16953 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16954 .dac_nids = alc662_dac_nids,
16955 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16956 .channel_mode = alc662_3ST_2ch_modes,
16957 .input_mux = &alc663_m51va_capture_source,
16958 .unsol_event = alc663_m51va_unsol_event,
16959 .init_hook = alc663_m51va_inithook,
16960 },
16961 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016962 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016963 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
16964 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16965 .dac_nids = alc662_dac_nids,
16966 .dig_out_nid = ALC662_DIGOUT_NID,
16967 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16968 .channel_mode = alc662_3ST_6ch_modes,
16969 .input_mux = &alc663_capture_source,
16970 .unsol_event = alc663_g50v_unsol_event,
16971 .init_hook = alc663_g50v_inithook,
16972 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016973 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016974 .mixers = { alc663_m51va_mixer },
16975 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016976 .init_verbs = { alc662_init_verbs,
16977 alc663_21jd_amic_init_verbs },
16978 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16979 .hp_nid = 0x03,
16980 .dac_nids = alc662_dac_nids,
16981 .dig_out_nid = ALC662_DIGOUT_NID,
16982 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16983 .channel_mode = alc662_3ST_2ch_modes,
16984 .input_mux = &alc662_eeepc_capture_source,
16985 .unsol_event = alc663_mode1_unsol_event,
16986 .init_hook = alc663_mode1_inithook,
16987 },
16988 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016989 .mixers = { alc662_1bjd_mixer },
16990 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016991 .init_verbs = { alc662_init_verbs,
16992 alc662_1bjd_amic_init_verbs },
16993 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16994 .dac_nids = alc662_dac_nids,
16995 .dig_out_nid = ALC662_DIGOUT_NID,
16996 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16997 .channel_mode = alc662_3ST_2ch_modes,
16998 .input_mux = &alc662_eeepc_capture_source,
16999 .unsol_event = alc662_mode2_unsol_event,
17000 .init_hook = alc662_mode2_inithook,
17001 },
17002 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017003 .mixers = { alc663_two_hp_m1_mixer },
17004 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017005 .init_verbs = { alc662_init_verbs,
17006 alc663_two_hp_amic_m1_init_verbs },
17007 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17008 .hp_nid = 0x03,
17009 .dac_nids = alc662_dac_nids,
17010 .dig_out_nid = ALC662_DIGOUT_NID,
17011 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17012 .channel_mode = alc662_3ST_2ch_modes,
17013 .input_mux = &alc662_eeepc_capture_source,
17014 .unsol_event = alc663_mode3_unsol_event,
17015 .init_hook = alc663_mode3_inithook,
17016 },
17017 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017018 .mixers = { alc663_asus_21jd_clfe_mixer },
17019 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017020 .init_verbs = { alc662_init_verbs,
17021 alc663_21jd_amic_init_verbs},
17022 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17023 .hp_nid = 0x03,
17024 .dac_nids = alc662_dac_nids,
17025 .dig_out_nid = ALC662_DIGOUT_NID,
17026 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17027 .channel_mode = alc662_3ST_2ch_modes,
17028 .input_mux = &alc662_eeepc_capture_source,
17029 .unsol_event = alc663_mode4_unsol_event,
17030 .init_hook = alc663_mode4_inithook,
17031 },
17032 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017033 .mixers = { alc663_asus_15jd_clfe_mixer },
17034 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017035 .init_verbs = { alc662_init_verbs,
17036 alc663_15jd_amic_init_verbs },
17037 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17038 .hp_nid = 0x03,
17039 .dac_nids = alc662_dac_nids,
17040 .dig_out_nid = ALC662_DIGOUT_NID,
17041 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17042 .channel_mode = alc662_3ST_2ch_modes,
17043 .input_mux = &alc662_eeepc_capture_source,
17044 .unsol_event = alc663_mode5_unsol_event,
17045 .init_hook = alc663_mode5_inithook,
17046 },
17047 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017048 .mixers = { alc663_two_hp_m2_mixer },
17049 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017050 .init_verbs = { alc662_init_verbs,
17051 alc663_two_hp_amic_m2_init_verbs },
17052 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17053 .hp_nid = 0x03,
17054 .dac_nids = alc662_dac_nids,
17055 .dig_out_nid = ALC662_DIGOUT_NID,
17056 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17057 .channel_mode = alc662_3ST_2ch_modes,
17058 .input_mux = &alc662_eeepc_capture_source,
17059 .unsol_event = alc663_mode6_unsol_event,
17060 .init_hook = alc663_mode6_inithook,
17061 },
Kailang Yang622e84c2009-04-21 07:39:04 +020017062 [ALC272_DELL] = {
17063 .mixers = { alc663_m51va_mixer },
17064 .cap_mixer = alc272_auto_capture_mixer,
17065 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
17066 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17067 .dac_nids = alc662_dac_nids,
17068 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17069 .adc_nids = alc272_adc_nids,
17070 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
17071 .capsrc_nids = alc272_capsrc_nids,
17072 .channel_mode = alc662_3ST_2ch_modes,
17073 .input_mux = &alc663_m51va_capture_source,
17074 .unsol_event = alc663_m51va_unsol_event,
17075 .init_hook = alc663_m51va_inithook,
17076 },
17077 [ALC272_DELL_ZM1] = {
17078 .mixers = { alc663_m51va_mixer },
17079 .cap_mixer = alc662_auto_capture_mixer,
17080 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
17081 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17082 .dac_nids = alc662_dac_nids,
17083 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17084 .adc_nids = alc662_adc_nids,
17085 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
17086 .capsrc_nids = alc662_capsrc_nids,
17087 .channel_mode = alc662_3ST_2ch_modes,
17088 .input_mux = &alc663_m51va_capture_source,
17089 .unsol_event = alc663_m51va_unsol_event,
17090 .init_hook = alc663_m51va_inithook,
17091 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020017092 [ALC272_SAMSUNG_NC10] = {
17093 .mixers = { alc272_nc10_mixer },
17094 .init_verbs = { alc662_init_verbs,
17095 alc663_21jd_amic_init_verbs },
17096 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17097 .dac_nids = alc272_dac_nids,
17098 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17099 .channel_mode = alc662_3ST_2ch_modes,
17100 .input_mux = &alc272_nc10_capture_source,
17101 .unsol_event = alc663_mode4_unsol_event,
17102 .init_hook = alc663_mode4_inithook,
17103 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017104};
17105
17106
17107/*
17108 * BIOS auto configuration
17109 */
17110
17111/* add playback controls from the parsed DAC table */
17112static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
17113 const struct auto_pin_cfg *cfg)
17114{
17115 char name[32];
17116 static const char *chname[4] = {
17117 "Front", "Surround", NULL /*CLFE*/, "Side"
17118 };
17119 hda_nid_t nid;
17120 int i, err;
17121
17122 for (i = 0; i < cfg->line_outs; i++) {
17123 if (!spec->multiout.dac_nids[i])
17124 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020017125 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017126 if (i == 2) {
17127 /* Center/LFE */
17128 err = add_control(spec, ALC_CTL_WIDGET_VOL,
17129 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017130 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
17131 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017132 if (err < 0)
17133 return err;
17134 err = add_control(spec, ALC_CTL_WIDGET_VOL,
17135 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017136 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
17137 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017138 if (err < 0)
17139 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017140 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017141 "Center Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017142 HDA_COMPOSE_AMP_VAL(0x0e, 1, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017143 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017144 if (err < 0)
17145 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017146 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017147 "LFE Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017148 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017149 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017150 if (err < 0)
17151 return err;
17152 } else {
17153 sprintf(name, "%s Playback Volume", chname[i]);
17154 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017155 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
17156 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017157 if (err < 0)
17158 return err;
17159 sprintf(name, "%s Playback Switch", chname[i]);
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017160 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
17161 HDA_COMPOSE_AMP_VAL(alc880_idx_to_mixer(i),
17162 3, 0, HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017163 if (err < 0)
17164 return err;
17165 }
17166 }
17167 return 0;
17168}
17169
17170/* add playback controls for speaker and HP outputs */
17171static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
17172 const char *pfx)
17173{
17174 hda_nid_t nid;
17175 int err;
17176 char name[32];
17177
17178 if (!pin)
17179 return 0;
17180
Takashi Iwai24fb9172008-09-02 14:48:20 +020017181 if (pin == 0x17) {
17182 /* ALC663 has a mono output pin on 0x17 */
17183 sprintf(name, "%s Playback Switch", pfx);
17184 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
17185 HDA_COMPOSE_AMP_VAL(pin, 2, 0, HDA_OUTPUT));
17186 return err;
17187 }
17188
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017189 if (alc880_is_fixed_pin(pin)) {
17190 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai939778a2009-02-05 15:57:55 +010017191 /* printk(KERN_DEBUG "DAC nid=%x\n",nid); */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017192 /* specify the DAC as the extra output */
17193 if (!spec->multiout.hp_nid)
17194 spec->multiout.hp_nid = nid;
17195 else
17196 spec->multiout.extra_out_nid[0] = nid;
17197 /* control HP volume/switch on the output mixer amp */
17198 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
17199 sprintf(name, "%s Playback Volume", pfx);
17200 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
17201 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
17202 if (err < 0)
17203 return err;
17204 sprintf(name, "%s Playback Switch", pfx);
17205 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
17206 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
17207 if (err < 0)
17208 return err;
17209 } else if (alc880_is_multi_pin(pin)) {
17210 /* set manual connection */
17211 /* we have only a switch on HP-out PIN */
17212 sprintf(name, "%s Playback Switch", pfx);
17213 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
17214 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
17215 if (err < 0)
17216 return err;
17217 }
17218 return 0;
17219}
17220
Takashi Iwai2d864c42009-03-20 12:52:47 +010017221/* return the index of the src widget from the connection list of the nid.
17222 * return -1 if not found
17223 */
17224static int alc662_input_pin_idx(struct hda_codec *codec, hda_nid_t nid,
17225 hda_nid_t src)
17226{
17227 hda_nid_t conn_list[HDA_MAX_CONNECTIONS];
17228 int i, conns;
17229
17230 conns = snd_hda_get_connections(codec, nid, conn_list,
17231 ARRAY_SIZE(conn_list));
17232 if (conns < 0)
17233 return -1;
17234 for (i = 0; i < conns; i++)
17235 if (conn_list[i] == src)
17236 return i;
17237 return -1;
17238}
17239
17240static int alc662_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
17241{
Takashi Iwai1327a322009-03-23 13:07:47 +010017242 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai2d864c42009-03-20 12:52:47 +010017243 return (pincap & AC_PINCAP_IN) != 0;
17244}
17245
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017246/* create playback/capture controls for input pins */
Takashi Iwai2d864c42009-03-20 12:52:47 +010017247static int alc662_auto_create_analog_input_ctls(struct hda_codec *codec,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017248 const struct auto_pin_cfg *cfg)
17249{
Takashi Iwai2d864c42009-03-20 12:52:47 +010017250 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017251 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017252 int i, err, idx;
17253
17254 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai2d864c42009-03-20 12:52:47 +010017255 if (alc662_is_input_pin(codec, cfg->input_pins[i])) {
17256 idx = alc662_input_pin_idx(codec, 0x0b,
17257 cfg->input_pins[i]);
17258 if (idx >= 0) {
17259 err = new_analog_input(spec, cfg->input_pins[i],
17260 auto_pin_cfg_labels[i],
17261 idx, 0x0b);
17262 if (err < 0)
17263 return err;
17264 }
17265 idx = alc662_input_pin_idx(codec, 0x22,
17266 cfg->input_pins[i]);
17267 if (idx >= 0) {
17268 imux->items[imux->num_items].label =
17269 auto_pin_cfg_labels[i];
17270 imux->items[imux->num_items].index = idx;
17271 imux->num_items++;
17272 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017273 }
17274 }
17275 return 0;
17276}
17277
17278static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
17279 hda_nid_t nid, int pin_type,
17280 int dac_idx)
17281{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017282 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017283 /* need the manual connection? */
17284 if (alc880_is_multi_pin(nid)) {
17285 struct alc_spec *spec = codec->spec;
17286 int idx = alc880_multi_pin_idx(nid);
17287 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
17288 AC_VERB_SET_CONNECT_SEL,
17289 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
17290 }
17291}
17292
17293static void alc662_auto_init_multi_out(struct hda_codec *codec)
17294{
17295 struct alc_spec *spec = codec->spec;
17296 int i;
17297
17298 for (i = 0; i <= HDA_SIDE; i++) {
17299 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017300 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017301 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017302 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017303 i);
17304 }
17305}
17306
17307static void alc662_auto_init_hp_out(struct hda_codec *codec)
17308{
17309 struct alc_spec *spec = codec->spec;
17310 hda_nid_t pin;
17311
17312 pin = spec->autocfg.hp_pins[0];
17313 if (pin) /* connect to front */
17314 /* use dac 0 */
17315 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017316 pin = spec->autocfg.speaker_pins[0];
17317 if (pin)
17318 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017319}
17320
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017321#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
17322
17323static void alc662_auto_init_analog_input(struct hda_codec *codec)
17324{
17325 struct alc_spec *spec = codec->spec;
17326 int i;
17327
17328 for (i = 0; i < AUTO_PIN_LAST; i++) {
17329 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai2d864c42009-03-20 12:52:47 +010017330 if (alc662_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010017331 alc_set_input_pin(codec, nid, i);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010017332 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010017333 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017334 snd_hda_codec_write(codec, nid, 0,
17335 AC_VERB_SET_AMP_GAIN_MUTE,
17336 AMP_OUT_MUTE);
17337 }
17338 }
17339}
17340
Takashi Iwaif511b012008-08-15 16:46:42 +020017341#define alc662_auto_init_input_src alc882_auto_init_input_src
17342
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017343static int alc662_parse_auto_config(struct hda_codec *codec)
17344{
17345 struct alc_spec *spec = codec->spec;
17346 int err;
17347 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
17348
17349 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
17350 alc662_ignore);
17351 if (err < 0)
17352 return err;
17353 if (!spec->autocfg.line_outs)
17354 return 0; /* can't find valid BIOS pin config */
17355
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017356 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
17357 if (err < 0)
17358 return err;
17359 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
17360 if (err < 0)
17361 return err;
17362 err = alc662_auto_create_extra_out(spec,
17363 spec->autocfg.speaker_pins[0],
17364 "Speaker");
17365 if (err < 0)
17366 return err;
17367 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
17368 "Headphone");
17369 if (err < 0)
17370 return err;
Takashi Iwai2d864c42009-03-20 12:52:47 +010017371 err = alc662_auto_create_analog_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017372 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017373 return err;
17374
17375 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
17376
Takashi Iwai0852d7a2009-02-11 11:35:15 +010017377 if (spec->autocfg.dig_outs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017378 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
17379
Takashi Iwai603c4012008-07-30 15:01:44 +020017380 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017381 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017382
17383 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017384 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020017385
Takashi Iwaid88897e2008-10-31 15:01:37 +010017386 add_verb(spec, alc662_auto_init_verbs);
Takashi Iwai24fb9172008-09-02 14:48:20 +020017387 if (codec->vendor_id == 0x10ec0663)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017388 add_verb(spec, alc663_auto_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020017389
17390 err = alc_auto_add_mic_boost(codec);
17391 if (err < 0)
17392 return err;
17393
Takashi Iwai4a79ba32009-04-22 16:31:35 +020017394 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
17395
Takashi Iwai8c872862007-06-19 12:11:16 +020017396 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017397}
17398
17399/* additional initialization for auto-configuration model */
17400static void alc662_auto_init(struct hda_codec *codec)
17401{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017402 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017403 alc662_auto_init_multi_out(codec);
17404 alc662_auto_init_hp_out(codec);
17405 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020017406 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017407 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020017408 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017409}
17410
17411static int patch_alc662(struct hda_codec *codec)
17412{
17413 struct alc_spec *spec;
17414 int err, board_config;
17415
17416 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
17417 if (!spec)
17418 return -ENOMEM;
17419
17420 codec->spec = spec;
17421
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020017422 alc_fix_pll_init(codec, 0x20, 0x04, 15);
17423
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017424 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
17425 alc662_models,
17426 alc662_cfg_tbl);
17427 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020017428 printk(KERN_INFO "hda_codec: Unknown model for %s, "
17429 "trying auto-probe from BIOS...\n", codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017430 board_config = ALC662_AUTO;
17431 }
17432
17433 if (board_config == ALC662_AUTO) {
17434 /* automatic parse from the BIOS config */
17435 err = alc662_parse_auto_config(codec);
17436 if (err < 0) {
17437 alc_free(codec);
17438 return err;
Takashi Iwai8c872862007-06-19 12:11:16 +020017439 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017440 printk(KERN_INFO
17441 "hda_codec: Cannot set up configuration "
17442 "from BIOS. Using base mode...\n");
17443 board_config = ALC662_3ST_2ch_DIG;
17444 }
17445 }
17446
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090017447 err = snd_hda_attach_beep_device(codec, 0x1);
17448 if (err < 0) {
17449 alc_free(codec);
17450 return err;
17451 }
17452
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017453 if (board_config != ALC662_AUTO)
17454 setup_preset(spec, &alc662_presets[board_config]);
17455
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017456 spec->stream_analog_playback = &alc662_pcm_analog_playback;
17457 spec->stream_analog_capture = &alc662_pcm_analog_capture;
17458
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017459 spec->stream_digital_playback = &alc662_pcm_digital_playback;
17460 spec->stream_digital_capture = &alc662_pcm_digital_capture;
17461
Takashi Iwaie1406342008-02-11 18:32:32 +010017462 spec->adc_nids = alc662_adc_nids;
17463 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
17464 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017465
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017466 if (!spec->cap_mixer)
17467 set_capture_mixer(spec);
Takashi Iwaib9591442009-03-16 15:25:00 +010017468 if (codec->vendor_id == 0x10ec0662)
17469 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
17470 else
17471 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017472
Takashi Iwai2134ea42008-01-10 16:53:55 +010017473 spec->vmaster_nid = 0x02;
17474
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017475 codec->patch_ops = alc_patch_ops;
17476 if (board_config == ALC662_AUTO)
17477 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020017478#ifdef CONFIG_SND_HDA_POWER_SAVE
17479 if (!spec->loopback.amplist)
17480 spec->loopback.amplist = alc662_loopbacks;
17481#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010017482 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017483
17484 return 0;
17485}
17486
17487/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070017488 * patch entries
17489 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017490static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070017491 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010017492 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017493 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020017494 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017495 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020017496 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017497 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017498 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017499 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
17500 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
17501 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017502 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
17503 .patch = patch_alc883 },
17504 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
17505 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017506 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017507 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017508 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020017509 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Clive Messer669faba2008-09-30 15:49:13 +020017510 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
17511 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Takashi Iwaicb308f92008-04-16 14:13:29 +020017512 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai7943a8a2008-04-16 17:29:09 +020017513 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Kailang Yangdf694da2005-12-05 19:42:22 +010017514 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Kailang Yanga385a522008-10-15 11:20:21 +020017515 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc883 },
Kailang Yang44426082008-10-15 11:18:05 +020017516 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
17517 .patch = patch_alc883 },
Wu Fengguang3fea2cb2008-12-26 12:20:43 +080017518 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017519 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017520 {} /* terminator */
17521};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017522
17523MODULE_ALIAS("snd-hda-codec-id:10ec*");
17524
17525MODULE_LICENSE("GPL");
17526MODULE_DESCRIPTION("Realtek HD-audio codec");
17527
17528static struct hda_codec_preset_list realtek_list = {
17529 .preset = snd_hda_preset_realtek,
17530 .owner = THIS_MODULE,
17531};
17532
17533static int __init patch_realtek_init(void)
17534{
17535 return snd_hda_add_codec_preset(&realtek_list);
17536}
17537
17538static void __exit patch_realtek_exit(void)
17539{
17540 snd_hda_delete_codec_preset(&realtek_list);
17541}
17542
17543module_init(patch_realtek_init)
17544module_exit(patch_realtek_exit)