blob: efb92c83c7a68fd9c984e6f450615addd0fb20de [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,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200211 ALC883_3ST_2ch_DIG,
212 ALC883_3ST_6ch_DIG,
213 ALC883_3ST_6ch,
214 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200215 ALC883_TARGA_DIG,
216 ALC883_TARGA_2ch_DIG,
David Heidelberger64a8be72009-06-08 16:15:18 +0200217 ALC883_TARGA_8ch_DIG,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +0200218 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200219 ALC883_ACER_ASPIRE,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +0800220 ALC888_ACER_ASPIRE_4930G,
Tony Vroond2fd4b02009-06-21 00:40:10 +0100221 ALC888_ACER_ASPIRE_6530G,
Hector Martin3b315d72009-06-02 10:54:19 +0200222 ALC888_ACER_ASPIRE_8930G,
Tobin Davisc07584c2006-10-13 12:32:16 +0200223 ALC883_MEDION,
Kailang Yangea1fb292008-08-26 12:58:38 +0200224 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100225 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200226 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200227 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200228 ALC888_LENOVO_MS7195_DIG,
Kailang Yange2757d52008-08-26 13:17:46 +0200229 ALC888_LENOVO_SKY,
Kailang Yangea1fb292008-08-26 12:58:38 +0200230 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200231 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100232 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100233 ALC883_MITAC,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100234 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100235 ALC883_FUJITSU_PI2515,
Vincent Petryef8ef5f2008-11-23 11:31:41 +0800236 ALC888_FUJITSU_XA3530,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200237 ALC883_3ST_6ch_INTEL,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +0200238 ALC889A_INTEL,
239 ALC889_INTEL,
Kailang Yange2757d52008-08-26 13:17:46 +0200240 ALC888_ASUS_M90V,
241 ALC888_ASUS_EEE1601,
Torben Schulzeb4c41d2009-05-18 15:02:35 +0200242 ALC889A_MB31,
Wu Fengguang3ab90932008-11-17 09:51:09 +0100243 ALC1200_ASUS_P5Q,
Guido Günther3e1647c2009-06-05 00:47:26 +0200244 ALC883_SONY_VAIO_TT,
Takashi Iwai4953550a2009-06-30 15:28:30 +0200245 ALC882_AUTO,
246 ALC882_MODEL_LAST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200247};
248
Kailang Yangdf694da2005-12-05 19:42:22 +0100249/* for GPIO Poll */
250#define GPIO_MASK 0x03
251
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200252/* extra amp-initialization sequence types */
253enum {
254 ALC_INIT_NONE,
255 ALC_INIT_DEFAULT,
256 ALC_INIT_GPIO1,
257 ALC_INIT_GPIO2,
258 ALC_INIT_GPIO3,
259};
260
Takashi Iwai6c819492009-08-10 18:47:44 +0200261struct alc_mic_route {
262 hda_nid_t pin;
263 unsigned char mux_idx;
264 unsigned char amix_idx;
265};
266
267#define MUX_IDX_UNDEF ((unsigned char)-1)
268
Linus Torvalds1da177e2005-04-16 15:20:36 -0700269struct alc_spec {
270 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100271 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700272 unsigned int num_mixers;
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100273 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100274 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700275
Kailang Yangdf694da2005-12-05 19:42:22 +0100276 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200277 * don't forget NULL
278 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200279 */
280 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700281
Takashi Iwaiaa563af2009-07-31 10:05:11 +0200282 char stream_name_analog[32]; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700283 struct hda_pcm_stream *stream_analog_playback;
284 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100285 struct hda_pcm_stream *stream_analog_alt_playback;
286 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700287
Takashi Iwaiaa563af2009-07-31 10:05:11 +0200288 char stream_name_digital[32]; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700289 struct hda_pcm_stream *stream_digital_playback;
290 struct hda_pcm_stream *stream_digital_capture;
291
292 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200293 struct hda_multi_out multiout; /* playback set-up
294 * max_channels, dacs must be set
295 * dig_out_nid and hp_nid are optional
296 */
Takashi Iwai63300792008-01-24 15:31:36 +0100297 hda_nid_t alt_dac_nid;
Takashi Iwai6a05ac42009-02-13 11:19:09 +0100298 hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */
Takashi Iwai8c441982009-01-20 18:30:20 +0100299 int dig_out_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700300
301 /* capture */
302 unsigned int num_adc_nids;
303 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100304 hda_nid_t *capsrc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200305 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700306
307 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200308 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309 const struct hda_input_mux *input_mux;
310 unsigned int cur_mux[3];
Takashi Iwai6c819492009-08-10 18:47:44 +0200311 struct alc_mic_route ext_mic;
312 struct alc_mic_route int_mic;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700313
314 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100315 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700316 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200317 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200318 int const_channel_count;
319 int ext_channel_count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700320
321 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100322 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200323
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200324 /* dynamic controls, init_verbs and input_mux */
325 struct auto_pin_cfg autocfg;
Takashi Iwai603c4012008-07-30 15:01:44 +0200326 struct snd_array kctls;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200327 struct hda_input_mux private_imux[3];
Takashi Iwai41923e42007-10-22 17:20:10 +0200328 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai4953550a2009-06-30 15:28:30 +0200329 hda_nid_t private_adc_nids[AUTO_CFG_MAX_OUTS];
330 hda_nid_t private_capsrc_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100331
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100332 /* hooks */
333 void (*init_hook)(struct hda_codec *codec);
334 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
335
Takashi Iwai834be882006-03-01 14:16:17 +0100336 /* for pin sensing */
337 unsigned int sense_updated: 1;
338 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100339 unsigned int master_sw: 1;
Takashi Iwai6c819492009-08-10 18:47:44 +0200340 unsigned int auto_mic:1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200341
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100342 /* other flags */
343 unsigned int no_analog :1; /* digital I/O only */
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200344 int init_amp;
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100345
Takashi Iwai2134ea42008-01-10 16:53:55 +0100346 /* for virtual master */
347 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200348#ifdef CONFIG_SND_HDA_POWER_SAVE
349 struct hda_loopback_check loopback;
350#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200351
352 /* for PLL fix */
353 hda_nid_t pll_nid;
354 unsigned int pll_coef_idx, pll_coef_bit;
Kailang Yangdf694da2005-12-05 19:42:22 +0100355};
356
357/*
358 * configuration template - to be copied to the spec instance
359 */
360struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200361 struct snd_kcontrol_new *mixers[5]; /* should be identical size
362 * with spec
363 */
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100364 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Kailang Yangdf694da2005-12-05 19:42:22 +0100365 const struct hda_verb *init_verbs[5];
366 unsigned int num_dacs;
367 hda_nid_t *dac_nids;
368 hda_nid_t dig_out_nid; /* optional */
369 hda_nid_t hp_nid; /* optional */
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800370 hda_nid_t *slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100371 unsigned int num_adc_nids;
372 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100373 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100374 hda_nid_t dig_in_nid;
375 unsigned int num_channel_mode;
376 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200377 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200378 int const_channel_count;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200379 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100380 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100381 void (*unsol_event)(struct hda_codec *, unsigned int);
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200382 void (*setup)(struct hda_codec *);
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100383 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200384#ifdef CONFIG_SND_HDA_POWER_SAVE
385 struct hda_amp_list *loopbacks;
386#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700387};
388
Linus Torvalds1da177e2005-04-16 15:20:36 -0700389
390/*
391 * input MUX handling
392 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200393static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
394 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700395{
396 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
397 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200398 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
399 if (mux_idx >= spec->num_mux_defs)
400 mux_idx = 0;
401 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700402}
403
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200404static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
405 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700406{
407 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
408 struct alc_spec *spec = codec->spec;
409 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
410
411 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
412 return 0;
413}
414
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200415static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
416 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700417{
418 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
419 struct alc_spec *spec = codec->spec;
Takashi Iwaicd896c32008-11-18 12:36:33 +0100420 const struct hda_input_mux *imux;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700421 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwaicd896c32008-11-18 12:36:33 +0100422 unsigned int mux_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100423 hda_nid_t nid = spec->capsrc_nids ?
424 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200425 unsigned int type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700426
Takashi Iwaicd896c32008-11-18 12:36:33 +0100427 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
428 imux = &spec->input_mux[mux_idx];
429
Takashi Iwaia22d5432009-07-27 12:54:26 +0200430 type = get_wcaps_type(get_wcaps(codec, nid));
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200431 if (type == AC_WID_AUD_MIX) {
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100432 /* Matrix-mixer style (e.g. ALC882) */
433 unsigned int *cur_val = &spec->cur_mux[adc_idx];
434 unsigned int i, idx;
435
436 idx = ucontrol->value.enumerated.item[0];
437 if (idx >= imux->num_items)
438 idx = imux->num_items - 1;
439 if (*cur_val == idx)
440 return 0;
441 for (i = 0; i < imux->num_items; i++) {
442 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
443 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
444 imux->items[i].index,
445 HDA_AMP_MUTE, v);
446 }
447 *cur_val = idx;
448 return 1;
449 } else {
450 /* MUX style (e.g. ALC880) */
Takashi Iwaicd896c32008-11-18 12:36:33 +0100451 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100452 &spec->cur_mux[adc_idx]);
453 }
454}
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200455
Linus Torvalds1da177e2005-04-16 15:20:36 -0700456/*
457 * channel mode setting
458 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200459static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
460 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700461{
462 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
463 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100464 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
465 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700466}
467
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200468static int alc_ch_mode_get(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 Iwaid2a6d7d2005-11-17 11:06:29 +0100473 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200474 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200475 spec->ext_channel_count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700476}
477
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200478static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
479 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700480{
481 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
482 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200483 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
484 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200485 &spec->ext_channel_count);
486 if (err >= 0 && !spec->const_channel_count) {
487 spec->multiout.max_channels = spec->ext_channel_count;
488 if (spec->need_dac_fix)
489 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
490 }
Takashi Iwai4e195a72006-07-28 14:47:34 +0200491 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700492}
493
Linus Torvalds1da177e2005-04-16 15:20:36 -0700494/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100495 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200496 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100497 * being part of a format specifier. Maximum allowed length of a value is
498 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100499 *
500 * Note: some retasking pin complexes seem to ignore requests for input
501 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
502 * are requested. Therefore order this list so that this behaviour will not
503 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200504 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
505 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200506 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100507static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100508 "Mic 50pc bias", "Mic 80pc bias",
509 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100510};
511static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100512 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100513};
514/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200515 * in the pin being assumed to be exclusively an input or an output pin. In
516 * addition, "input" pins may or may not process the mic bias option
517 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
518 * accept requests for bias as of chip versions up to March 2006) and/or
519 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100520 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200521#define ALC_PIN_DIR_IN 0x00
522#define ALC_PIN_DIR_OUT 0x01
523#define ALC_PIN_DIR_INOUT 0x02
524#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
525#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100526
Kailang Yangea1fb292008-08-26 12:58:38 +0200527/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100528 * For each direction the minimum and maximum values are given.
529 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200530static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100531 { 0, 2 }, /* ALC_PIN_DIR_IN */
532 { 3, 4 }, /* ALC_PIN_DIR_OUT */
533 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200534 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
535 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100536};
537#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
538#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
539#define alc_pin_mode_n_items(_dir) \
540 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
541
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200542static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
543 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200544{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100545 unsigned int item_num = uinfo->value.enumerated.item;
546 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
547
548 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200549 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100550 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
551
552 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
553 item_num = alc_pin_mode_min(dir);
554 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200555 return 0;
556}
557
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200558static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
559 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200560{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100561 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200562 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
563 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100564 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200565 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200566 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
567 AC_VERB_GET_PIN_WIDGET_CONTROL,
568 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200569
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100570 /* Find enumerated value for current pinctl setting */
571 i = alc_pin_mode_min(dir);
Roel Kluin4b35d2ca2009-08-02 13:30:45 +0200572 while (i <= alc_pin_mode_max(dir) && alc_pin_mode_values[i] != pinctl)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100573 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200574 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100575 return 0;
576}
577
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200578static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
579 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100580{
581 signed int change;
582 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
583 hda_nid_t nid = kcontrol->private_value & 0xffff;
584 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
585 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200586 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
587 AC_VERB_GET_PIN_WIDGET_CONTROL,
588 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100589
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200590 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100591 val = alc_pin_mode_min(dir);
592
593 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100594 if (change) {
595 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200596 snd_hda_codec_write_cache(codec, nid, 0,
597 AC_VERB_SET_PIN_WIDGET_CONTROL,
598 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100599
Kailang Yangea1fb292008-08-26 12:58:38 +0200600 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100601 * for the requested pin mode. Enum values of 2 or less are
602 * input modes.
603 *
604 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200605 * reduces noise slightly (particularly on input) so we'll
606 * do it. However, having both input and output buffers
607 * enabled simultaneously doesn't seem to be problematic if
608 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100609 */
610 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200611 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
612 HDA_AMP_MUTE, HDA_AMP_MUTE);
613 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
614 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100615 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200616 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
617 HDA_AMP_MUTE, HDA_AMP_MUTE);
618 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
619 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100620 }
621 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200622 return change;
623}
624
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100625#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200626 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100627 .info = alc_pin_mode_info, \
628 .get = alc_pin_mode_get, \
629 .put = alc_pin_mode_put, \
630 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100631
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100632/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
633 * together using a mask with more than one bit set. This control is
634 * currently used only by the ALC260 test model. At this stage they are not
635 * needed for any "production" models.
636 */
637#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200638#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200639
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200640static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
641 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100642{
643 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
644 hda_nid_t nid = kcontrol->private_value & 0xffff;
645 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
646 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200647 unsigned int val = snd_hda_codec_read(codec, nid, 0,
648 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100649
650 *valp = (val & mask) != 0;
651 return 0;
652}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200653static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
654 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100655{
656 signed int change;
657 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
658 hda_nid_t nid = kcontrol->private_value & 0xffff;
659 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
660 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200661 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
662 AC_VERB_GET_GPIO_DATA,
663 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100664
665 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200666 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
667 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100668 gpio_data &= ~mask;
669 else
670 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200671 snd_hda_codec_write_cache(codec, nid, 0,
672 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100673
674 return change;
675}
676#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
677 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
678 .info = alc_gpio_data_info, \
679 .get = alc_gpio_data_get, \
680 .put = alc_gpio_data_put, \
681 .private_value = nid | (mask<<16) }
682#endif /* CONFIG_SND_DEBUG */
683
Jonathan Woithe92621f12006-02-28 11:47:47 +0100684/* A switch control to allow the enabling of the digital IO pins on the
685 * ALC260. This is incredibly simplistic; the intention of this control is
686 * to provide something in the test model allowing digital outputs to be
687 * identified if present. If models are found which can utilise these
688 * outputs a more complete mixer control can be devised for those models if
689 * necessary.
690 */
691#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200692#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200693
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200694static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
695 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100696{
697 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
698 hda_nid_t nid = kcontrol->private_value & 0xffff;
699 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
700 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200701 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100702 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100703
704 *valp = (val & mask) != 0;
705 return 0;
706}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200707static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
708 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100709{
710 signed int change;
711 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
712 hda_nid_t nid = kcontrol->private_value & 0xffff;
713 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
714 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200715 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100716 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200717 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100718
719 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200720 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100721 if (val==0)
722 ctrl_data &= ~mask;
723 else
724 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200725 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
726 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100727
728 return change;
729}
730#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
731 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
732 .info = alc_spdif_ctrl_info, \
733 .get = alc_spdif_ctrl_get, \
734 .put = alc_spdif_ctrl_put, \
735 .private_value = nid | (mask<<16) }
736#endif /* CONFIG_SND_DEBUG */
737
Jonathan Woithef8225f62008-01-08 12:16:54 +0100738/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
739 * Again, this is only used in the ALC26x test models to help identify when
740 * the EAPD line must be asserted for features to work.
741 */
742#ifdef CONFIG_SND_DEBUG
743#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
744
745static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
746 struct snd_ctl_elem_value *ucontrol)
747{
748 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
749 hda_nid_t nid = kcontrol->private_value & 0xffff;
750 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
751 long *valp = ucontrol->value.integer.value;
752 unsigned int val = snd_hda_codec_read(codec, nid, 0,
753 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
754
755 *valp = (val & mask) != 0;
756 return 0;
757}
758
759static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
760 struct snd_ctl_elem_value *ucontrol)
761{
762 int change;
763 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
764 hda_nid_t nid = kcontrol->private_value & 0xffff;
765 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
766 long val = *ucontrol->value.integer.value;
767 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
768 AC_VERB_GET_EAPD_BTLENABLE,
769 0x00);
770
771 /* Set/unset the masked control bit(s) as needed */
772 change = (!val ? 0 : mask) != (ctrl_data & mask);
773 if (!val)
774 ctrl_data &= ~mask;
775 else
776 ctrl_data |= mask;
777 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
778 ctrl_data);
779
780 return change;
781}
782
783#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
784 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
785 .info = alc_eapd_ctrl_info, \
786 .get = alc_eapd_ctrl_get, \
787 .put = alc_eapd_ctrl_put, \
788 .private_value = nid | (mask<<16) }
789#endif /* CONFIG_SND_DEBUG */
790
Kailang Yangdf694da2005-12-05 19:42:22 +0100791/*
Takashi Iwai23f0c042009-02-26 13:03:58 +0100792 * set up the input pin config (depending on the given auto-pin type)
793 */
794static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
795 int auto_pin_type)
796{
797 unsigned int val = PIN_IN;
798
799 if (auto_pin_type <= AUTO_PIN_FRONT_MIC) {
800 unsigned int pincap;
Takashi Iwai1327a322009-03-23 13:07:47 +0100801 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai23f0c042009-02-26 13:03:58 +0100802 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
803 if (pincap & AC_PINCAP_VREF_80)
804 val = PIN_VREF80;
Takashi Iwai461c6c32009-05-25 08:06:02 +0200805 else if (pincap & AC_PINCAP_VREF_50)
806 val = PIN_VREF50;
807 else if (pincap & AC_PINCAP_VREF_100)
808 val = PIN_VREF100;
809 else if (pincap & AC_PINCAP_VREF_GRD)
810 val = PIN_VREFGRD;
Takashi Iwai23f0c042009-02-26 13:03:58 +0100811 }
812 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
813}
814
815/*
Takashi Iwaid88897e2008-10-31 15:01:37 +0100816 */
817static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
818{
819 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
820 return;
821 spec->mixers[spec->num_mixers++] = mix;
822}
823
824static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
825{
826 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
827 return;
828 spec->init_verbs[spec->num_init_verbs++] = verb;
829}
830
Takashi Iwaidaead532008-11-28 12:55:36 +0100831#ifdef CONFIG_PROC_FS
832/*
833 * hook for proc
834 */
835static void print_realtek_coef(struct snd_info_buffer *buffer,
836 struct hda_codec *codec, hda_nid_t nid)
837{
838 int coeff;
839
840 if (nid != 0x20)
841 return;
842 coeff = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PROC_COEF, 0);
843 snd_iprintf(buffer, " Processing Coefficient: 0x%02x\n", coeff);
844 coeff = snd_hda_codec_read(codec, nid, 0,
845 AC_VERB_GET_COEF_INDEX, 0);
846 snd_iprintf(buffer, " Coefficient Index: 0x%02x\n", coeff);
847}
848#else
849#define print_realtek_coef NULL
850#endif
851
Takashi Iwaid88897e2008-10-31 15:01:37 +0100852/*
Kailang Yangdf694da2005-12-05 19:42:22 +0100853 * set up from the preset table
854 */
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200855static void setup_preset(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200856 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100857{
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200858 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +0100859 int i;
860
861 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100862 add_mixer(spec, preset->mixers[i]);
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100863 spec->cap_mixer = preset->cap_mixer;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200864 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
865 i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100866 add_verb(spec, preset->init_verbs[i]);
Kailang Yangea1fb292008-08-26 12:58:38 +0200867
Kailang Yangdf694da2005-12-05 19:42:22 +0100868 spec->channel_mode = preset->channel_mode;
869 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200870 spec->need_dac_fix = preset->need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200871 spec->const_channel_count = preset->const_channel_count;
Kailang Yangdf694da2005-12-05 19:42:22 +0100872
Hector Martin3b315d72009-06-02 10:54:19 +0200873 if (preset->const_channel_count)
874 spec->multiout.max_channels = preset->const_channel_count;
875 else
876 spec->multiout.max_channels = spec->channel_mode[0].channels;
877 spec->ext_channel_count = spec->channel_mode[0].channels;
Kailang Yangdf694da2005-12-05 19:42:22 +0100878
879 spec->multiout.num_dacs = preset->num_dacs;
880 spec->multiout.dac_nids = preset->dac_nids;
881 spec->multiout.dig_out_nid = preset->dig_out_nid;
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800882 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100883 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200884
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200885 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200886 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200887 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100888 spec->input_mux = preset->input_mux;
889
890 spec->num_adc_nids = preset->num_adc_nids;
891 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100892 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100893 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100894
895 spec->unsol_event = preset->unsol_event;
896 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200897#ifdef CONFIG_SND_HDA_POWER_SAVE
898 spec->loopback.amplist = preset->loopbacks;
899#endif
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200900
901 if (preset->setup)
902 preset->setup(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +0100903}
904
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200905/* Enable GPIO mask and set output */
906static struct hda_verb alc_gpio1_init_verbs[] = {
907 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
908 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
909 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
910 { }
911};
912
913static struct hda_verb alc_gpio2_init_verbs[] = {
914 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
915 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
916 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
917 { }
918};
919
Kailang Yangbdd148a2007-05-08 15:19:08 +0200920static struct hda_verb alc_gpio3_init_verbs[] = {
921 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
922 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
923 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
924 { }
925};
926
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200927/*
928 * Fix hardware PLL issue
929 * On some codecs, the analog PLL gating control must be off while
930 * the default value is 1.
931 */
932static void alc_fix_pll(struct hda_codec *codec)
933{
934 struct alc_spec *spec = codec->spec;
935 unsigned int val;
936
937 if (!spec->pll_nid)
938 return;
939 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
940 spec->pll_coef_idx);
941 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
942 AC_VERB_GET_PROC_COEF, 0);
943 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
944 spec->pll_coef_idx);
945 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
946 val & ~(1 << spec->pll_coef_bit));
947}
948
949static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
950 unsigned int coef_idx, unsigned int coef_bit)
951{
952 struct alc_spec *spec = codec->spec;
953 spec->pll_nid = nid;
954 spec->pll_coef_idx = coef_idx;
955 spec->pll_coef_bit = coef_bit;
956 alc_fix_pll(codec);
957}
958
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200959static void alc_automute_pin(struct hda_codec *codec)
Kailang Yangc9b58002007-10-16 14:30:01 +0200960{
961 struct alc_spec *spec = codec->spec;
Takashi Iwai261c2402009-06-25 08:13:40 +0200962 unsigned int present, pincap;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200963 unsigned int nid = spec->autocfg.hp_pins[0];
964 int i;
Kailang Yangc9b58002007-10-16 14:30:01 +0200965
Takashi Iwai261c2402009-06-25 08:13:40 +0200966 pincap = snd_hda_query_pin_caps(codec, nid);
967 if (pincap & AC_PINCAP_TRIG_REQ) /* need trigger? */
968 snd_hda_codec_read(codec, nid, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200969 present = snd_hda_codec_read(codec, nid, 0,
Kailang Yangc9b58002007-10-16 14:30:01 +0200970 AC_VERB_GET_PIN_SENSE, 0);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200971 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
972 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
973 nid = spec->autocfg.speaker_pins[i];
974 if (!nid)
975 break;
976 snd_hda_codec_write(codec, nid, 0,
977 AC_VERB_SET_PIN_WIDGET_CONTROL,
978 spec->jack_present ? 0 : PIN_OUT);
979 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200980}
981
Takashi Iwai6c819492009-08-10 18:47:44 +0200982static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
983 hda_nid_t nid)
984{
985 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
986 int i, nums;
987
988 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
989 for (i = 0; i < nums; i++)
990 if (conn[i] == nid)
991 return i;
992 return -1;
993}
994
Kailang Yang7fb0d782008-10-15 11:12:35 +0200995static void alc_mic_automute(struct hda_codec *codec)
996{
997 struct alc_spec *spec = codec->spec;
Takashi Iwai6c819492009-08-10 18:47:44 +0200998 struct alc_mic_route *dead, *alive;
999 unsigned int present, type;
1000 hda_nid_t cap_nid;
Kailang Yang7fb0d782008-10-15 11:12:35 +02001001
Takashi Iwaib59bdf32009-08-11 09:47:30 +02001002 if (!spec->auto_mic)
1003 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001004 if (!spec->int_mic.pin || !spec->ext_mic.pin)
1005 return;
1006 if (snd_BUG_ON(!spec->adc_nids))
1007 return;
1008
1009 cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0];
1010
1011 present = snd_hda_codec_read(codec, spec->ext_mic.pin, 0,
1012 AC_VERB_GET_PIN_SENSE, 0);
1013 present &= AC_PINSENSE_PRESENCE;
1014 if (present) {
1015 alive = &spec->ext_mic;
1016 dead = &spec->int_mic;
1017 } else {
1018 alive = &spec->int_mic;
1019 dead = &spec->ext_mic;
1020 }
1021
Takashi Iwai6c819492009-08-10 18:47:44 +02001022 type = get_wcaps_type(get_wcaps(codec, cap_nid));
1023 if (type == AC_WID_AUD_MIX) {
1024 /* Matrix-mixer style (e.g. ALC882) */
1025 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1026 alive->mux_idx,
1027 HDA_AMP_MUTE, 0);
1028 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1029 dead->mux_idx,
1030 HDA_AMP_MUTE, HDA_AMP_MUTE);
1031 } else {
1032 /* MUX style (e.g. ALC880) */
1033 snd_hda_codec_write_cache(codec, cap_nid, 0,
1034 AC_VERB_SET_CONNECT_SEL,
1035 alive->mux_idx);
1036 }
1037
1038 /* FIXME: analog mixer */
Kailang Yang7fb0d782008-10-15 11:12:35 +02001039}
1040
Kailang Yangc9b58002007-10-16 14:30:01 +02001041/* unsolicited event for HP jack sensing */
1042static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
1043{
1044 if (codec->vendor_id == 0x10ec0880)
1045 res >>= 28;
1046 else
1047 res >>= 26;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001048 switch (res) {
1049 case ALC880_HP_EVENT:
1050 alc_automute_pin(codec);
1051 break;
1052 case ALC880_MIC_EVENT:
Kailang Yang7fb0d782008-10-15 11:12:35 +02001053 alc_mic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001054 break;
1055 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001056}
1057
1058static void alc_inithook(struct hda_codec *codec)
1059{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001060 alc_automute_pin(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +02001061 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001062}
1063
Kailang Yangf9423e72008-05-27 12:32:25 +02001064/* additional initialization for ALC888 variants */
1065static void alc888_coef_init(struct hda_codec *codec)
1066{
1067 unsigned int tmp;
1068
1069 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1070 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1071 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
Takashi Iwai37db6232009-03-05 09:40:16 +01001072 if ((tmp & 0xf0) == 0x20)
Kailang Yangf9423e72008-05-27 12:32:25 +02001073 /* alc888S-VC */
1074 snd_hda_codec_read(codec, 0x20, 0,
1075 AC_VERB_SET_PROC_COEF, 0x830);
1076 else
1077 /* alc888-VB */
1078 snd_hda_codec_read(codec, 0x20, 0,
1079 AC_VERB_SET_PROC_COEF, 0x3030);
1080}
1081
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001082static void alc889_coef_init(struct hda_codec *codec)
1083{
1084 unsigned int tmp;
1085
1086 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1087 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1088 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1089 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
1090}
1091
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001092static void alc_auto_init_amp(struct hda_codec *codec, int type)
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001093{
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001094 unsigned int tmp;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001095
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001096 switch (type) {
1097 case ALC_INIT_GPIO1:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001098 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1099 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001100 case ALC_INIT_GPIO2:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001101 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1102 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001103 case ALC_INIT_GPIO3:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001104 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1105 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001106 case ALC_INIT_DEFAULT:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001107 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001108 case 0x10ec0260:
1109 snd_hda_codec_write(codec, 0x0f, 0,
1110 AC_VERB_SET_EAPD_BTLENABLE, 2);
1111 snd_hda_codec_write(codec, 0x10, 0,
1112 AC_VERB_SET_EAPD_BTLENABLE, 2);
1113 break;
1114 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001115 case 0x10ec0267:
1116 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001117 case 0x10ec0269:
Takashi Iwaic6e8f2d2009-02-06 12:45:52 +01001118 case 0x10ec0272:
Kailang Yangf9423e72008-05-27 12:32:25 +02001119 case 0x10ec0660:
1120 case 0x10ec0662:
1121 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001122 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001123 case 0x10ec0889:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001124 snd_hda_codec_write(codec, 0x14, 0,
1125 AC_VERB_SET_EAPD_BTLENABLE, 2);
1126 snd_hda_codec_write(codec, 0x15, 0,
1127 AC_VERB_SET_EAPD_BTLENABLE, 2);
Kailang Yangc9b58002007-10-16 14:30:01 +02001128 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001129 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001130 switch (codec->vendor_id) {
1131 case 0x10ec0260:
1132 snd_hda_codec_write(codec, 0x1a, 0,
1133 AC_VERB_SET_COEF_INDEX, 7);
1134 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1135 AC_VERB_GET_PROC_COEF, 0);
1136 snd_hda_codec_write(codec, 0x1a, 0,
1137 AC_VERB_SET_COEF_INDEX, 7);
1138 snd_hda_codec_write(codec, 0x1a, 0,
1139 AC_VERB_SET_PROC_COEF,
1140 tmp | 0x2010);
1141 break;
1142 case 0x10ec0262:
1143 case 0x10ec0880:
1144 case 0x10ec0882:
1145 case 0x10ec0883:
1146 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001147 case 0x10ec0887:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001148 case 0x10ec0889:
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001149 alc889_coef_init(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001150 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001151 case 0x10ec0888:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001152 alc888_coef_init(codec);
Kailang Yangf9423e72008-05-27 12:32:25 +02001153 break;
Kailang Yangc9b58002007-10-16 14:30:01 +02001154 case 0x10ec0267:
1155 case 0x10ec0268:
1156 snd_hda_codec_write(codec, 0x20, 0,
1157 AC_VERB_SET_COEF_INDEX, 7);
1158 tmp = snd_hda_codec_read(codec, 0x20, 0,
1159 AC_VERB_GET_PROC_COEF, 0);
1160 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001161 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001162 snd_hda_codec_write(codec, 0x20, 0,
1163 AC_VERB_SET_PROC_COEF,
1164 tmp | 0x3000);
1165 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001166 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001167 break;
1168 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001169}
Kailang Yangea1fb292008-08-26 12:58:38 +02001170
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001171static void alc_init_auto_hp(struct hda_codec *codec)
1172{
1173 struct alc_spec *spec = codec->spec;
1174
1175 if (!spec->autocfg.hp_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +02001176 return;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001177
Kailang Yangc9b58002007-10-16 14:30:01 +02001178 if (!spec->autocfg.speaker_pins[0]) {
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001179 if (spec->autocfg.line_out_pins[0] &&
1180 spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT)
Kailang Yangc9b58002007-10-16 14:30:01 +02001181 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +01001182 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +02001183 else
1184 return;
1185 }
1186
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001187 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1188 spec->autocfg.hp_pins[0]);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001189 snd_hda_codec_write_cache(codec, spec->autocfg.hp_pins[0], 0,
1190 AC_VERB_SET_UNSOLICITED_ENABLE,
1191 AC_USRSP_EN | ALC880_HP_EVENT);
1192 spec->unsol_event = alc_sku_unsol_event;
1193}
1194
Takashi Iwai6c819492009-08-10 18:47:44 +02001195static void alc_init_auto_mic(struct hda_codec *codec)
1196{
1197 struct alc_spec *spec = codec->spec;
1198 struct auto_pin_cfg *cfg = &spec->autocfg;
1199 hda_nid_t fixed, ext;
1200 int i;
1201
1202 /* there must be only two mic inputs exclusively */
1203 for (i = AUTO_PIN_LINE; i < AUTO_PIN_LAST; i++)
1204 if (cfg->input_pins[i])
1205 return;
1206
1207 fixed = ext = 0;
1208 for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++) {
1209 hda_nid_t nid = cfg->input_pins[i];
1210 unsigned int defcfg;
1211 if (!nid)
1212 return;
1213 defcfg = snd_hda_codec_get_pincfg(codec, nid);
1214 switch (get_defcfg_connect(defcfg)) {
1215 case AC_JACK_PORT_FIXED:
1216 if (fixed)
1217 return; /* already occupied */
1218 fixed = nid;
1219 break;
1220 case AC_JACK_PORT_COMPLEX:
1221 if (ext)
1222 return; /* already occupied */
1223 ext = nid;
1224 break;
1225 default:
1226 return; /* invalid entry */
1227 }
1228 }
1229 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
1230 return; /* no unsol support */
1231 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x\n",
1232 ext, fixed);
1233 spec->ext_mic.pin = ext;
1234 spec->int_mic.pin = fixed;
1235 spec->ext_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1236 spec->int_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1237 spec->auto_mic = 1;
1238 snd_hda_codec_write_cache(codec, spec->ext_mic.pin, 0,
1239 AC_VERB_SET_UNSOLICITED_ENABLE,
1240 AC_USRSP_EN | ALC880_MIC_EVENT);
1241 spec->unsol_event = alc_sku_unsol_event;
1242}
1243
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001244/* check subsystem ID and set up device-specific initialization;
1245 * return 1 if initialized, 0 if invalid SSID
1246 */
1247/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1248 * 31 ~ 16 : Manufacture ID
1249 * 15 ~ 8 : SKU ID
1250 * 7 ~ 0 : Assembly ID
1251 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1252 */
1253static int alc_subsystem_id(struct hda_codec *codec,
1254 hda_nid_t porta, hda_nid_t porte,
1255 hda_nid_t portd)
1256{
1257 unsigned int ass, tmp, i;
1258 unsigned nid;
1259 struct alc_spec *spec = codec->spec;
1260
1261 ass = codec->subsystem_id & 0xffff;
1262 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1263 goto do_sku;
1264
1265 /* invalid SSID, check the special NID pin defcfg instead */
1266 /*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04001267 * 31~30 : port connectivity
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001268 * 29~21 : reserve
1269 * 20 : PCBEEP input
1270 * 19~16 : Check sum (15:1)
1271 * 15~1 : Custom
1272 * 0 : override
1273 */
1274 nid = 0x1d;
1275 if (codec->vendor_id == 0x10ec0260)
1276 nid = 0x17;
1277 ass = snd_hda_codec_get_pincfg(codec, nid);
1278 snd_printd("realtek: No valid SSID, "
1279 "checking pincfg 0x%08x for NID 0x%x\n",
Takashi Iwaicb6605c2009-04-28 13:03:19 +02001280 ass, nid);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001281 if (!(ass & 1) && !(ass & 0x100000))
1282 return 0;
1283 if ((ass >> 30) != 1) /* no physical connection */
1284 return 0;
1285
1286 /* check sum */
1287 tmp = 0;
1288 for (i = 1; i < 16; i++) {
1289 if ((ass >> i) & 1)
1290 tmp++;
1291 }
1292 if (((ass >> 16) & 0xf) != tmp)
1293 return 0;
1294do_sku:
1295 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1296 ass & 0xffff, codec->vendor_id);
1297 /*
1298 * 0 : override
1299 * 1 : Swap Jack
1300 * 2 : 0 --> Desktop, 1 --> Laptop
1301 * 3~5 : External Amplifier control
1302 * 7~6 : Reserved
1303 */
1304 tmp = (ass & 0x38) >> 3; /* external Amp control */
1305 switch (tmp) {
1306 case 1:
1307 spec->init_amp = ALC_INIT_GPIO1;
1308 break;
1309 case 3:
1310 spec->init_amp = ALC_INIT_GPIO2;
1311 break;
1312 case 7:
1313 spec->init_amp = ALC_INIT_GPIO3;
1314 break;
1315 case 5:
1316 spec->init_amp = ALC_INIT_DEFAULT;
1317 break;
1318 }
1319
1320 /* is laptop or Desktop and enable the function "Mute internal speaker
1321 * when the external headphone out jack is plugged"
1322 */
1323 if (!(ass & 0x8000))
1324 return 1;
1325 /*
1326 * 10~8 : Jack location
1327 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1328 * 14~13: Resvered
1329 * 15 : 1 --> enable the function "Mute internal speaker
1330 * when the external headphone out jack is plugged"
1331 */
Kailang Yangc9b58002007-10-16 14:30:01 +02001332 if (!spec->autocfg.hp_pins[0]) {
1333 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1334 if (tmp == 0)
1335 spec->autocfg.hp_pins[0] = porta;
1336 else if (tmp == 1)
1337 spec->autocfg.hp_pins[0] = porte;
1338 else if (tmp == 2)
1339 spec->autocfg.hp_pins[0] = portd;
1340 else
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001341 return 1;
Kailang Yangc9b58002007-10-16 14:30:01 +02001342 }
1343
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001344 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001345 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001346 return 1;
1347}
Kailang Yangea1fb292008-08-26 12:58:38 +02001348
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001349static void alc_ssid_check(struct hda_codec *codec,
1350 hda_nid_t porta, hda_nid_t porte, hda_nid_t portd)
1351{
1352 if (!alc_subsystem_id(codec, porta, porte, portd)) {
1353 struct alc_spec *spec = codec->spec;
1354 snd_printd("realtek: "
1355 "Enable default setup for auto mode as fallback\n");
1356 spec->init_amp = ALC_INIT_DEFAULT;
1357 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001358 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001359 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001360}
1361
Takashi Iwai41e41f12005-06-08 14:48:49 +02001362/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02001363 * Fix-up pin default configurations
1364 */
1365
1366struct alc_pincfg {
1367 hda_nid_t nid;
1368 u32 val;
1369};
1370
1371static void alc_fix_pincfg(struct hda_codec *codec,
1372 const struct snd_pci_quirk *quirk,
1373 const struct alc_pincfg **pinfix)
1374{
1375 const struct alc_pincfg *cfg;
1376
1377 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1378 if (!quirk)
1379 return;
1380
1381 cfg = pinfix[quirk->value];
Takashi Iwai0e8a21b2009-02-20 14:13:06 +01001382 for (; cfg->nid; cfg++)
1383 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
Takashi Iwaif95474e2007-07-10 00:47:43 +02001384}
1385
1386/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001387 * ALC888
1388 */
1389
1390/*
1391 * 2ch mode
1392 */
1393static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1394/* Mic-in jack as mic in */
1395 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1396 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1397/* Line-in jack as Line in */
1398 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1399 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1400/* Line-Out as Front */
1401 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1402 { } /* end */
1403};
1404
1405/*
1406 * 4ch mode
1407 */
1408static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1409/* Mic-in jack as mic in */
1410 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1411 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1412/* Line-in jack as Surround */
1413 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1414 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1415/* Line-Out as Front */
1416 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1417 { } /* end */
1418};
1419
1420/*
1421 * 6ch mode
1422 */
1423static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1424/* Mic-in jack as CLFE */
1425 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1426 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1427/* Line-in jack as Surround */
1428 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1429 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1430/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1431 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1432 { } /* end */
1433};
1434
1435/*
1436 * 8ch mode
1437 */
1438static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1439/* Mic-in jack as CLFE */
1440 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1441 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1442/* Line-in jack as Surround */
1443 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1444 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1445/* Line-Out as Side */
1446 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1447 { } /* end */
1448};
1449
1450static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1451 { 2, alc888_4ST_ch2_intel_init },
1452 { 4, alc888_4ST_ch4_intel_init },
1453 { 6, alc888_4ST_ch6_intel_init },
1454 { 8, alc888_4ST_ch8_intel_init },
1455};
1456
1457/*
1458 * ALC888 Fujitsu Siemens Amillo xa3530
1459 */
1460
1461static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1462/* Front Mic: set to PIN_IN (empty by default) */
1463 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1464/* Connect Internal HP to Front */
1465 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1466 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1467 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1468/* Connect Bass HP to Front */
1469 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1470 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1471 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1472/* Connect Line-Out side jack (SPDIF) to Side */
1473 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1474 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1475 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1476/* Connect Mic jack to CLFE */
1477 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1478 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1479 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1480/* Connect Line-in jack to Surround */
1481 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1482 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1483 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1484/* Connect HP out jack to Front */
1485 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1486 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1487 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1488/* Enable unsolicited event for HP jack and Line-out jack */
1489 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1490 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1491 {}
1492};
1493
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001494static void alc_automute_amp(struct hda_codec *codec)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001495{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001496 struct alc_spec *spec = codec->spec;
Takashi Iwai261c2402009-06-25 08:13:40 +02001497 unsigned int val, mute, pincap;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001498 hda_nid_t nid;
1499 int i;
1500
1501 spec->jack_present = 0;
1502 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1503 nid = spec->autocfg.hp_pins[i];
1504 if (!nid)
1505 break;
Takashi Iwai261c2402009-06-25 08:13:40 +02001506 pincap = snd_hda_query_pin_caps(codec, nid);
1507 if (pincap & AC_PINCAP_TRIG_REQ) /* need trigger? */
1508 snd_hda_codec_read(codec, nid, 0,
1509 AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001510 val = snd_hda_codec_read(codec, nid, 0,
1511 AC_VERB_GET_PIN_SENSE, 0);
1512 if (val & AC_PINSENSE_PRESENCE) {
1513 spec->jack_present = 1;
1514 break;
1515 }
1516 }
1517
1518 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001519 /* Toggle internal speakers muting */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001520 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1521 nid = spec->autocfg.speaker_pins[i];
1522 if (!nid)
1523 break;
1524 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1525 HDA_AMP_MUTE, mute);
1526 }
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001527}
1528
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001529static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1530 unsigned int res)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001531{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001532 if (codec->vendor_id == 0x10ec0880)
1533 res >>= 28;
1534 else
1535 res >>= 26;
1536 if (res == ALC880_HP_EVENT)
1537 alc_automute_amp(codec);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001538}
1539
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001540static void alc889_automute_setup(struct hda_codec *codec)
Wu Fengguang6732bd02009-07-30 09:19:14 +02001541{
1542 struct alc_spec *spec = codec->spec;
1543
1544 spec->autocfg.hp_pins[0] = 0x15;
1545 spec->autocfg.speaker_pins[0] = 0x14;
1546 spec->autocfg.speaker_pins[1] = 0x16;
1547 spec->autocfg.speaker_pins[2] = 0x17;
1548 spec->autocfg.speaker_pins[3] = 0x19;
1549 spec->autocfg.speaker_pins[4] = 0x1a;
Wu Fengguang6732bd02009-07-30 09:19:14 +02001550}
1551
1552static void alc889_intel_init_hook(struct hda_codec *codec)
1553{
1554 alc889_coef_init(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001555 alc_automute_amp(codec);
Wu Fengguang6732bd02009-07-30 09:19:14 +02001556}
1557
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001558static void alc888_fujitsu_xa3530_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001559{
1560 struct alc_spec *spec = codec->spec;
1561
1562 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1563 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1564 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1565 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001566}
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001567
1568/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001569 * ALC888 Acer Aspire 4930G model
1570 */
1571
1572static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1573/* Front Mic: set to PIN_IN (empty by default) */
1574 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1575/* Unselect Front Mic by default in input mixer 3 */
1576 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001577/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001578 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1579/* Connect Internal HP to front */
1580 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1581 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1582 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1583/* Connect HP out to front */
1584 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1585 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1586 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1587 { }
1588};
1589
Hector Martin3b315d72009-06-02 10:54:19 +02001590/*
Tony Vroond2fd4b02009-06-21 00:40:10 +01001591 * ALC888 Acer Aspire 6530G model
1592 */
1593
1594static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
1595/* Bias voltage on for external mic port */
1596 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
Emilio López320d5922009-06-25 08:18:44 +02001597/* Front Mic: set to PIN_IN (empty by default) */
1598 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1599/* Unselect Front Mic by default in input mixer 3 */
1600 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001601/* Enable unsolicited event for HP jack */
1602 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1603/* Enable speaker output */
1604 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1605 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1606/* Enable headphone output */
1607 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
1608 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1609 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1610 { }
1611};
1612
1613/*
Hector Martin018df412009-06-04 00:13:40 +02001614 * ALC889 Acer Aspire 8930G model
Hector Martin3b315d72009-06-02 10:54:19 +02001615 */
1616
Hector Martin018df412009-06-04 00:13:40 +02001617static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
Hector Martin3b315d72009-06-02 10:54:19 +02001618/* Front Mic: set to PIN_IN (empty by default) */
1619 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1620/* Unselect Front Mic by default in input mixer 3 */
1621 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1622/* Enable unsolicited event for HP jack */
1623 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1624/* Connect Internal Front to Front */
1625 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1626 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1627 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1628/* Connect Internal Rear to Rear */
1629 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1630 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1631 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
1632/* Connect Internal CLFE to CLFE */
1633 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1634 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1635 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
1636/* Connect HP out to Front */
Hector Martin018df412009-06-04 00:13:40 +02001637 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
Hector Martin3b315d72009-06-02 10:54:19 +02001638 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1639 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1640/* Enable all DACs */
1641/* DAC DISABLE/MUTE 1? */
1642/* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
1643 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
1644 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1645/* DAC DISABLE/MUTE 2? */
1646/* some bit here disables the other DACs. Init=0x4900 */
1647 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
1648 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1649/* Enable amplifiers */
1650 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
1651 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
Hector Martin018df412009-06-04 00:13:40 +02001652/* DMIC fix
1653 * This laptop has a stereo digital microphone. The mics are only 1cm apart
1654 * which makes the stereo useless. However, either the mic or the ALC889
1655 * makes the signal become a difference/sum signal instead of standard
1656 * stereo, which is annoying. So instead we flip this bit which makes the
1657 * codec replicate the sum signal to both channels, turning it into a
1658 * normal mono mic.
1659 */
1660/* DMIC_CONTROL? Init value = 0x0001 */
1661 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
1662 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
Hector Martin3b315d72009-06-02 10:54:19 +02001663 { }
1664};
1665
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001666static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001667 /* Front mic only available on one ADC */
1668 {
1669 .num_items = 4,
1670 .items = {
1671 { "Mic", 0x0 },
1672 { "Line", 0x2 },
1673 { "CD", 0x4 },
1674 { "Front Mic", 0xb },
1675 },
1676 },
1677 {
1678 .num_items = 3,
1679 .items = {
1680 { "Mic", 0x0 },
1681 { "Line", 0x2 },
1682 { "CD", 0x4 },
1683 },
1684 }
1685};
1686
Tony Vroond2fd4b02009-06-21 00:40:10 +01001687static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
1688 /* Interal mic only available on one ADC */
1689 {
Tony Vroon684a8842009-06-26 09:27:50 +01001690 .num_items = 5,
Tony Vroond2fd4b02009-06-21 00:40:10 +01001691 .items = {
1692 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01001693 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001694 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01001695 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001696 { "Int Mic", 0xb },
1697 },
1698 },
1699 {
Tony Vroon684a8842009-06-26 09:27:50 +01001700 .num_items = 4,
Tony Vroond2fd4b02009-06-21 00:40:10 +01001701 .items = {
1702 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01001703 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001704 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01001705 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001706 },
1707 }
1708};
1709
Hector Martin018df412009-06-04 00:13:40 +02001710static struct hda_input_mux alc889_capture_sources[3] = {
1711 /* Digital mic only available on first "ADC" */
1712 {
1713 .num_items = 5,
1714 .items = {
1715 { "Mic", 0x0 },
1716 { "Line", 0x2 },
1717 { "CD", 0x4 },
1718 { "Front Mic", 0xb },
1719 { "Input Mix", 0xa },
1720 },
1721 },
1722 {
1723 .num_items = 4,
1724 .items = {
1725 { "Mic", 0x0 },
1726 { "Line", 0x2 },
1727 { "CD", 0x4 },
1728 { "Input Mix", 0xa },
1729 },
1730 },
1731 {
1732 .num_items = 4,
1733 .items = {
1734 { "Mic", 0x0 },
1735 { "Line", 0x2 },
1736 { "CD", 0x4 },
1737 { "Input Mix", 0xa },
1738 },
1739 }
1740};
1741
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001742static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001743 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1744 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1745 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1746 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1747 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1748 HDA_OUTPUT),
1749 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1750 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1751 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1752 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1753 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1754 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1755 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1756 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1757 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1758 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1759 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1760 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001761 { } /* end */
1762};
1763
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001764static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec)
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001765{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001766 struct alc_spec *spec = codec->spec;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001767
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001768 spec->autocfg.hp_pins[0] = 0x15;
1769 spec->autocfg.speaker_pins[0] = 0x14;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001770}
1771
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001772static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
Emilio López320d5922009-06-25 08:18:44 +02001773{
1774 struct alc_spec *spec = codec->spec;
1775
1776 spec->autocfg.hp_pins[0] = 0x15;
1777 spec->autocfg.speaker_pins[0] = 0x14;
1778 spec->autocfg.speaker_pins[1] = 0x16;
1779 spec->autocfg.speaker_pins[2] = 0x17;
Emilio López320d5922009-06-25 08:18:44 +02001780}
1781
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001782static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
Hector Martin3b315d72009-06-02 10:54:19 +02001783{
1784 struct alc_spec *spec = codec->spec;
1785
1786 spec->autocfg.hp_pins[0] = 0x15;
1787 spec->autocfg.speaker_pins[0] = 0x14;
1788 spec->autocfg.speaker_pins[1] = 0x16;
1789 spec->autocfg.speaker_pins[2] = 0x1b;
Hector Martin3b315d72009-06-02 10:54:19 +02001790}
1791
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001792/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001793 * ALC880 3-stack model
1794 *
1795 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001796 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1797 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07001798 */
1799
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001800static hda_nid_t alc880_dac_nids[4] = {
1801 /* front, rear, clfe, rear_surr */
1802 0x02, 0x05, 0x04, 0x03
1803};
1804
1805static hda_nid_t alc880_adc_nids[3] = {
1806 /* ADC0-2 */
1807 0x07, 0x08, 0x09,
1808};
1809
1810/* The datasheet says the node 0x07 is connected from inputs,
1811 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01001812 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07001813 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001814static hda_nid_t alc880_adc_nids_alt[2] = {
1815 /* ADC1-2 */
1816 0x08, 0x09,
1817};
1818
1819#define ALC880_DIGOUT_NID 0x06
1820#define ALC880_DIGIN_NID 0x0a
1821
1822static struct hda_input_mux alc880_capture_source = {
1823 .num_items = 4,
1824 .items = {
1825 { "Mic", 0x0 },
1826 { "Front Mic", 0x3 },
1827 { "Line", 0x2 },
1828 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001829 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001830};
1831
1832/* channel source setting (2/6 channel selection for 3-stack) */
1833/* 2ch mode */
1834static struct hda_verb alc880_threestack_ch2_init[] = {
1835 /* set line-in to input, mute it */
1836 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1837 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1838 /* set mic-in to input vref 80%, mute it */
1839 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1840 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001841 { } /* end */
1842};
1843
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001844/* 6ch mode */
1845static struct hda_verb alc880_threestack_ch6_init[] = {
1846 /* set line-in to output, unmute it */
1847 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1848 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1849 /* set mic-in to output, unmute it */
1850 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1851 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1852 { } /* end */
1853};
1854
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001855static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001856 { 2, alc880_threestack_ch2_init },
1857 { 6, alc880_threestack_ch6_init },
1858};
1859
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001860static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001861 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001862 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001863 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001864 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001865 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1866 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001867 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1868 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001869 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1870 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1871 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1872 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1873 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1874 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1875 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1876 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001877 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001878 {
1879 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1880 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001881 .info = alc_ch_mode_info,
1882 .get = alc_ch_mode_get,
1883 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001884 },
1885 { } /* end */
1886};
1887
1888/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001889static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1890 struct snd_ctl_elem_info *uinfo)
1891{
1892 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1893 struct alc_spec *spec = codec->spec;
1894 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001895
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001896 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001897 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1898 HDA_INPUT);
1899 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001900 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001901 return err;
1902}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001903
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001904static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1905 unsigned int size, unsigned int __user *tlv)
1906{
1907 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1908 struct alc_spec *spec = codec->spec;
1909 int err;
1910
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001911 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001912 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1913 HDA_INPUT);
1914 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001915 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001916 return err;
1917}
1918
1919typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1920 struct snd_ctl_elem_value *ucontrol);
1921
1922static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1923 struct snd_ctl_elem_value *ucontrol,
1924 getput_call_t func)
1925{
1926 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1927 struct alc_spec *spec = codec->spec;
1928 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1929 int err;
1930
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001931 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001932 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
1933 3, 0, HDA_INPUT);
1934 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001935 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001936 return err;
1937}
1938
1939static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
1940 struct snd_ctl_elem_value *ucontrol)
1941{
1942 return alc_cap_getput_caller(kcontrol, ucontrol,
1943 snd_hda_mixer_amp_volume_get);
1944}
1945
1946static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
1947 struct snd_ctl_elem_value *ucontrol)
1948{
1949 return alc_cap_getput_caller(kcontrol, ucontrol,
1950 snd_hda_mixer_amp_volume_put);
1951}
1952
1953/* capture mixer elements */
1954#define alc_cap_sw_info snd_ctl_boolean_stereo_info
1955
1956static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
1957 struct snd_ctl_elem_value *ucontrol)
1958{
1959 return alc_cap_getput_caller(kcontrol, ucontrol,
1960 snd_hda_mixer_amp_switch_get);
1961}
1962
1963static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
1964 struct snd_ctl_elem_value *ucontrol)
1965{
1966 return alc_cap_getput_caller(kcontrol, ucontrol,
1967 snd_hda_mixer_amp_switch_put);
1968}
1969
Takashi Iwaia23b6882009-03-23 15:21:36 +01001970#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001971 { \
1972 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1973 .name = "Capture Switch", \
1974 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1975 .count = num, \
1976 .info = alc_cap_sw_info, \
1977 .get = alc_cap_sw_get, \
1978 .put = alc_cap_sw_put, \
1979 }, \
1980 { \
1981 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1982 .name = "Capture Volume", \
1983 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1984 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1985 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
1986 .count = num, \
1987 .info = alc_cap_vol_info, \
1988 .get = alc_cap_vol_get, \
1989 .put = alc_cap_vol_put, \
1990 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01001991 }
1992
1993#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01001994 { \
1995 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1996 /* .name = "Capture Source", */ \
1997 .name = "Input Source", \
1998 .count = num, \
1999 .info = alc_mux_enum_info, \
2000 .get = alc_mux_enum_get, \
2001 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002002 }
2003
2004#define DEFINE_CAPMIX(num) \
2005static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
2006 _DEFINE_CAPMIX(num), \
2007 _DEFINE_CAPSRC(num), \
2008 { } /* end */ \
2009}
2010
2011#define DEFINE_CAPMIX_NOSRC(num) \
2012static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
2013 _DEFINE_CAPMIX(num), \
2014 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002015}
2016
2017/* up to three ADCs */
2018DEFINE_CAPMIX(1);
2019DEFINE_CAPMIX(2);
2020DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01002021DEFINE_CAPMIX_NOSRC(1);
2022DEFINE_CAPMIX_NOSRC(2);
2023DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002024
2025/*
2026 * ALC880 5-stack model
2027 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002028 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
2029 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002030 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
2031 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
2032 */
2033
2034/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002035static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002036 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002037 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002038 { } /* end */
2039};
2040
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002041/* channel source setting (6/8 channel selection for 5-stack) */
2042/* 6ch mode */
2043static struct hda_verb alc880_fivestack_ch6_init[] = {
2044 /* set line-in to input, mute it */
2045 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2046 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002047 { } /* end */
2048};
2049
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002050/* 8ch mode */
2051static struct hda_verb alc880_fivestack_ch8_init[] = {
2052 /* set line-in to output, unmute it */
2053 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2054 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2055 { } /* end */
2056};
2057
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002058static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002059 { 6, alc880_fivestack_ch6_init },
2060 { 8, alc880_fivestack_ch8_init },
2061};
2062
2063
2064/*
2065 * ALC880 6-stack model
2066 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002067 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
2068 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002069 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
2070 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
2071 */
2072
2073static hda_nid_t alc880_6st_dac_nids[4] = {
2074 /* front, rear, clfe, rear_surr */
2075 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002076};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002077
2078static struct hda_input_mux alc880_6stack_capture_source = {
2079 .num_items = 4,
2080 .items = {
2081 { "Mic", 0x0 },
2082 { "Front Mic", 0x1 },
2083 { "Line", 0x2 },
2084 { "CD", 0x4 },
2085 },
2086};
2087
2088/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002089static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002090 { 8, NULL },
2091};
2092
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002093static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002094 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002095 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002096 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002097 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002098 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2099 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002100 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2101 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002102 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002103 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002104 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2105 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2106 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2107 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2108 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2109 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2110 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2111 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002112 {
2113 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2114 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002115 .info = alc_ch_mode_info,
2116 .get = alc_ch_mode_get,
2117 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002118 },
2119 { } /* end */
2120};
2121
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002122
2123/*
2124 * ALC880 W810 model
2125 *
2126 * W810 has rear IO for:
2127 * Front (DAC 02)
2128 * Surround (DAC 03)
2129 * Center/LFE (DAC 04)
2130 * Digital out (06)
2131 *
2132 * The system also has a pair of internal speakers, and a headphone jack.
2133 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02002134 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002135 * There is a variable resistor to control the speaker or headphone
2136 * volume. This is a hardware-only device without a software API.
2137 *
2138 * Plugging headphones in will disable the internal speakers. This is
2139 * implemented in hardware, not via the driver using jack sense. In
2140 * a similar fashion, plugging into the rear socket marked "front" will
2141 * disable both the speakers and headphones.
2142 *
2143 * For input, there's a microphone jack, and an "audio in" jack.
2144 * These may not do anything useful with this driver yet, because I
2145 * haven't setup any initialization verbs for these yet...
2146 */
2147
2148static hda_nid_t alc880_w810_dac_nids[3] = {
2149 /* front, rear/surround, clfe */
2150 0x02, 0x03, 0x04
2151};
2152
2153/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002154static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002155 { 6, NULL }
2156};
2157
2158/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002159static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002160 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002161 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002162 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002163 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002164 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2165 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002166 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2167 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002168 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2169 { } /* end */
2170};
2171
2172
2173/*
2174 * Z710V model
2175 *
2176 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002177 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2178 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002179 */
2180
2181static hda_nid_t alc880_z71v_dac_nids[1] = {
2182 0x02
2183};
2184#define ALC880_Z71V_HP_DAC 0x03
2185
2186/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002187static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002188 { 2, NULL }
2189};
2190
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002191static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002192 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002193 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002194 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002195 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002196 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("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2199 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2200 { } /* end */
2201};
2202
2203
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002204/*
2205 * ALC880 F1734 model
2206 *
2207 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2208 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2209 */
2210
2211static hda_nid_t alc880_f1734_dac_nids[1] = {
2212 0x03
2213};
2214#define ALC880_F1734_HP_DAC 0x02
2215
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002216static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002217 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002218 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01002219 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2220 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002221 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2222 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01002223 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2224 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002225 { } /* end */
2226};
2227
Takashi Iwai937b4162008-02-11 14:52:36 +01002228static struct hda_input_mux alc880_f1734_capture_source = {
2229 .num_items = 2,
2230 .items = {
2231 { "Mic", 0x1 },
2232 { "CD", 0x4 },
2233 },
2234};
2235
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002236
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002237/*
2238 * ALC880 ASUS model
2239 *
2240 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2241 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2242 * Mic = 0x18, Line = 0x1a
2243 */
2244
2245#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2246#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2247
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002248static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002249 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002250 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002251 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002252 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002253 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2254 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002255 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2256 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002257 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2258 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2259 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2260 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2261 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2262 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002263 {
2264 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2265 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002266 .info = alc_ch_mode_info,
2267 .get = alc_ch_mode_get,
2268 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002269 },
2270 { } /* end */
2271};
2272
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002273/*
2274 * ALC880 ASUS W1V model
2275 *
2276 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2277 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2278 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2279 */
2280
2281/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002282static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002283 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2284 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002285 { } /* end */
2286};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002287
Kailang Yangdf694da2005-12-05 19:42:22 +01002288/* TCL S700 */
2289static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2290 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2291 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2292 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2293 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2294 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2295 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2296 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2297 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2298 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002299 { } /* end */
2300};
2301
Kailang Yangccc656c2006-10-17 12:32:26 +02002302/* Uniwill */
2303static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002304 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2305 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2306 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2307 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002308 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2309 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2310 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2311 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2312 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2313 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2314 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2315 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2316 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2317 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2318 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2319 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002320 {
2321 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2322 .name = "Channel Mode",
2323 .info = alc_ch_mode_info,
2324 .get = alc_ch_mode_get,
2325 .put = alc_ch_mode_put,
2326 },
2327 { } /* end */
2328};
2329
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002330static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2331 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2332 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2333 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2334 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2335 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2336 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2337 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2338 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2339 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2340 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2341 { } /* end */
2342};
2343
Kailang Yangccc656c2006-10-17 12:32:26 +02002344static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002345 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2346 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2347 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2348 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002349 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2350 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2351 { } /* end */
2352};
2353
Linus Torvalds1da177e2005-04-16 15:20:36 -07002354/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01002355 * virtual master controls
2356 */
2357
2358/*
2359 * slave controls for virtual master
2360 */
2361static const char *alc_slave_vols[] = {
2362 "Front Playback Volume",
2363 "Surround Playback Volume",
2364 "Center Playback Volume",
2365 "LFE Playback Volume",
2366 "Side Playback Volume",
2367 "Headphone Playback Volume",
2368 "Speaker Playback Volume",
2369 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002370 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01002371 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002372 NULL,
2373};
2374
2375static const char *alc_slave_sws[] = {
2376 "Front Playback Switch",
2377 "Surround Playback Switch",
2378 "Center Playback Switch",
2379 "LFE Playback Switch",
2380 "Side Playback Switch",
2381 "Headphone Playback Switch",
2382 "Speaker Playback Switch",
2383 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01002384 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002385 NULL,
2386};
2387
2388/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002389 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002390 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002391
2392static void alc_free_kctls(struct hda_codec *codec);
2393
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002394/* additional beep mixers; the actual parameters are overwritten at build */
2395static struct snd_kcontrol_new alc_beep_mixer[] = {
2396 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
2397 HDA_CODEC_MUTE("Beep Playback Switch", 0, 0, HDA_INPUT),
2398 { } /* end */
2399};
2400
Linus Torvalds1da177e2005-04-16 15:20:36 -07002401static int alc_build_controls(struct hda_codec *codec)
2402{
2403 struct alc_spec *spec = codec->spec;
2404 int err;
2405 int i;
2406
2407 for (i = 0; i < spec->num_mixers; i++) {
2408 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2409 if (err < 0)
2410 return err;
2411 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002412 if (spec->cap_mixer) {
2413 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2414 if (err < 0)
2415 return err;
2416 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002417 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002418 err = snd_hda_create_spdif_out_ctls(codec,
2419 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002420 if (err < 0)
2421 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002422 if (!spec->no_analog) {
2423 err = snd_hda_create_spdif_share_sw(codec,
2424 &spec->multiout);
2425 if (err < 0)
2426 return err;
2427 spec->multiout.share_spdif = 1;
2428 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002429 }
2430 if (spec->dig_in_nid) {
2431 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2432 if (err < 0)
2433 return err;
2434 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002435
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002436 /* create beep controls if needed */
2437 if (spec->beep_amp) {
2438 struct snd_kcontrol_new *knew;
2439 for (knew = alc_beep_mixer; knew->name; knew++) {
2440 struct snd_kcontrol *kctl;
2441 kctl = snd_ctl_new1(knew, codec);
2442 if (!kctl)
2443 return -ENOMEM;
2444 kctl->private_value = spec->beep_amp;
2445 err = snd_hda_ctl_add(codec, kctl);
2446 if (err < 0)
2447 return err;
2448 }
2449 }
2450
Takashi Iwai2134ea42008-01-10 16:53:55 +01002451 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002452 if (!spec->no_analog &&
2453 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002454 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002455 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002456 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002457 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002458 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002459 if (err < 0)
2460 return err;
2461 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002462 if (!spec->no_analog &&
2463 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002464 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2465 NULL, alc_slave_sws);
2466 if (err < 0)
2467 return err;
2468 }
2469
Takashi Iwai603c4012008-07-30 15:01:44 +02002470 alc_free_kctls(codec); /* no longer needed */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002471 return 0;
2472}
2473
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002474
Linus Torvalds1da177e2005-04-16 15:20:36 -07002475/*
2476 * initialize the codec volumes, etc
2477 */
2478
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002479/*
2480 * generic initialization of ADC, input mixers and output mixers
2481 */
2482static struct hda_verb alc880_volume_init_verbs[] = {
2483 /*
2484 * Unmute ADC0-2 and set the default input to mic-in
2485 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002486 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002487 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002488 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002489 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002490 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002491 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002492
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002493 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2494 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002495 * Note: PASD motherboards uses the Line In 2 as the input for front
2496 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002497 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002498 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02002499 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2500 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2501 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2502 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2503 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2504 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2505 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002506
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002507 /*
2508 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002509 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002510 /* set vol=0 to output mixers */
2511 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2512 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2513 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2514 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2515 /* set up input amps for analog loopback */
2516 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002517 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2518 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002519 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2520 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002521 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2522 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002523 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2524 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002525
2526 { }
2527};
2528
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002529/*
2530 * 3-stack pin configuration:
2531 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2532 */
2533static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2534 /*
2535 * preset connection lists of input pins
2536 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2537 */
2538 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2539 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2540 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2541
2542 /*
2543 * Set pin mode and muting
2544 */
2545 /* set front pin widgets 0x14 for output */
2546 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2547 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2548 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2549 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2550 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2551 /* Mic2 (as headphone out) for HP output */
2552 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2553 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2554 /* Line In pin widget for input */
2555 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2556 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2557 /* Line2 (as front mic) pin widget for input and vref at 80% */
2558 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2559 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2560 /* CD pin widget for input */
2561 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2562
2563 { }
2564};
2565
2566/*
2567 * 5-stack pin configuration:
2568 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2569 * line-in/side = 0x1a, f-mic = 0x1b
2570 */
2571static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2572 /*
2573 * preset connection lists of input pins
2574 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2575 */
2576 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2577 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2578
2579 /*
2580 * Set pin mode and muting
2581 */
2582 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02002583 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2584 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2585 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2586 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002587 /* unmute pins for output (no gain on this amp) */
2588 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2589 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2590 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2591 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2592
Linus Torvalds1da177e2005-04-16 15:20:36 -07002593 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02002594 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002595 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2596 /* Mic2 (as headphone out) for HP output */
2597 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002598 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002599 /* Line In pin widget for input */
2600 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2601 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2602 /* Line2 (as front mic) pin widget for input and vref at 80% */
2603 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2604 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2605 /* CD pin widget for input */
2606 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002607
2608 { }
2609};
2610
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002611/*
2612 * W810 pin configuration:
2613 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2614 */
2615static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002616 /* hphone/speaker input selector: front DAC */
2617 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2618
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002619 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2620 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2621 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2622 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2623 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2624 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2625
2626 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002627 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002628
Linus Torvalds1da177e2005-04-16 15:20:36 -07002629 { }
2630};
2631
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002632/*
2633 * Z71V pin configuration:
2634 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2635 */
2636static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002637 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002638 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02002639 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002640 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002641
Takashi Iwai16ded522005-06-10 19:58:24 +02002642 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002643 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002644 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002645 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002646
2647 { }
2648};
2649
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002650/*
2651 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002652 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2653 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002654 */
2655static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2656 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2657
Takashi Iwai16ded522005-06-10 19:58:24 +02002658 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002659 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002660 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002661 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002662 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002663 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002664 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002665 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2666
Takashi Iwai16ded522005-06-10 19:58:24 +02002667 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002668 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002669 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002670 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002671 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002672 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002673 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02002674 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002675 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002676
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002677 { }
2678};
Takashi Iwai16ded522005-06-10 19:58:24 +02002679
Kailang Yangccc656c2006-10-17 12:32:26 +02002680/*
2681 * Uniwill pin configuration:
2682 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2683 * line = 0x1a
2684 */
2685static struct hda_verb alc880_uniwill_init_verbs[] = {
2686 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2687
2688 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2689 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2690 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2691 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2692 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2693 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2694 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2695 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2696 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2697 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2698 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2699 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2700 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2701 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2702
2703 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2704 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2705 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2706 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2707 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2708 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2709 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2710 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2711 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2712
2713 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2714 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2715
2716 { }
2717};
2718
2719/*
2720* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02002721* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02002722 */
2723static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2724 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2725
2726 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2727 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2728 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2729 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2730 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2731 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2732 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2733 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2734 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2735 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2736 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2737 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2738
2739 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2740 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2741 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2742 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2743 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2744 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2745
2746 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2747 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2748
2749 { }
2750};
2751
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002752static struct hda_verb alc880_beep_init_verbs[] = {
2753 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2754 { }
2755};
2756
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002757/* auto-toggle front mic */
2758static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2759{
2760 unsigned int present;
2761 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002762
2763 present = snd_hda_codec_read(codec, 0x18, 0,
2764 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002765 bits = present ? HDA_AMP_MUTE : 0;
2766 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002767}
2768
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002769static void alc880_uniwill_setup(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002770{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002771 struct alc_spec *spec = codec->spec;
2772
2773 spec->autocfg.hp_pins[0] = 0x14;
2774 spec->autocfg.speaker_pins[0] = 0x15;
2775 spec->autocfg.speaker_pins[0] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002776}
2777
2778static void alc880_uniwill_init_hook(struct hda_codec *codec)
2779{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002780 alc_automute_amp(codec);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002781 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002782}
2783
2784static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2785 unsigned int res)
2786{
2787 /* Looks like the unsol event is incompatible with the standard
2788 * definition. 4bit tag is placed at 28 bit!
2789 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002790 switch (res >> 28) {
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002791 case ALC880_MIC_EVENT:
2792 alc880_uniwill_mic_automute(codec);
2793 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002794 default:
2795 alc_automute_amp_unsol_event(codec, res);
2796 break;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002797 }
Kailang Yangccc656c2006-10-17 12:32:26 +02002798}
2799
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002800static void alc880_uniwill_p53_setup(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02002801{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002802 struct alc_spec *spec = codec->spec;
Kailang Yangccc656c2006-10-17 12:32:26 +02002803
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002804 spec->autocfg.hp_pins[0] = 0x14;
2805 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yangccc656c2006-10-17 12:32:26 +02002806}
2807
2808static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2809{
2810 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02002811
Kailang Yangccc656c2006-10-17 12:32:26 +02002812 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02002813 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2814 present &= HDA_AMP_VOLMASK;
2815 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2816 HDA_AMP_VOLMASK, present);
2817 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2818 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02002819}
Takashi Iwai47fd8302007-08-10 17:11:07 +02002820
Kailang Yangccc656c2006-10-17 12:32:26 +02002821static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2822 unsigned int res)
2823{
2824 /* Looks like the unsol event is incompatible with the standard
2825 * definition. 4bit tag is placed at 28 bit!
2826 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002827 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02002828 alc880_uniwill_p53_dcvol_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002829 else
2830 alc_automute_amp_unsol_event(codec, res);
Kailang Yangccc656c2006-10-17 12:32:26 +02002831}
2832
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002833/*
2834 * F1734 pin configuration:
2835 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2836 */
2837static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01002838 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002839 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2840 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2841 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2842 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2843
2844 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2845 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2846 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2847 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2848
2849 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2850 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01002851 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002852 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2853 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2854 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2855 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2856 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2857 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002858
Takashi Iwai937b4162008-02-11 14:52:36 +01002859 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2860 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2861
Takashi Iwai16ded522005-06-10 19:58:24 +02002862 { }
2863};
2864
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002865/*
2866 * ASUS pin configuration:
2867 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2868 */
2869static struct hda_verb alc880_pin_asus_init_verbs[] = {
2870 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2871 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2872 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2873 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2874
2875 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2876 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2877 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2878 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2879 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2880 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2881 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2882 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2883
2884 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2885 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2886 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2887 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2888 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2889 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2890 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2891 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2892 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002893
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002894 { }
2895};
2896
2897/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02002898#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2899#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
David Heidelberger64a8be72009-06-08 16:15:18 +02002900#define alc880_gpio3_init_verbs alc_gpio3_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002901
Kailang Yangdf694da2005-12-05 19:42:22 +01002902/* Clevo m520g init */
2903static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2904 /* headphone output */
2905 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2906 /* line-out */
2907 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2908 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2909 /* Line-in */
2910 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2911 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2912 /* CD */
2913 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2914 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2915 /* Mic1 (rear panel) */
2916 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2917 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2918 /* Mic2 (front panel) */
2919 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2920 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2921 /* headphone */
2922 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2923 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2924 /* change to EAPD mode */
2925 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2926 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2927
2928 { }
2929};
2930
2931static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002932 /* change to EAPD mode */
2933 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2934 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2935
Kailang Yangdf694da2005-12-05 19:42:22 +01002936 /* Headphone output */
2937 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2938 /* Front output*/
2939 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2940 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2941
2942 /* Line In pin widget for input */
2943 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2944 /* CD pin widget for input */
2945 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2946 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2947 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2948
2949 /* change to EAPD mode */
2950 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2951 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2952
2953 { }
2954};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002955
2956/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002957 * LG m1 express dual
2958 *
2959 * Pin assignment:
2960 * Rear Line-In/Out (blue): 0x14
2961 * Build-in Mic-In: 0x15
2962 * Speaker-out: 0x17
2963 * HP-Out (green): 0x1b
2964 * Mic-In/Out (red): 0x19
2965 * SPDIF-Out: 0x1e
2966 */
2967
2968/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2969static hda_nid_t alc880_lg_dac_nids[3] = {
2970 0x05, 0x02, 0x03
2971};
2972
2973/* seems analog CD is not working */
2974static struct hda_input_mux alc880_lg_capture_source = {
2975 .num_items = 3,
2976 .items = {
2977 { "Mic", 0x1 },
2978 { "Line", 0x5 },
2979 { "Internal Mic", 0x6 },
2980 },
2981};
2982
2983/* 2,4,6 channel modes */
2984static struct hda_verb alc880_lg_ch2_init[] = {
2985 /* set line-in and mic-in to input */
2986 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2987 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2988 { }
2989};
2990
2991static struct hda_verb alc880_lg_ch4_init[] = {
2992 /* set line-in to out and mic-in to input */
2993 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2994 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2995 { }
2996};
2997
2998static struct hda_verb alc880_lg_ch6_init[] = {
2999 /* set line-in and mic-in to output */
3000 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3001 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3002 { }
3003};
3004
3005static struct hda_channel_mode alc880_lg_ch_modes[3] = {
3006 { 2, alc880_lg_ch2_init },
3007 { 4, alc880_lg_ch4_init },
3008 { 6, alc880_lg_ch6_init },
3009};
3010
3011static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003012 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3013 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003014 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3015 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
3016 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
3017 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
3018 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
3019 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
3020 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3021 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3022 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
3023 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
3024 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
3025 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
3026 {
3027 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3028 .name = "Channel Mode",
3029 .info = alc_ch_mode_info,
3030 .get = alc_ch_mode_get,
3031 .put = alc_ch_mode_put,
3032 },
3033 { } /* end */
3034};
3035
3036static struct hda_verb alc880_lg_init_verbs[] = {
3037 /* set capture source to mic-in */
3038 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3039 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3040 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3041 /* mute all amp mixer inputs */
3042 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003043 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3044 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003045 /* line-in to input */
3046 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3047 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3048 /* built-in mic */
3049 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3050 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3051 /* speaker-out */
3052 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3053 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3054 /* mic-in to input */
3055 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3056 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3057 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3058 /* HP-out */
3059 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
3060 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3061 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3062 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003063 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003064 { }
3065};
3066
3067/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003068static void alc880_lg_setup(struct hda_codec *codec)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003069{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003070 struct alc_spec *spec = codec->spec;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003071
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003072 spec->autocfg.hp_pins[0] = 0x1b;
3073 spec->autocfg.speaker_pins[0] = 0x17;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003074}
3075
3076/*
Takashi Iwaid6815182006-03-23 16:06:23 +01003077 * LG LW20
3078 *
3079 * Pin assignment:
3080 * Speaker-out: 0x14
3081 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003082 * Built-in Mic-In: 0x19
3083 * Line-In: 0x1b
3084 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01003085 * SPDIF-Out: 0x1e
3086 */
3087
Takashi Iwaid6815182006-03-23 16:06:23 +01003088static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003089 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01003090 .items = {
3091 { "Mic", 0x0 },
3092 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003093 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003094 },
3095};
3096
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003097#define alc880_lg_lw_modes alc880_threestack_modes
3098
Takashi Iwaid6815182006-03-23 16:06:23 +01003099static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003100 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3101 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3102 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3103 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
3104 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3105 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3106 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3107 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3108 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3109 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01003110 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3111 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3112 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3113 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003114 {
3115 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3116 .name = "Channel Mode",
3117 .info = alc_ch_mode_info,
3118 .get = alc_ch_mode_get,
3119 .put = alc_ch_mode_put,
3120 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003121 { } /* end */
3122};
3123
3124static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003125 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3126 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3127 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3128
Takashi Iwaid6815182006-03-23 16:06:23 +01003129 /* set capture source to mic-in */
3130 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3131 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3132 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003133 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01003134 /* speaker-out */
3135 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3136 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3137 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01003138 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3139 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3140 /* mic-in to input */
3141 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3142 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3143 /* built-in mic */
3144 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3145 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3146 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003147 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaid6815182006-03-23 16:06:23 +01003148 { }
3149};
3150
3151/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003152static void alc880_lg_lw_setup(struct hda_codec *codec)
Takashi Iwaid6815182006-03-23 16:06:23 +01003153{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003154 struct alc_spec *spec = codec->spec;
Takashi Iwaid6815182006-03-23 16:06:23 +01003155
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003156 spec->autocfg.hp_pins[0] = 0x1b;
3157 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid6815182006-03-23 16:06:23 +01003158}
3159
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003160static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3161 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3162 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3163 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3164 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3165 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3166 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3167 { } /* end */
3168};
3169
3170static struct hda_input_mux alc880_medion_rim_capture_source = {
3171 .num_items = 2,
3172 .items = {
3173 { "Mic", 0x0 },
3174 { "Internal Mic", 0x1 },
3175 },
3176};
3177
3178static struct hda_verb alc880_medion_rim_init_verbs[] = {
3179 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3180
3181 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3182 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3183
3184 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3185 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3186 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3187 /* Mic2 (as headphone out) for HP output */
3188 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3189 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3190 /* Internal Speaker */
3191 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3192 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3193
3194 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3195 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3196
3197 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3198 { }
3199};
3200
3201/* toggle speaker-output according to the hp-jack state */
3202static void alc880_medion_rim_automute(struct hda_codec *codec)
3203{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003204 struct alc_spec *spec = codec->spec;
3205 alc_automute_amp(codec);
3206 /* toggle EAPD */
3207 if (spec->jack_present)
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003208 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3209 else
3210 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3211}
3212
3213static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3214 unsigned int res)
3215{
3216 /* Looks like the unsol event is incompatible with the standard
3217 * definition. 4bit tag is placed at 28 bit!
3218 */
3219 if ((res >> 28) == ALC880_HP_EVENT)
3220 alc880_medion_rim_automute(codec);
3221}
3222
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003223static void alc880_medion_rim_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003224{
3225 struct alc_spec *spec = codec->spec;
3226
3227 spec->autocfg.hp_pins[0] = 0x14;
3228 spec->autocfg.speaker_pins[0] = 0x1b;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003229}
3230
Takashi Iwaicb53c622007-08-10 17:21:45 +02003231#ifdef CONFIG_SND_HDA_POWER_SAVE
3232static struct hda_amp_list alc880_loopbacks[] = {
3233 { 0x0b, HDA_INPUT, 0 },
3234 { 0x0b, HDA_INPUT, 1 },
3235 { 0x0b, HDA_INPUT, 2 },
3236 { 0x0b, HDA_INPUT, 3 },
3237 { 0x0b, HDA_INPUT, 4 },
3238 { } /* end */
3239};
3240
3241static struct hda_amp_list alc880_lg_loopbacks[] = {
3242 { 0x0b, HDA_INPUT, 1 },
3243 { 0x0b, HDA_INPUT, 6 },
3244 { 0x0b, HDA_INPUT, 7 },
3245 { } /* end */
3246};
3247#endif
3248
Takashi Iwaid6815182006-03-23 16:06:23 +01003249/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003250 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003251 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003252
Linus Torvalds1da177e2005-04-16 15:20:36 -07003253static int alc_init(struct hda_codec *codec)
3254{
3255 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003256 unsigned int i;
3257
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003258 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02003259 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003260
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003261 for (i = 0; i < spec->num_init_verbs; i++)
3262 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003263
3264 if (spec->init_hook)
3265 spec->init_hook(codec);
3266
Linus Torvalds1da177e2005-04-16 15:20:36 -07003267 return 0;
3268}
3269
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003270static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3271{
3272 struct alc_spec *spec = codec->spec;
3273
3274 if (spec->unsol_event)
3275 spec->unsol_event(codec, res);
3276}
3277
Takashi Iwaicb53c622007-08-10 17:21:45 +02003278#ifdef CONFIG_SND_HDA_POWER_SAVE
3279static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3280{
3281 struct alc_spec *spec = codec->spec;
3282 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3283}
3284#endif
3285
Linus Torvalds1da177e2005-04-16 15:20:36 -07003286/*
3287 * Analog playback callbacks
3288 */
3289static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3290 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003291 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003292{
3293 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01003294 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3295 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003296}
3297
3298static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3299 struct hda_codec *codec,
3300 unsigned int stream_tag,
3301 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003302 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003303{
3304 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003305 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3306 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003307}
3308
3309static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3310 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003311 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003312{
3313 struct alc_spec *spec = codec->spec;
3314 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3315}
3316
3317/*
3318 * Digital out
3319 */
3320static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3321 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003322 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003323{
3324 struct alc_spec *spec = codec->spec;
3325 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3326}
3327
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003328static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3329 struct hda_codec *codec,
3330 unsigned int stream_tag,
3331 unsigned int format,
3332 struct snd_pcm_substream *substream)
3333{
3334 struct alc_spec *spec = codec->spec;
3335 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3336 stream_tag, format, substream);
3337}
3338
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003339static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3340 struct hda_codec *codec,
3341 struct snd_pcm_substream *substream)
3342{
3343 struct alc_spec *spec = codec->spec;
3344 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3345}
3346
Linus Torvalds1da177e2005-04-16 15:20:36 -07003347static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3348 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003349 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003350{
3351 struct alc_spec *spec = codec->spec;
3352 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3353}
3354
3355/*
3356 * Analog capture
3357 */
Takashi Iwai63300792008-01-24 15:31:36 +01003358static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003359 struct hda_codec *codec,
3360 unsigned int stream_tag,
3361 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003362 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003363{
3364 struct alc_spec *spec = codec->spec;
3365
Takashi Iwai63300792008-01-24 15:31:36 +01003366 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07003367 stream_tag, 0, format);
3368 return 0;
3369}
3370
Takashi Iwai63300792008-01-24 15:31:36 +01003371static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003372 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003373 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003374{
3375 struct alc_spec *spec = codec->spec;
3376
Takashi Iwai888afa12008-03-18 09:57:50 +01003377 snd_hda_codec_cleanup_stream(codec,
3378 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003379 return 0;
3380}
3381
3382
3383/*
3384 */
3385static struct hda_pcm_stream alc880_pcm_analog_playback = {
3386 .substreams = 1,
3387 .channels_min = 2,
3388 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003389 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003390 .ops = {
3391 .open = alc880_playback_pcm_open,
3392 .prepare = alc880_playback_pcm_prepare,
3393 .cleanup = alc880_playback_pcm_cleanup
3394 },
3395};
3396
3397static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01003398 .substreams = 1,
3399 .channels_min = 2,
3400 .channels_max = 2,
3401 /* NID is set in alc_build_pcms */
3402};
3403
3404static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3405 .substreams = 1,
3406 .channels_min = 2,
3407 .channels_max = 2,
3408 /* NID is set in alc_build_pcms */
3409};
3410
3411static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3412 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003413 .channels_min = 2,
3414 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003415 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003416 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01003417 .prepare = alc880_alt_capture_pcm_prepare,
3418 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003419 },
3420};
3421
3422static struct hda_pcm_stream alc880_pcm_digital_playback = {
3423 .substreams = 1,
3424 .channels_min = 2,
3425 .channels_max = 2,
3426 /* NID is set in alc_build_pcms */
3427 .ops = {
3428 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003429 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003430 .prepare = alc880_dig_playback_pcm_prepare,
3431 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003432 },
3433};
3434
3435static struct hda_pcm_stream alc880_pcm_digital_capture = {
3436 .substreams = 1,
3437 .channels_min = 2,
3438 .channels_max = 2,
3439 /* NID is set in alc_build_pcms */
3440};
3441
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003442/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01003443static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003444 .substreams = 0,
3445 .channels_min = 0,
3446 .channels_max = 0,
3447};
3448
Linus Torvalds1da177e2005-04-16 15:20:36 -07003449static int alc_build_pcms(struct hda_codec *codec)
3450{
3451 struct alc_spec *spec = codec->spec;
3452 struct hda_pcm *info = spec->pcm_rec;
3453 int i;
3454
3455 codec->num_pcms = 1;
3456 codec->pcm_info = info;
3457
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003458 if (spec->no_analog)
3459 goto skip_analog;
3460
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003461 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
3462 "%s Analog", codec->chip_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003463 info->name = spec->stream_name_analog;
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003464
Takashi Iwai4a471b72005-12-07 13:56:29 +01003465 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003466 if (snd_BUG_ON(!spec->multiout.dac_nids))
3467 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003468 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3469 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3470 }
3471 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003472 if (snd_BUG_ON(!spec->adc_nids))
3473 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003474 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3475 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3476 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003477
Takashi Iwai4a471b72005-12-07 13:56:29 +01003478 if (spec->channel_mode) {
3479 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3480 for (i = 0; i < spec->num_channel_mode; i++) {
3481 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3482 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3483 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003484 }
3485 }
3486
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003487 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02003488 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003489 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003490 snprintf(spec->stream_name_digital,
3491 sizeof(spec->stream_name_digital),
3492 "%s Digital", codec->chip_name);
Takashi Iwaie08a0072006-09-07 17:52:14 +02003493 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08003494 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003495 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003496 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01003497 if (spec->dig_out_type)
3498 info->pcm_type = spec->dig_out_type;
3499 else
3500 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003501 if (spec->multiout.dig_out_nid &&
3502 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003503 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
3504 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3505 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01003506 if (spec->dig_in_nid &&
3507 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003508 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
3509 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3510 }
Takashi Iwai963f8032008-08-11 10:04:40 +02003511 /* FIXME: do we need this for all Realtek codec models? */
3512 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003513 }
3514
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003515 if (spec->no_analog)
3516 return 0;
3517
Takashi Iwaie08a0072006-09-07 17:52:14 +02003518 /* If the use of more than one ADC is requested for the current
3519 * model, configure a second analog capture-only PCM.
3520 */
3521 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01003522 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
3523 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003524 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003525 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003526 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01003527 if (spec->alt_dac_nid) {
3528 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3529 *spec->stream_analog_alt_playback;
3530 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3531 spec->alt_dac_nid;
3532 } else {
3533 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3534 alc_pcm_null_stream;
3535 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
3536 }
3537 if (spec->num_adc_nids > 1) {
3538 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3539 *spec->stream_analog_alt_capture;
3540 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
3541 spec->adc_nids[1];
3542 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
3543 spec->num_adc_nids - 1;
3544 } else {
3545 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3546 alc_pcm_null_stream;
3547 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003548 }
3549 }
3550
Linus Torvalds1da177e2005-04-16 15:20:36 -07003551 return 0;
3552}
3553
Takashi Iwai603c4012008-07-30 15:01:44 +02003554static void alc_free_kctls(struct hda_codec *codec)
3555{
3556 struct alc_spec *spec = codec->spec;
3557
3558 if (spec->kctls.list) {
3559 struct snd_kcontrol_new *kctl = spec->kctls.list;
3560 int i;
3561 for (i = 0; i < spec->kctls.used; i++)
3562 kfree(kctl[i].name);
3563 }
3564 snd_array_free(&spec->kctls);
3565}
3566
Linus Torvalds1da177e2005-04-16 15:20:36 -07003567static void alc_free(struct hda_codec *codec)
3568{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003569 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003570
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003571 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003572 return;
3573
Takashi Iwai603c4012008-07-30 15:01:44 +02003574 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003575 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09003576 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003577}
3578
Takashi Iwaie044c392008-10-27 16:56:24 +01003579#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01003580static int alc_resume(struct hda_codec *codec)
3581{
Takashi Iwaie044c392008-10-27 16:56:24 +01003582 codec->patch_ops.init(codec);
3583 snd_hda_codec_resume_amp(codec);
3584 snd_hda_codec_resume_cache(codec);
3585 return 0;
3586}
Takashi Iwaie044c392008-10-27 16:56:24 +01003587#endif
3588
Linus Torvalds1da177e2005-04-16 15:20:36 -07003589/*
3590 */
3591static struct hda_codec_ops alc_patch_ops = {
3592 .build_controls = alc_build_controls,
3593 .build_pcms = alc_build_pcms,
3594 .init = alc_init,
3595 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003596 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01003597#ifdef SND_HDA_NEEDS_RESUME
3598 .resume = alc_resume,
3599#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02003600#ifdef CONFIG_SND_HDA_POWER_SAVE
3601 .check_power_status = alc_check_power_status,
3602#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003603};
3604
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003605
3606/*
3607 * Test configuration for debugging
3608 *
3609 * Almost all inputs/outputs are enabled. I/O pins can be configured via
3610 * enum controls.
3611 */
3612#ifdef CONFIG_SND_DEBUG
3613static hda_nid_t alc880_test_dac_nids[4] = {
3614 0x02, 0x03, 0x04, 0x05
3615};
3616
3617static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003618 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003619 .items = {
3620 { "In-1", 0x0 },
3621 { "In-2", 0x1 },
3622 { "In-3", 0x2 },
3623 { "In-4", 0x3 },
3624 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003625 { "Front", 0x5 },
3626 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003627 },
3628};
3629
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003630static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003631 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003632 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003633 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003634 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003635};
3636
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003637static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
3638 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003639{
3640 static char *texts[] = {
3641 "N/A", "Line Out", "HP Out",
3642 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
3643 };
3644 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3645 uinfo->count = 1;
3646 uinfo->value.enumerated.items = 8;
3647 if (uinfo->value.enumerated.item >= 8)
3648 uinfo->value.enumerated.item = 7;
3649 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3650 return 0;
3651}
3652
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003653static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
3654 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003655{
3656 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3657 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3658 unsigned int pin_ctl, item = 0;
3659
3660 pin_ctl = snd_hda_codec_read(codec, nid, 0,
3661 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3662 if (pin_ctl & AC_PINCTL_OUT_EN) {
3663 if (pin_ctl & AC_PINCTL_HP_EN)
3664 item = 2;
3665 else
3666 item = 1;
3667 } else if (pin_ctl & AC_PINCTL_IN_EN) {
3668 switch (pin_ctl & AC_PINCTL_VREFEN) {
3669 case AC_PINCTL_VREF_HIZ: item = 3; break;
3670 case AC_PINCTL_VREF_50: item = 4; break;
3671 case AC_PINCTL_VREF_GRD: item = 5; break;
3672 case AC_PINCTL_VREF_80: item = 6; break;
3673 case AC_PINCTL_VREF_100: item = 7; break;
3674 }
3675 }
3676 ucontrol->value.enumerated.item[0] = item;
3677 return 0;
3678}
3679
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003680static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
3681 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003682{
3683 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3684 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3685 static unsigned int ctls[] = {
3686 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
3687 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
3688 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
3689 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
3690 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
3691 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
3692 };
3693 unsigned int old_ctl, new_ctl;
3694
3695 old_ctl = snd_hda_codec_read(codec, nid, 0,
3696 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3697 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
3698 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003699 int val;
3700 snd_hda_codec_write_cache(codec, nid, 0,
3701 AC_VERB_SET_PIN_WIDGET_CONTROL,
3702 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003703 val = ucontrol->value.enumerated.item[0] >= 3 ?
3704 HDA_AMP_MUTE : 0;
3705 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3706 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003707 return 1;
3708 }
3709 return 0;
3710}
3711
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003712static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
3713 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003714{
3715 static char *texts[] = {
3716 "Front", "Surround", "CLFE", "Side"
3717 };
3718 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3719 uinfo->count = 1;
3720 uinfo->value.enumerated.items = 4;
3721 if (uinfo->value.enumerated.item >= 4)
3722 uinfo->value.enumerated.item = 3;
3723 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3724 return 0;
3725}
3726
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003727static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
3728 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003729{
3730 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3731 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3732 unsigned int sel;
3733
3734 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
3735 ucontrol->value.enumerated.item[0] = sel & 3;
3736 return 0;
3737}
3738
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003739static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
3740 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003741{
3742 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3743 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3744 unsigned int sel;
3745
3746 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
3747 if (ucontrol->value.enumerated.item[0] != sel) {
3748 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003749 snd_hda_codec_write_cache(codec, nid, 0,
3750 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003751 return 1;
3752 }
3753 return 0;
3754}
3755
3756#define PIN_CTL_TEST(xname,nid) { \
3757 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3758 .name = xname, \
3759 .info = alc_test_pin_ctl_info, \
3760 .get = alc_test_pin_ctl_get, \
3761 .put = alc_test_pin_ctl_put, \
3762 .private_value = nid \
3763 }
3764
3765#define PIN_SRC_TEST(xname,nid) { \
3766 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3767 .name = xname, \
3768 .info = alc_test_pin_src_info, \
3769 .get = alc_test_pin_src_get, \
3770 .put = alc_test_pin_src_put, \
3771 .private_value = nid \
3772 }
3773
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003774static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003775 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3776 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3777 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
3778 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003779 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3780 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
3781 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
3782 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003783 PIN_CTL_TEST("Front Pin Mode", 0x14),
3784 PIN_CTL_TEST("Surround Pin Mode", 0x15),
3785 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
3786 PIN_CTL_TEST("Side Pin Mode", 0x17),
3787 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
3788 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
3789 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
3790 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
3791 PIN_SRC_TEST("In-1 Pin Source", 0x18),
3792 PIN_SRC_TEST("In-2 Pin Source", 0x19),
3793 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
3794 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
3795 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
3796 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
3797 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
3798 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
3799 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
3800 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
3801 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
3802 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
3803 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
3804 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003805 {
3806 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3807 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01003808 .info = alc_ch_mode_info,
3809 .get = alc_ch_mode_get,
3810 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003811 },
3812 { } /* end */
3813};
3814
3815static struct hda_verb alc880_test_init_verbs[] = {
3816 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003817 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3818 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3819 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3820 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3821 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3822 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3823 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3824 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003825 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003826 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3827 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3828 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3829 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003830 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003831 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3832 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3833 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3834 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003835 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003836 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3837 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3838 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3839 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003840 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02003841 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3842 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02003843 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3844 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3845 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003846 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02003847 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3848 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3849 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3850 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003851 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02003852 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003853 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003854 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003855 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003856 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003857 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003858 /* Analog input/passthru */
3859 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3860 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3861 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3862 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3863 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003864 { }
3865};
3866#endif
3867
Linus Torvalds1da177e2005-04-16 15:20:36 -07003868/*
3869 */
3870
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003871static const char *alc880_models[ALC880_MODEL_LAST] = {
3872 [ALC880_3ST] = "3stack",
3873 [ALC880_TCL_S700] = "tcl",
3874 [ALC880_3ST_DIG] = "3stack-digout",
3875 [ALC880_CLEVO] = "clevo",
3876 [ALC880_5ST] = "5stack",
3877 [ALC880_5ST_DIG] = "5stack-digout",
3878 [ALC880_W810] = "w810",
3879 [ALC880_Z71V] = "z71v",
3880 [ALC880_6ST] = "6stack",
3881 [ALC880_6ST_DIG] = "6stack-digout",
3882 [ALC880_ASUS] = "asus",
3883 [ALC880_ASUS_W1V] = "asus-w1v",
3884 [ALC880_ASUS_DIG] = "asus-dig",
3885 [ALC880_ASUS_DIG2] = "asus-dig2",
3886 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003887 [ALC880_UNIWILL_P53] = "uniwill-p53",
3888 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003889 [ALC880_F1734] = "F1734",
3890 [ALC880_LG] = "lg",
3891 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003892 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003893#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003894 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003895#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003896 [ALC880_AUTO] = "auto",
3897};
3898
3899static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003900 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003901 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
3902 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
3903 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
3904 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
3905 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
3906 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
3907 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
3908 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003909 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
3910 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003911 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
3912 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
3913 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
3914 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
3915 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
3916 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
3917 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
3918 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
3919 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
3920 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02003921 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003922 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
3923 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
3924 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01003925 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003926 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003927 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
3928 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003929 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
3930 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003931 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
3932 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
3933 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
3934 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003935 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
3936 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003937 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003938 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003939 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003940 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003941 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
3942 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003943 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003944 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003945 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003946 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003947 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02003948 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003949 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003950 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003951 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003952 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
3953 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003954 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003955 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
3956 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
3957 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
3958 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003959 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
3960 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003961 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003962 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003963 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
3964 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003965 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
3966 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
3967 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01003968 /* default Intel */
3969 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003970 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
3971 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003972 {}
3973};
3974
Takashi Iwai16ded522005-06-10 19:58:24 +02003975/*
Kailang Yangdf694da2005-12-05 19:42:22 +01003976 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02003977 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003978static struct alc_config_preset alc880_presets[] = {
3979 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003980 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003981 .init_verbs = { alc880_volume_init_verbs,
3982 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003983 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003984 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003985 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3986 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003987 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003988 .input_mux = &alc880_capture_source,
3989 },
3990 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003991 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003992 .init_verbs = { alc880_volume_init_verbs,
3993 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003994 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003995 .dac_nids = alc880_dac_nids,
3996 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003997 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3998 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003999 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004000 .input_mux = &alc880_capture_source,
4001 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004002 [ALC880_TCL_S700] = {
4003 .mixers = { alc880_tcl_s700_mixer },
4004 .init_verbs = { alc880_volume_init_verbs,
4005 alc880_pin_tcl_S700_init_verbs,
4006 alc880_gpio2_init_verbs },
4007 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4008 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004009 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
4010 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01004011 .hp_nid = 0x03,
4012 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4013 .channel_mode = alc880_2_jack_modes,
4014 .input_mux = &alc880_capture_source,
4015 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004016 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004017 .mixers = { alc880_three_stack_mixer,
4018 alc880_five_stack_mixer},
4019 .init_verbs = { alc880_volume_init_verbs,
4020 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004021 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4022 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004023 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4024 .channel_mode = alc880_fivestack_modes,
4025 .input_mux = &alc880_capture_source,
4026 },
4027 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004028 .mixers = { alc880_three_stack_mixer,
4029 alc880_five_stack_mixer },
4030 .init_verbs = { alc880_volume_init_verbs,
4031 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004032 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4033 .dac_nids = alc880_dac_nids,
4034 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004035 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4036 .channel_mode = alc880_fivestack_modes,
4037 .input_mux = &alc880_capture_source,
4038 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004039 [ALC880_6ST] = {
4040 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004041 .init_verbs = { alc880_volume_init_verbs,
4042 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004043 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4044 .dac_nids = alc880_6st_dac_nids,
4045 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4046 .channel_mode = alc880_sixstack_modes,
4047 .input_mux = &alc880_6stack_capture_source,
4048 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004049 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004050 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004051 .init_verbs = { alc880_volume_init_verbs,
4052 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004053 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4054 .dac_nids = alc880_6st_dac_nids,
4055 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004056 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4057 .channel_mode = alc880_sixstack_modes,
4058 .input_mux = &alc880_6stack_capture_source,
4059 },
4060 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004061 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004062 .init_verbs = { alc880_volume_init_verbs,
4063 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004064 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004065 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
4066 .dac_nids = alc880_w810_dac_nids,
4067 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004068 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
4069 .channel_mode = alc880_w810_modes,
4070 .input_mux = &alc880_capture_source,
4071 },
4072 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004073 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004074 .init_verbs = { alc880_volume_init_verbs,
4075 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004076 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
4077 .dac_nids = alc880_z71v_dac_nids,
4078 .dig_out_nid = ALC880_DIGOUT_NID,
4079 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004080 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4081 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02004082 .input_mux = &alc880_capture_source,
4083 },
4084 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004085 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004086 .init_verbs = { alc880_volume_init_verbs,
4087 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004088 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
4089 .dac_nids = alc880_f1734_dac_nids,
4090 .hp_nid = 0x02,
4091 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4092 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01004093 .input_mux = &alc880_f1734_capture_source,
4094 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004095 .setup = alc880_uniwill_p53_setup,
4096 .init_hook = alc_automute_amp,
Takashi Iwai16ded522005-06-10 19:58:24 +02004097 },
4098 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004099 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004100 .init_verbs = { alc880_volume_init_verbs,
4101 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004102 alc880_gpio1_init_verbs },
4103 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4104 .dac_nids = alc880_asus_dac_nids,
4105 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4106 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004107 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004108 .input_mux = &alc880_capture_source,
4109 },
4110 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004111 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004112 .init_verbs = { alc880_volume_init_verbs,
4113 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004114 alc880_gpio1_init_verbs },
4115 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4116 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004117 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004118 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4119 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004120 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004121 .input_mux = &alc880_capture_source,
4122 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004123 [ALC880_ASUS_DIG2] = {
4124 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004125 .init_verbs = { alc880_volume_init_verbs,
4126 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01004127 alc880_gpio2_init_verbs }, /* use GPIO2 */
4128 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4129 .dac_nids = alc880_asus_dac_nids,
4130 .dig_out_nid = ALC880_DIGOUT_NID,
4131 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4132 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004133 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004134 .input_mux = &alc880_capture_source,
4135 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004136 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004137 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004138 .init_verbs = { alc880_volume_init_verbs,
4139 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004140 alc880_gpio1_init_verbs },
4141 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4142 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004143 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004144 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4145 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004146 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004147 .input_mux = &alc880_capture_source,
4148 },
4149 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004150 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02004151 .init_verbs = { alc880_volume_init_verbs,
4152 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004153 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4154 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004155 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004156 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4157 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004158 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004159 .input_mux = &alc880_capture_source,
4160 },
Kailang Yangccc656c2006-10-17 12:32:26 +02004161 [ALC880_UNIWILL] = {
4162 .mixers = { alc880_uniwill_mixer },
4163 .init_verbs = { alc880_volume_init_verbs,
4164 alc880_uniwill_init_verbs },
4165 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4166 .dac_nids = alc880_asus_dac_nids,
4167 .dig_out_nid = ALC880_DIGOUT_NID,
4168 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4169 .channel_mode = alc880_threestack_modes,
4170 .need_dac_fix = 1,
4171 .input_mux = &alc880_capture_source,
4172 .unsol_event = alc880_uniwill_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004173 .setup = alc880_uniwill_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004174 .init_hook = alc880_uniwill_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004175 },
4176 [ALC880_UNIWILL_P53] = {
4177 .mixers = { alc880_uniwill_p53_mixer },
4178 .init_verbs = { alc880_volume_init_verbs,
4179 alc880_uniwill_p53_init_verbs },
4180 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4181 .dac_nids = alc880_asus_dac_nids,
4182 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004183 .channel_mode = alc880_threestack_modes,
4184 .input_mux = &alc880_capture_source,
4185 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004186 .setup = alc880_uniwill_p53_setup,
4187 .init_hook = alc_automute_amp,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004188 },
4189 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004190 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004191 .init_verbs = { alc880_volume_init_verbs,
4192 alc880_uniwill_p53_init_verbs,
4193 alc880_beep_init_verbs },
4194 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4195 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02004196 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004197 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4198 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02004199 .input_mux = &alc880_capture_source,
4200 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004201 .setup = alc880_uniwill_p53_setup,
4202 .init_hook = alc_automute_amp,
Kailang Yangccc656c2006-10-17 12:32:26 +02004203 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004204 [ALC880_CLEVO] = {
4205 .mixers = { alc880_three_stack_mixer },
4206 .init_verbs = { alc880_volume_init_verbs,
4207 alc880_pin_clevo_init_verbs },
4208 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4209 .dac_nids = alc880_dac_nids,
4210 .hp_nid = 0x03,
4211 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4212 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004213 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004214 .input_mux = &alc880_capture_source,
4215 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004216 [ALC880_LG] = {
4217 .mixers = { alc880_lg_mixer },
4218 .init_verbs = { alc880_volume_init_verbs,
4219 alc880_lg_init_verbs },
4220 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
4221 .dac_nids = alc880_lg_dac_nids,
4222 .dig_out_nid = ALC880_DIGOUT_NID,
4223 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
4224 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004225 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004226 .input_mux = &alc880_lg_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004227 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004228 .setup = alc880_lg_setup,
4229 .init_hook = alc_automute_amp,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004230#ifdef CONFIG_SND_HDA_POWER_SAVE
4231 .loopbacks = alc880_lg_loopbacks,
4232#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004233 },
Takashi Iwaid6815182006-03-23 16:06:23 +01004234 [ALC880_LG_LW] = {
4235 .mixers = { alc880_lg_lw_mixer },
4236 .init_verbs = { alc880_volume_init_verbs,
4237 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004238 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01004239 .dac_nids = alc880_dac_nids,
4240 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004241 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
4242 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01004243 .input_mux = &alc880_lg_lw_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004244 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004245 .setup = alc880_lg_lw_setup,
4246 .init_hook = alc_automute_amp,
Takashi Iwaid6815182006-03-23 16:06:23 +01004247 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004248 [ALC880_MEDION_RIM] = {
4249 .mixers = { alc880_medion_rim_mixer },
4250 .init_verbs = { alc880_volume_init_verbs,
4251 alc880_medion_rim_init_verbs,
4252 alc_gpio2_init_verbs },
4253 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4254 .dac_nids = alc880_dac_nids,
4255 .dig_out_nid = ALC880_DIGOUT_NID,
4256 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4257 .channel_mode = alc880_2_jack_modes,
4258 .input_mux = &alc880_medion_rim_capture_source,
4259 .unsol_event = alc880_medion_rim_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004260 .setup = alc880_medion_rim_setup,
4261 .init_hook = alc880_medion_rim_automute,
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004262 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004263#ifdef CONFIG_SND_DEBUG
4264 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004265 .mixers = { alc880_test_mixer },
4266 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004267 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
4268 .dac_nids = alc880_test_dac_nids,
4269 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004270 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
4271 .channel_mode = alc880_test_modes,
4272 .input_mux = &alc880_test_capture_source,
4273 },
4274#endif
4275};
4276
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004277/*
4278 * Automatic parse of I/O pins from the BIOS configuration
4279 */
4280
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004281enum {
4282 ALC_CTL_WIDGET_VOL,
4283 ALC_CTL_WIDGET_MUTE,
4284 ALC_CTL_BIND_MUTE,
4285};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004286static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004287 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
4288 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01004289 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004290};
4291
4292/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004293static int add_control(struct alc_spec *spec, int type, const char *name,
4294 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004295{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004296 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004297
Takashi Iwai603c4012008-07-30 15:01:44 +02004298 snd_array_init(&spec->kctls, sizeof(*knew), 32);
4299 knew = snd_array_new(&spec->kctls);
4300 if (!knew)
4301 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004302 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07004303 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004304 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004305 return -ENOMEM;
4306 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004307 return 0;
4308}
4309
4310#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
4311#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
4312#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
4313#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
4314#define alc880_is_input_pin(nid) ((nid) >= 0x18)
4315#define alc880_input_pin_idx(nid) ((nid) - 0x18)
4316#define alc880_idx_to_dac(nid) ((nid) + 0x02)
4317#define alc880_dac_to_idx(nid) ((nid) - 0x02)
4318#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
4319#define alc880_idx_to_selector(nid) ((nid) + 0x10)
4320#define ALC880_PIN_CD_NID 0x1c
4321
4322/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004323static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
4324 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004325{
4326 hda_nid_t nid;
4327 int assigned[4];
4328 int i, j;
4329
4330 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004331 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004332
4333 /* check the pins hardwired to audio widget */
4334 for (i = 0; i < cfg->line_outs; i++) {
4335 nid = cfg->line_out_pins[i];
4336 if (alc880_is_fixed_pin(nid)) {
4337 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01004338 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004339 assigned[idx] = 1;
4340 }
4341 }
4342 /* left pins can be connect to any audio widget */
4343 for (i = 0; i < cfg->line_outs; i++) {
4344 nid = cfg->line_out_pins[i];
4345 if (alc880_is_fixed_pin(nid))
4346 continue;
4347 /* search for an empty channel */
4348 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004349 if (!assigned[j]) {
4350 spec->multiout.dac_nids[i] =
4351 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004352 assigned[j] = 1;
4353 break;
4354 }
4355 }
4356 }
4357 spec->multiout.num_dacs = cfg->line_outs;
4358 return 0;
4359}
4360
4361/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01004362static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
4363 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004364{
4365 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004366 static const char *chname[4] = {
4367 "Front", "Surround", NULL /*CLFE*/, "Side"
4368 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004369 hda_nid_t nid;
4370 int i, err;
4371
4372 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004373 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004374 continue;
4375 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4376 if (i == 2) {
4377 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004378 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4379 "Center Playback Volume",
4380 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
4381 HDA_OUTPUT));
4382 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004383 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004384 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4385 "LFE Playback Volume",
4386 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
4387 HDA_OUTPUT));
4388 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004389 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004390 err = add_control(spec, ALC_CTL_BIND_MUTE,
4391 "Center Playback Switch",
4392 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
4393 HDA_INPUT));
4394 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004395 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004396 err = add_control(spec, ALC_CTL_BIND_MUTE,
4397 "LFE Playback Switch",
4398 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
4399 HDA_INPUT));
4400 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004401 return err;
4402 } else {
4403 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004404 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4405 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4406 HDA_OUTPUT));
4407 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004408 return err;
4409 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004410 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4411 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4412 HDA_INPUT));
4413 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004414 return err;
4415 }
4416 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004417 return 0;
4418}
4419
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004420/* add playback controls for speaker and HP outputs */
4421static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
4422 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004423{
4424 hda_nid_t nid;
4425 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004426 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004427
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004428 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004429 return 0;
4430
4431 if (alc880_is_fixed_pin(pin)) {
4432 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01004433 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004434 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004435 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004436 else
4437 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004438 /* control HP volume/switch on the output mixer amp */
4439 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004440 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004441 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4442 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
4443 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004444 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004445 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004446 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4447 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
4448 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004449 return err;
4450 } else if (alc880_is_multi_pin(pin)) {
4451 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004452 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004453 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004454 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4455 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
4456 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004457 return err;
4458 }
4459 return 0;
4460}
4461
4462/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004463static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4464 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01004465 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004466{
4467 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01004468 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004469
4470 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004471 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4472 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4473 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004474 return err;
4475 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004476 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4477 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4478 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004479 return err;
4480 return 0;
4481}
4482
4483/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01004484static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
4485 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004486{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004487 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004488 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004489
4490 for (i = 0; i < AUTO_PIN_LAST; i++) {
4491 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01004492 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01004493 err = new_analog_input(spec, cfg->input_pins[i],
4494 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01004495 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004496 if (err < 0)
4497 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004498 imux->items[imux->num_items].label =
4499 auto_pin_cfg_labels[i];
4500 imux->items[imux->num_items].index =
4501 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004502 imux->num_items++;
4503 }
4504 }
4505 return 0;
4506}
4507
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004508static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
4509 unsigned int pin_type)
4510{
4511 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4512 pin_type);
4513 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01004514 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4515 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004516}
4517
Kailang Yangdf694da2005-12-05 19:42:22 +01004518static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
4519 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004520 int dac_idx)
4521{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004522 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004523 /* need the manual connection? */
4524 if (alc880_is_multi_pin(nid)) {
4525 struct alc_spec *spec = codec->spec;
4526 int idx = alc880_multi_pin_idx(nid);
4527 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
4528 AC_VERB_SET_CONNECT_SEL,
4529 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
4530 }
4531}
4532
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004533static int get_pin_type(int line_out_type)
4534{
4535 if (line_out_type == AUTO_PIN_HP_OUT)
4536 return PIN_HP;
4537 else
4538 return PIN_OUT;
4539}
4540
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004541static void alc880_auto_init_multi_out(struct hda_codec *codec)
4542{
4543 struct alc_spec *spec = codec->spec;
4544 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02004545
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004546 for (i = 0; i < spec->autocfg.line_outs; i++) {
4547 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004548 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4549 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004550 }
4551}
4552
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004553static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004554{
4555 struct alc_spec *spec = codec->spec;
4556 hda_nid_t pin;
4557
Takashi Iwai82bc9552006-03-21 11:24:42 +01004558 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004559 if (pin) /* connect to front */
4560 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004561 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004562 if (pin) /* connect to front */
4563 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
4564}
4565
4566static void alc880_auto_init_analog_input(struct hda_codec *codec)
4567{
4568 struct alc_spec *spec = codec->spec;
4569 int i;
4570
4571 for (i = 0; i < AUTO_PIN_LAST; i++) {
4572 hda_nid_t nid = spec->autocfg.input_pins[i];
4573 if (alc880_is_input_pin(nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01004574 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01004575 if (nid != ALC880_PIN_CD_NID &&
4576 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004577 snd_hda_codec_write(codec, nid, 0,
4578 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004579 AMP_OUT_MUTE);
4580 }
4581 }
4582}
4583
4584/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004585/* return 1 if successful, 0 if the proper config is not found,
4586 * or a negative error code
4587 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004588static int alc880_parse_auto_config(struct hda_codec *codec)
4589{
4590 struct alc_spec *spec = codec->spec;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004591 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +01004592 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004593
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004594 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4595 alc880_ignore);
4596 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004597 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004598 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004599 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01004600
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004601 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
4602 if (err < 0)
4603 return err;
4604 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
4605 if (err < 0)
4606 return err;
4607 err = alc880_auto_create_extra_out(spec,
4608 spec->autocfg.speaker_pins[0],
4609 "Speaker");
4610 if (err < 0)
4611 return err;
4612 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
4613 "Headphone");
4614 if (err < 0)
4615 return err;
4616 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
4617 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004618 return err;
4619
4620 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4621
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004622 /* check multiple SPDIF-out (for recent codecs) */
4623 for (i = 0; i < spec->autocfg.dig_outs; i++) {
4624 hda_nid_t dig_nid;
4625 err = snd_hda_get_connections(codec,
4626 spec->autocfg.dig_out_pins[i],
4627 &dig_nid, 1);
4628 if (err < 0)
4629 continue;
4630 if (!i)
4631 spec->multiout.dig_out_nid = dig_nid;
4632 else {
4633 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
4634 spec->slave_dig_outs[i - 1] = dig_nid;
4635 if (i == ARRAY_SIZE(spec->slave_dig_outs) - 1)
4636 break;
4637 }
4638 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004639 if (spec->autocfg.dig_in_pin)
4640 spec->dig_in_nid = ALC880_DIGIN_NID;
4641
Takashi Iwai603c4012008-07-30 15:01:44 +02004642 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01004643 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004644
Takashi Iwaid88897e2008-10-31 15:01:37 +01004645 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004646
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004647 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004648 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004649
Takashi Iwai4a79ba32009-04-22 16:31:35 +02004650 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
4651
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004652 return 1;
4653}
4654
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004655/* additional initialization for auto-configuration model */
4656static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004657{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004658 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004659 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004660 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004661 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004662 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02004663 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004664}
4665
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004666/* check the ADC/MUX contains all input pins; some ADC/MUX contains only
4667 * one of two digital mic pins, e.g. on ALC272
4668 */
4669static void fixup_automic_adc(struct hda_codec *codec)
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004670{
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004671 struct alc_spec *spec = codec->spec;
4672 int i;
4673
4674 for (i = 0; i < spec->num_adc_nids; i++) {
4675 hda_nid_t cap = spec->capsrc_nids ?
4676 spec->capsrc_nids[i] : spec->adc_nids[i];
4677 int iidx, eidx;
4678
4679 iidx = get_connection_index(codec, cap, spec->int_mic.pin);
4680 if (iidx < 0)
4681 continue;
4682 eidx = get_connection_index(codec, cap, spec->ext_mic.pin);
4683 if (eidx < 0)
4684 continue;
4685 spec->int_mic.mux_idx = iidx;
4686 spec->ext_mic.mux_idx = eidx;
4687 if (spec->capsrc_nids)
4688 spec->capsrc_nids += i;
4689 spec->adc_nids += i;
4690 spec->num_adc_nids = 1;
4691 return;
4692 }
4693 snd_printd(KERN_INFO "hda_codec: %s: "
4694 "No ADC/MUX containing both 0x%x and 0x%x pins\n",
4695 codec->chip_name, spec->int_mic.pin, spec->ext_mic.pin);
4696 spec->auto_mic = 0; /* disable auto-mic to be sure */
4697}
4698
4699static void set_capture_mixer(struct hda_codec *codec)
4700{
4701 struct alc_spec *spec = codec->spec;
Takashi Iwaia23b6882009-03-23 15:21:36 +01004702 static struct snd_kcontrol_new *caps[2][3] = {
4703 { alc_capture_mixer_nosrc1,
4704 alc_capture_mixer_nosrc2,
4705 alc_capture_mixer_nosrc3 },
4706 { alc_capture_mixer1,
4707 alc_capture_mixer2,
4708 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004709 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01004710 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
4711 int mux;
Takashi Iwai2a22d3f2009-08-10 18:54:38 +02004712 if (spec->auto_mic) {
4713 mux = 0;
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004714 fixup_automic_adc(codec);
Takashi Iwai2a22d3f2009-08-10 18:54:38 +02004715 } else if (spec->input_mux && spec->input_mux->num_items > 1)
Takashi Iwaia23b6882009-03-23 15:21:36 +01004716 mux = 1;
4717 else
4718 mux = 0;
4719 spec->cap_mixer = caps[mux][spec->num_adc_nids - 1];
4720 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004721}
4722
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004723#define set_beep_amp(spec, nid, idx, dir) \
4724 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
4725
4726/*
4727 * OK, here we have finally the patch for ALC880
4728 */
4729
Linus Torvalds1da177e2005-04-16 15:20:36 -07004730static int patch_alc880(struct hda_codec *codec)
4731{
4732 struct alc_spec *spec;
4733 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01004734 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004735
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004736 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004737 if (spec == NULL)
4738 return -ENOMEM;
4739
4740 codec->spec = spec;
4741
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004742 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
4743 alc880_models,
4744 alc880_cfg_tbl);
4745 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02004746 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
4747 codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004748 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004749 }
4750
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004751 if (board_config == ALC880_AUTO) {
4752 /* automatic parse from the BIOS config */
4753 err = alc880_parse_auto_config(codec);
4754 if (err < 0) {
4755 alc_free(codec);
4756 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004757 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004758 printk(KERN_INFO
4759 "hda_codec: Cannot set up configuration "
4760 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004761 board_config = ALC880_3ST;
4762 }
4763 }
4764
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09004765 err = snd_hda_attach_beep_device(codec, 0x1);
4766 if (err < 0) {
4767 alc_free(codec);
4768 return err;
4769 }
4770
Kailang Yangdf694da2005-12-05 19:42:22 +01004771 if (board_config != ALC880_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02004772 setup_preset(codec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004773
Linus Torvalds1da177e2005-04-16 15:20:36 -07004774 spec->stream_analog_playback = &alc880_pcm_analog_playback;
4775 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01004776 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004777
Linus Torvalds1da177e2005-04-16 15:20:36 -07004778 spec->stream_digital_playback = &alc880_pcm_digital_playback;
4779 spec->stream_digital_capture = &alc880_pcm_digital_capture;
4780
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004781 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004782 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01004783 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004784 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02004785 wcap = get_wcaps_type(wcap);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004786 if (wcap != AC_WID_AUD_IN) {
4787 spec->adc_nids = alc880_adc_nids_alt;
4788 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004789 } else {
4790 spec->adc_nids = alc880_adc_nids;
4791 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004792 }
4793 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004794 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004795 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004796
Takashi Iwai2134ea42008-01-10 16:53:55 +01004797 spec->vmaster_nid = 0x0c;
4798
Linus Torvalds1da177e2005-04-16 15:20:36 -07004799 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004800 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004801 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02004802#ifdef CONFIG_SND_HDA_POWER_SAVE
4803 if (!spec->loopback.amplist)
4804 spec->loopback.amplist = alc880_loopbacks;
4805#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01004806 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004807
4808 return 0;
4809}
4810
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004811
Linus Torvalds1da177e2005-04-16 15:20:36 -07004812/*
4813 * ALC260 support
4814 */
4815
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004816static hda_nid_t alc260_dac_nids[1] = {
4817 /* front */
4818 0x02,
4819};
4820
4821static hda_nid_t alc260_adc_nids[1] = {
4822 /* ADC0 */
4823 0x04,
4824};
4825
Kailang Yangdf694da2005-12-05 19:42:22 +01004826static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004827 /* ADC1 */
4828 0x05,
4829};
4830
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004831/* NIDs used when simultaneous access to both ADCs makes sense. Note that
4832 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
4833 */
4834static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004835 /* ADC0, ADC1 */
4836 0x04, 0x05
4837};
4838
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004839#define ALC260_DIGOUT_NID 0x03
4840#define ALC260_DIGIN_NID 0x06
4841
4842static struct hda_input_mux alc260_capture_source = {
4843 .num_items = 4,
4844 .items = {
4845 { "Mic", 0x0 },
4846 { "Front Mic", 0x1 },
4847 { "Line", 0x2 },
4848 { "CD", 0x4 },
4849 },
4850};
4851
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004852/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004853 * headphone jack and the internal CD lines since these are the only pins at
4854 * which audio can appear. For flexibility, also allow the option of
4855 * recording the mixer output on the second ADC (ADC0 doesn't have a
4856 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004857 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004858static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
4859 {
4860 .num_items = 3,
4861 .items = {
4862 { "Mic/Line", 0x0 },
4863 { "CD", 0x4 },
4864 { "Headphone", 0x2 },
4865 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004866 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004867 {
4868 .num_items = 4,
4869 .items = {
4870 { "Mic/Line", 0x0 },
4871 { "CD", 0x4 },
4872 { "Headphone", 0x2 },
4873 { "Mixer", 0x5 },
4874 },
4875 },
4876
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004877};
4878
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004879/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
4880 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004881 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004882static struct hda_input_mux alc260_acer_capture_sources[2] = {
4883 {
4884 .num_items = 4,
4885 .items = {
4886 { "Mic", 0x0 },
4887 { "Line", 0x2 },
4888 { "CD", 0x4 },
4889 { "Headphone", 0x5 },
4890 },
4891 },
4892 {
4893 .num_items = 5,
4894 .items = {
4895 { "Mic", 0x0 },
4896 { "Line", 0x2 },
4897 { "CD", 0x4 },
4898 { "Headphone", 0x6 },
4899 { "Mixer", 0x5 },
4900 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004901 },
4902};
Michael Schwingencc959482009-02-22 18:58:45 +01004903
4904/* Maxdata Favorit 100XS */
4905static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
4906 {
4907 .num_items = 2,
4908 .items = {
4909 { "Line/Mic", 0x0 },
4910 { "CD", 0x4 },
4911 },
4912 },
4913 {
4914 .num_items = 3,
4915 .items = {
4916 { "Line/Mic", 0x0 },
4917 { "CD", 0x4 },
4918 { "Mixer", 0x5 },
4919 },
4920 },
4921};
4922
Linus Torvalds1da177e2005-04-16 15:20:36 -07004923/*
4924 * This is just place-holder, so there's something for alc_build_pcms to look
4925 * at when it calculates the maximum number of channels. ALC260 has no mixer
4926 * element which allows changing the channel mode, so the verb list is
4927 * never used.
4928 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004929static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004930 { 2, NULL },
4931};
4932
Kailang Yangdf694da2005-12-05 19:42:22 +01004933
4934/* Mixer combinations
4935 *
4936 * basic: base_output + input + pc_beep + capture
4937 * HP: base_output + input + capture_alt
4938 * HP_3013: hp_3013 + input + capture
4939 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004940 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01004941 */
4942
4943static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004944 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004945 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004946 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4947 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4948 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4949 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4950 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004951};
Kailang Yangdf694da2005-12-05 19:42:22 +01004952
4953static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004954 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4955 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4956 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4957 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4958 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4959 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4960 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
4961 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004962 { } /* end */
4963};
4964
Takashi Iwaibec15c32008-01-28 18:16:30 +01004965/* update HP, line and mono out pins according to the master switch */
4966static void alc260_hp_master_update(struct hda_codec *codec,
4967 hda_nid_t hp, hda_nid_t line,
4968 hda_nid_t mono)
4969{
4970 struct alc_spec *spec = codec->spec;
4971 unsigned int val = spec->master_sw ? PIN_HP : 0;
4972 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004973 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004974 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004975 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004976 val);
4977 /* mono (speaker) depending on the HP jack sense */
4978 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004979 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004980 val);
4981}
4982
4983static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
4984 struct snd_ctl_elem_value *ucontrol)
4985{
4986 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4987 struct alc_spec *spec = codec->spec;
4988 *ucontrol->value.integer.value = spec->master_sw;
4989 return 0;
4990}
4991
4992static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
4993 struct snd_ctl_elem_value *ucontrol)
4994{
4995 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4996 struct alc_spec *spec = codec->spec;
4997 int val = !!*ucontrol->value.integer.value;
4998 hda_nid_t hp, line, mono;
4999
5000 if (val == spec->master_sw)
5001 return 0;
5002 spec->master_sw = val;
5003 hp = (kcontrol->private_value >> 16) & 0xff;
5004 line = (kcontrol->private_value >> 8) & 0xff;
5005 mono = kcontrol->private_value & 0xff;
5006 alc260_hp_master_update(codec, hp, line, mono);
5007 return 1;
5008}
5009
5010static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
5011 {
5012 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5013 .name = "Master Playback Switch",
5014 .info = snd_ctl_boolean_mono_info,
5015 .get = alc260_hp_master_sw_get,
5016 .put = alc260_hp_master_sw_put,
5017 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
5018 },
5019 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5020 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
5021 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5022 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5023 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
5024 HDA_OUTPUT),
5025 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5026 { } /* end */
5027};
5028
5029static struct hda_verb alc260_hp_unsol_verbs[] = {
5030 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5031 {},
5032};
5033
5034static void alc260_hp_automute(struct hda_codec *codec)
5035{
5036 struct alc_spec *spec = codec->spec;
5037 unsigned int present;
5038
5039 present = snd_hda_codec_read(codec, 0x10, 0,
5040 AC_VERB_GET_PIN_SENSE, 0);
5041 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
5042 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
5043}
5044
5045static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
5046{
5047 if ((res >> 26) == ALC880_HP_EVENT)
5048 alc260_hp_automute(codec);
5049}
5050
Kailang Yangdf694da2005-12-05 19:42:22 +01005051static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005052 {
5053 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5054 .name = "Master Playback Switch",
5055 .info = snd_ctl_boolean_mono_info,
5056 .get = alc260_hp_master_sw_get,
5057 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005058 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01005059 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005060 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5061 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5062 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
5063 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
5064 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5065 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01005066 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5067 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02005068 { } /* end */
5069};
5070
Kailang Yang3f878302008-08-26 13:02:23 +02005071static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
5072 .ops = &snd_hda_bind_vol,
5073 .values = {
5074 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
5075 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
5076 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
5077 0
5078 },
5079};
5080
5081static struct hda_bind_ctls alc260_dc7600_bind_switch = {
5082 .ops = &snd_hda_bind_sw,
5083 .values = {
5084 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
5085 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
5086 0
5087 },
5088};
5089
5090static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
5091 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
5092 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
5093 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
5094 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5095 { } /* end */
5096};
5097
Takashi Iwaibec15c32008-01-28 18:16:30 +01005098static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
5099 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5100 {},
5101};
5102
5103static void alc260_hp_3013_automute(struct hda_codec *codec)
5104{
5105 struct alc_spec *spec = codec->spec;
5106 unsigned int present;
5107
5108 present = snd_hda_codec_read(codec, 0x15, 0,
5109 AC_VERB_GET_PIN_SENSE, 0);
5110 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005111 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005112}
5113
5114static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
5115 unsigned int res)
5116{
5117 if ((res >> 26) == ALC880_HP_EVENT)
5118 alc260_hp_3013_automute(codec);
5119}
5120
Kailang Yang3f878302008-08-26 13:02:23 +02005121static void alc260_hp_3012_automute(struct hda_codec *codec)
5122{
5123 unsigned int present, bits;
5124
5125 present = snd_hda_codec_read(codec, 0x10, 0,
5126 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
5127
5128 bits = present ? 0 : PIN_OUT;
5129 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5130 bits);
5131 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5132 bits);
5133 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5134 bits);
5135}
5136
5137static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
5138 unsigned int res)
5139{
5140 if ((res >> 26) == ALC880_HP_EVENT)
5141 alc260_hp_3012_automute(codec);
5142}
5143
5144/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005145 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
5146 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005147static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005148 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005149 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005150 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005151 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5152 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5153 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
5154 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005155 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005156 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5157 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005158 { } /* end */
5159};
5160
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005161/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
5162 * versions of the ALC260 don't act on requests to enable mic bias from NID
5163 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
5164 * datasheet doesn't mention this restriction. At this stage it's not clear
5165 * whether this behaviour is intentional or is a hardware bug in chip
5166 * revisions available in early 2006. Therefore for now allow the
5167 * "Headphone Jack Mode" control to span all choices, but if it turns out
5168 * that the lack of mic bias for this NID is intentional we could change the
5169 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5170 *
5171 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
5172 * don't appear to make the mic bias available from the "line" jack, even
5173 * though the NID used for this jack (0x14) can supply it. The theory is
5174 * that perhaps Acer have included blocking capacitors between the ALC260
5175 * and the output jack. If this turns out to be the case for all such
5176 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
5177 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01005178 *
5179 * The C20x Tablet series have a mono internal speaker which is controlled
5180 * via the chip's Mono sum widget and pin complex, so include the necessary
5181 * controls for such models. On models without a "mono speaker" the control
5182 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005183 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005184static struct snd_kcontrol_new alc260_acer_mixer[] = {
5185 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5186 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005187 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005188 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01005189 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005190 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01005191 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005192 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5193 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5194 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5195 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5196 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5197 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5198 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5199 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005200 { } /* end */
5201};
5202
Michael Schwingencc959482009-02-22 18:58:45 +01005203/* Maxdata Favorit 100XS: one output and one input (0x12) jack
5204 */
5205static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
5206 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5207 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
5208 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
5209 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5210 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5211 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5212 { } /* end */
5213};
5214
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005215/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
5216 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
5217 */
5218static struct snd_kcontrol_new alc260_will_mixer[] = {
5219 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5220 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5221 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5222 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5223 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5224 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5225 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5226 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5227 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5228 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005229 { } /* end */
5230};
5231
5232/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
5233 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
5234 */
5235static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
5236 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5237 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5238 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5239 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5240 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5241 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
5242 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
5243 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5244 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5245 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5246 { } /* end */
5247};
5248
Kailang Yangdf694da2005-12-05 19:42:22 +01005249/*
5250 * initialization verbs
5251 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07005252static struct hda_verb alc260_init_verbs[] = {
5253 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005254 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005255 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005256 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005257 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005258 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005259 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005260 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005261 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02005262 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005263 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01005264 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005265 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02005266 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005267 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02005268 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005269 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02005270 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5271 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02005272 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005273 /* set connection select to line in (default select for this ADC) */
5274 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02005275 /* mute capture amp left and right */
5276 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5277 /* set connection select to line in (default select for this ADC) */
5278 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02005279 /* set vol=0 Line-Out mixer amp left and right */
5280 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5281 /* unmute pin widget amp left and right (no gain on this amp) */
5282 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5283 /* set vol=0 HP mixer amp left and right */
5284 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5285 /* unmute pin widget amp left and right (no gain on this amp) */
5286 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5287 /* set vol=0 Mono mixer amp left and right */
5288 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5289 /* unmute pin widget amp left and right (no gain on this amp) */
5290 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5291 /* unmute LINE-2 out pin */
5292 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005293 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5294 * Line In 2 = 0x03
5295 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005296 /* mute analog inputs */
5297 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5298 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5299 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5300 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5301 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005302 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005303 /* mute Front out path */
5304 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5305 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5306 /* mute Headphone out path */
5307 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5308 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5309 /* mute Mono out path */
5310 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5311 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005312 { }
5313};
5314
Takashi Iwai474167d2006-05-17 17:17:43 +02005315#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01005316static struct hda_verb alc260_hp_init_verbs[] = {
5317 /* Headphone and output */
5318 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5319 /* mono output */
5320 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5321 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5322 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5323 /* Mic2 (front panel) pin widget for input and vref at 80% */
5324 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5325 /* Line In pin widget for input */
5326 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5327 /* Line-2 pin widget for output */
5328 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5329 /* CD pin widget for input */
5330 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5331 /* unmute amp left and right */
5332 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5333 /* set connection select to line in (default select for this ADC) */
5334 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5335 /* unmute Line-Out mixer amp left and right (volume = 0) */
5336 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5337 /* mute pin widget amp left and right (no gain on this amp) */
5338 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5339 /* unmute HP mixer amp left and right (volume = 0) */
5340 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5341 /* mute pin widget amp left and right (no gain on this amp) */
5342 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005343 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5344 * Line In 2 = 0x03
5345 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005346 /* mute analog inputs */
5347 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5348 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5349 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5350 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5351 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005352 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5353 /* Unmute Front out path */
5354 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5355 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5356 /* Unmute Headphone out path */
5357 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5358 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5359 /* Unmute Mono out path */
5360 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5361 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5362 { }
5363};
Takashi Iwai474167d2006-05-17 17:17:43 +02005364#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005365
5366static struct hda_verb alc260_hp_3013_init_verbs[] = {
5367 /* Line out and output */
5368 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5369 /* mono output */
5370 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5371 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5372 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5373 /* Mic2 (front panel) pin widget for input and vref at 80% */
5374 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5375 /* Line In pin widget for input */
5376 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5377 /* Headphone pin widget for output */
5378 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5379 /* CD pin widget for input */
5380 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5381 /* unmute amp left and right */
5382 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5383 /* set connection select to line in (default select for this ADC) */
5384 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5385 /* unmute Line-Out mixer amp left and right (volume = 0) */
5386 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5387 /* mute pin widget amp left and right (no gain on this amp) */
5388 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5389 /* unmute HP mixer amp left and right (volume = 0) */
5390 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5391 /* mute pin widget amp left and right (no gain on this amp) */
5392 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005393 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5394 * Line In 2 = 0x03
5395 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005396 /* mute analog inputs */
5397 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5398 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5399 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5400 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5401 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005402 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5403 /* Unmute Front out path */
5404 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5405 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5406 /* Unmute Headphone out path */
5407 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5408 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5409 /* Unmute Mono out path */
5410 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5411 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5412 { }
5413};
5414
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005415/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005416 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
5417 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005418 */
5419static struct hda_verb alc260_fujitsu_init_verbs[] = {
5420 /* Disable all GPIOs */
5421 {0x01, AC_VERB_SET_GPIO_MASK, 0},
5422 /* Internal speaker is connected to headphone pin */
5423 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5424 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
5425 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005426 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
5427 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5428 /* Ensure all other unused pins are disabled and muted. */
5429 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5430 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005431 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005432 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005433 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005434 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5435 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5436 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005437
Jonathan Woithef7ace402006-02-28 11:46:14 +01005438 /* Disable digital (SPDIF) pins */
5439 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5440 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005441
Kailang Yangea1fb292008-08-26 12:58:38 +02005442 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01005443 * when acting as an output.
5444 */
5445 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5446
5447 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01005448 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5449 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5450 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5451 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5452 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5453 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5454 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5455 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5456 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005457
Jonathan Woithef7ace402006-02-28 11:46:14 +01005458 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
5459 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5460 /* Unmute Line1 pin widget output buffer since it starts as an output.
5461 * If the pin mode is changed by the user the pin mode control will
5462 * take care of enabling the pin's input/output buffers as needed.
5463 * Therefore there's no need to enable the input buffer at this
5464 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005465 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005466 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02005467 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005468 * mixer ctrl)
5469 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005470 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005471
Jonathan Woithef7ace402006-02-28 11:46:14 +01005472 /* Mute capture amp left and right */
5473 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005474 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01005475 * in (on mic1 pin)
5476 */
5477 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005478
Jonathan Woithef7ace402006-02-28 11:46:14 +01005479 /* Do the same for the second ADC: mute capture input amp and
5480 * set ADC connection to line in (on mic1 pin)
5481 */
5482 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5483 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005484
Jonathan Woithef7ace402006-02-28 11:46:14 +01005485 /* Mute all inputs to mixer widget (even unconnected ones) */
5486 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5487 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5488 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5489 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5490 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5491 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5492 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5493 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005494
5495 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005496};
5497
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005498/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
5499 * similar laptops (adapted from Fujitsu init verbs).
5500 */
5501static struct hda_verb alc260_acer_init_verbs[] = {
5502 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
5503 * the headphone jack. Turn this on and rely on the standard mute
5504 * methods whenever the user wants to turn these outputs off.
5505 */
5506 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5507 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5508 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5509 /* Internal speaker/Headphone jack is connected to Line-out pin */
5510 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5511 /* Internal microphone/Mic jack is connected to Mic1 pin */
5512 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5513 /* Line In jack is connected to Line1 pin */
5514 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01005515 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
5516 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005517 /* Ensure all other unused pins are disabled and muted. */
5518 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5519 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005520 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5521 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5522 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5523 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5524 /* Disable digital (SPDIF) pins */
5525 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5526 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5527
Kailang Yangea1fb292008-08-26 12:58:38 +02005528 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005529 * bus when acting as outputs.
5530 */
5531 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5532 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5533
5534 /* Start with output sum widgets muted and their output gains at min */
5535 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5536 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5537 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5538 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5539 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5540 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5541 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5542 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5543 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5544
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005545 /* Unmute Line-out pin widget amp left and right
5546 * (no equiv mixer ctrl)
5547 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005548 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01005549 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
5550 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005551 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5552 * inputs. If the pin mode is changed by the user the pin mode control
5553 * will take care of enabling the pin's input/output buffers as needed.
5554 * Therefore there's no need to enable the input buffer at this
5555 * stage.
5556 */
5557 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5558 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5559
5560 /* Mute capture amp left and right */
5561 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5562 /* Set ADC connection select to match default mixer setting - mic
5563 * (on mic1 pin)
5564 */
5565 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5566
5567 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005568 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005569 */
5570 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005571 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005572
5573 /* Mute all inputs to mixer widget (even unconnected ones) */
5574 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5575 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5576 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5577 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5578 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5579 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5580 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5581 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5582
5583 { }
5584};
5585
Michael Schwingencc959482009-02-22 18:58:45 +01005586/* Initialisation sequence for Maxdata Favorit 100XS
5587 * (adapted from Acer init verbs).
5588 */
5589static struct hda_verb alc260_favorit100_init_verbs[] = {
5590 /* GPIO 0 enables the output jack.
5591 * Turn this on and rely on the standard mute
5592 * methods whenever the user wants to turn these outputs off.
5593 */
5594 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5595 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5596 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5597 /* Line/Mic input jack is connected to Mic1 pin */
5598 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5599 /* Ensure all other unused pins are disabled and muted. */
5600 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5601 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5602 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5603 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5604 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5605 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5606 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5607 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5608 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5609 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5610 /* Disable digital (SPDIF) pins */
5611 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5612 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5613
5614 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
5615 * bus when acting as outputs.
5616 */
5617 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5618 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5619
5620 /* Start with output sum widgets muted and their output gains at min */
5621 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5622 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5623 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5624 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5625 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5626 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5627 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5628 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5629 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5630
5631 /* Unmute Line-out pin widget amp left and right
5632 * (no equiv mixer ctrl)
5633 */
5634 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5635 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5636 * inputs. If the pin mode is changed by the user the pin mode control
5637 * will take care of enabling the pin's input/output buffers as needed.
5638 * Therefore there's no need to enable the input buffer at this
5639 * stage.
5640 */
5641 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5642
5643 /* Mute capture amp left and right */
5644 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5645 /* Set ADC connection select to match default mixer setting - mic
5646 * (on mic1 pin)
5647 */
5648 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5649
5650 /* Do similar with the second ADC: mute capture input amp and
5651 * set ADC connection to mic to match ALSA's default state.
5652 */
5653 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5654 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5655
5656 /* Mute all inputs to mixer widget (even unconnected ones) */
5657 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5658 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5659 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5660 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5661 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5662 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5663 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5664 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5665
5666 { }
5667};
5668
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005669static struct hda_verb alc260_will_verbs[] = {
5670 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5671 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
5672 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
5673 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5674 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5675 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
5676 {}
5677};
5678
5679static struct hda_verb alc260_replacer_672v_verbs[] = {
5680 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5681 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5682 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
5683
5684 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5685 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5686 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5687
5688 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5689 {}
5690};
5691
5692/* toggle speaker-output according to the hp-jack state */
5693static void alc260_replacer_672v_automute(struct hda_codec *codec)
5694{
5695 unsigned int present;
5696
5697 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
5698 present = snd_hda_codec_read(codec, 0x0f, 0,
5699 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5700 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005701 snd_hda_codec_write_cache(codec, 0x01, 0,
5702 AC_VERB_SET_GPIO_DATA, 1);
5703 snd_hda_codec_write_cache(codec, 0x0f, 0,
5704 AC_VERB_SET_PIN_WIDGET_CONTROL,
5705 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005706 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005707 snd_hda_codec_write_cache(codec, 0x01, 0,
5708 AC_VERB_SET_GPIO_DATA, 0);
5709 snd_hda_codec_write_cache(codec, 0x0f, 0,
5710 AC_VERB_SET_PIN_WIDGET_CONTROL,
5711 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005712 }
5713}
5714
5715static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
5716 unsigned int res)
5717{
5718 if ((res >> 26) == ALC880_HP_EVENT)
5719 alc260_replacer_672v_automute(codec);
5720}
5721
Kailang Yang3f878302008-08-26 13:02:23 +02005722static struct hda_verb alc260_hp_dc7600_verbs[] = {
5723 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
5724 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5725 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5726 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5727 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5728 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5729 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5730 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5731 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5732 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5733 {}
5734};
5735
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005736/* Test configuration for debugging, modelled after the ALC880 test
5737 * configuration.
5738 */
5739#ifdef CONFIG_SND_DEBUG
5740static hda_nid_t alc260_test_dac_nids[1] = {
5741 0x02,
5742};
5743static hda_nid_t alc260_test_adc_nids[2] = {
5744 0x04, 0x05,
5745};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005746/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02005747 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005748 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005749 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005750static struct hda_input_mux alc260_test_capture_sources[2] = {
5751 {
5752 .num_items = 7,
5753 .items = {
5754 { "MIC1 pin", 0x0 },
5755 { "MIC2 pin", 0x1 },
5756 { "LINE1 pin", 0x2 },
5757 { "LINE2 pin", 0x3 },
5758 { "CD pin", 0x4 },
5759 { "LINE-OUT pin", 0x5 },
5760 { "HP-OUT pin", 0x6 },
5761 },
5762 },
5763 {
5764 .num_items = 8,
5765 .items = {
5766 { "MIC1 pin", 0x0 },
5767 { "MIC2 pin", 0x1 },
5768 { "LINE1 pin", 0x2 },
5769 { "LINE2 pin", 0x3 },
5770 { "CD pin", 0x4 },
5771 { "Mixer", 0x5 },
5772 { "LINE-OUT pin", 0x6 },
5773 { "HP-OUT pin", 0x7 },
5774 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005775 },
5776};
5777static struct snd_kcontrol_new alc260_test_mixer[] = {
5778 /* Output driver widgets */
5779 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5780 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5781 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5782 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
5783 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5784 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
5785
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005786 /* Modes for retasking pin widgets
5787 * Note: the ALC260 doesn't seem to act on requests to enable mic
5788 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
5789 * mention this restriction. At this stage it's not clear whether
5790 * this behaviour is intentional or is a hardware bug in chip
5791 * revisions available at least up until early 2006. Therefore for
5792 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
5793 * choices, but if it turns out that the lack of mic bias for these
5794 * NIDs is intentional we could change their modes from
5795 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5796 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005797 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
5798 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
5799 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
5800 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
5801 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
5802 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
5803
5804 /* Loopback mixer controls */
5805 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
5806 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
5807 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
5808 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
5809 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
5810 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
5811 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
5812 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
5813 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5814 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005815 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
5816 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
5817 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
5818 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005819
5820 /* Controls for GPIO pins, assuming they are configured as outputs */
5821 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
5822 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
5823 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
5824 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
5825
Jonathan Woithe92621f12006-02-28 11:47:47 +01005826 /* Switches to allow the digital IO pins to be enabled. The datasheet
5827 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02005828 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01005829 */
5830 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
5831 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
5832
Jonathan Woithef8225f62008-01-08 12:16:54 +01005833 /* A switch allowing EAPD to be enabled. Some laptops seem to use
5834 * this output to turn on an external amplifier.
5835 */
5836 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
5837 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
5838
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005839 { } /* end */
5840};
5841static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005842 /* Enable all GPIOs as outputs with an initial value of 0 */
5843 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
5844 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5845 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
5846
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005847 /* Enable retasking pins as output, initially without power amp */
5848 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5849 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5850 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5851 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5852 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5853 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5854
Jonathan Woithe92621f12006-02-28 11:47:47 +01005855 /* Disable digital (SPDIF) pins initially, but users can enable
5856 * them via a mixer switch. In the case of SPDIF-out, this initverb
5857 * payload also sets the generation to 0, output to be in "consumer"
5858 * PCM format, copyright asserted, no pre-emphasis and no validity
5859 * control.
5860 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005861 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5862 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5863
Kailang Yangea1fb292008-08-26 12:58:38 +02005864 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005865 * OUT1 sum bus when acting as an output.
5866 */
5867 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5868 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
5869 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5870 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
5871
5872 /* Start with output sum widgets muted and their output gains at min */
5873 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5874 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5875 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5876 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5877 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5878 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5879 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5880 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5881 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5882
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005883 /* Unmute retasking pin widget output buffers since the default
5884 * state appears to be output. As the pin mode is changed by the
5885 * user the pin mode control will take care of enabling the pin's
5886 * input/output buffers as needed.
5887 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005888 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5889 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5890 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5891 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5892 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5893 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5894 /* Also unmute the mono-out pin widget */
5895 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5896
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005897 /* Mute capture amp left and right */
5898 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005899 /* Set ADC connection select to match default mixer setting (mic1
5900 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005901 */
5902 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5903
5904 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01005905 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005906 */
5907 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5908 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5909
5910 /* Mute all inputs to mixer widget (even unconnected ones) */
5911 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5912 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5913 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5914 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5915 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5916 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5917 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5918 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5919
5920 { }
5921};
5922#endif
5923
Takashi Iwai63300792008-01-24 15:31:36 +01005924#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
5925#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07005926
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005927#define alc260_pcm_digital_playback alc880_pcm_digital_playback
5928#define alc260_pcm_digital_capture alc880_pcm_digital_capture
5929
Kailang Yangdf694da2005-12-05 19:42:22 +01005930/*
5931 * for BIOS auto-configuration
5932 */
5933
5934static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02005935 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01005936{
5937 hda_nid_t nid_vol;
5938 unsigned long vol_val, sw_val;
5939 char name[32];
5940 int err;
5941
5942 if (nid >= 0x0f && nid < 0x11) {
5943 nid_vol = nid - 0x7;
5944 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5945 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5946 } else if (nid == 0x11) {
5947 nid_vol = nid - 0x7;
5948 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
5949 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
5950 } else if (nid >= 0x12 && nid <= 0x15) {
5951 nid_vol = 0x08;
5952 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5953 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5954 } else
5955 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02005956
Takashi Iwai863b4512008-10-21 17:01:47 +02005957 if (!(*vol_bits & (1 << nid_vol))) {
5958 /* first control for the volume widget */
5959 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
5960 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
5961 if (err < 0)
5962 return err;
5963 *vol_bits |= (1 << nid_vol);
5964 }
Kailang Yangdf694da2005-12-05 19:42:22 +01005965 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005966 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
5967 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005968 return err;
5969 return 1;
5970}
5971
5972/* add playback controls from the parsed DAC table */
5973static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
5974 const struct auto_pin_cfg *cfg)
5975{
5976 hda_nid_t nid;
5977 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02005978 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005979
5980 spec->multiout.num_dacs = 1;
5981 spec->multiout.dac_nids = spec->private_dac_nids;
5982 spec->multiout.dac_nids[0] = 0x02;
5983
5984 nid = cfg->line_out_pins[0];
5985 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005986 err = alc260_add_playback_controls(spec, nid, "Front", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005987 if (err < 0)
5988 return err;
5989 }
5990
Takashi Iwai82bc9552006-03-21 11:24:42 +01005991 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005992 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005993 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005994 if (err < 0)
5995 return err;
5996 }
5997
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005998 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005999 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006000 err = alc260_add_playback_controls(spec, nid, "Headphone",
6001 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006002 if (err < 0)
6003 return err;
6004 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006005 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006006}
6007
6008/* create playback/capture controls for input pins */
6009static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
6010 const struct auto_pin_cfg *cfg)
6011{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02006012 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006013 int i, err, idx;
6014
6015 for (i = 0; i < AUTO_PIN_LAST; i++) {
6016 if (cfg->input_pins[i] >= 0x12) {
6017 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01006018 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006019 auto_pin_cfg_labels[i], idx,
6020 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01006021 if (err < 0)
6022 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006023 imux->items[imux->num_items].label =
6024 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01006025 imux->items[imux->num_items].index = idx;
6026 imux->num_items++;
6027 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006028 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01006029 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01006030 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006031 auto_pin_cfg_labels[i], idx,
6032 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01006033 if (err < 0)
6034 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006035 imux->items[imux->num_items].label =
6036 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01006037 imux->items[imux->num_items].index = idx;
6038 imux->num_items++;
6039 }
6040 }
6041 return 0;
6042}
6043
6044static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
6045 hda_nid_t nid, int pin_type,
6046 int sel_idx)
6047{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006048 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006049 /* need the manual connection? */
6050 if (nid >= 0x12) {
6051 int idx = nid - 0x12;
6052 snd_hda_codec_write(codec, idx + 0x0b, 0,
6053 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01006054 }
6055}
6056
6057static void alc260_auto_init_multi_out(struct hda_codec *codec)
6058{
6059 struct alc_spec *spec = codec->spec;
6060 hda_nid_t nid;
6061
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006062 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006063 if (nid) {
6064 int pin_type = get_pin_type(spec->autocfg.line_out_type);
6065 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
6066 }
Kailang Yangea1fb292008-08-26 12:58:38 +02006067
Takashi Iwai82bc9552006-03-21 11:24:42 +01006068 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006069 if (nid)
6070 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
6071
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006072 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006073 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006074 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006075}
Kailang Yangdf694da2005-12-05 19:42:22 +01006076
6077#define ALC260_PIN_CD_NID 0x16
6078static void alc260_auto_init_analog_input(struct hda_codec *codec)
6079{
6080 struct alc_spec *spec = codec->spec;
6081 int i;
6082
6083 for (i = 0; i < AUTO_PIN_LAST; i++) {
6084 hda_nid_t nid = spec->autocfg.input_pins[i];
6085 if (nid >= 0x12) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01006086 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01006087 if (nid != ALC260_PIN_CD_NID &&
6088 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006089 snd_hda_codec_write(codec, nid, 0,
6090 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01006091 AMP_OUT_MUTE);
6092 }
6093 }
6094}
6095
6096/*
6097 * generic initialization of ADC, input mixers and output mixers
6098 */
6099static struct hda_verb alc260_volume_init_verbs[] = {
6100 /*
6101 * Unmute ADC0-1 and set the default input to mic-in
6102 */
6103 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6104 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6105 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6106 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006107
Kailang Yangdf694da2005-12-05 19:42:22 +01006108 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6109 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006110 * Note: PASD motherboards uses the Line In 2 as the input for
6111 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006112 */
6113 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006114 /* mute analog inputs */
6115 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6116 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6117 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6118 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6119 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006120
6121 /*
6122 * Set up output mixers (0x08 - 0x0a)
6123 */
6124 /* set vol=0 to output mixers */
6125 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6126 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6127 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6128 /* set up input amps for analog loopback */
6129 /* Amp Indices: DAC = 0, mixer = 1 */
6130 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6131 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6132 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6133 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6134 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6135 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006136
Kailang Yangdf694da2005-12-05 19:42:22 +01006137 { }
6138};
6139
6140static int alc260_parse_auto_config(struct hda_codec *codec)
6141{
6142 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006143 int err;
6144 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
6145
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006146 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
6147 alc260_ignore);
6148 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006149 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006150 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
6151 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01006152 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02006153 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01006154 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006155 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
6156 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006157 return err;
6158
6159 spec->multiout.max_channels = 2;
6160
Takashi Iwai0852d7a2009-02-11 11:35:15 +01006161 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01006162 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02006163 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01006164 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01006165
Takashi Iwaid88897e2008-10-31 15:01:37 +01006166 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01006167
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006168 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02006169 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006170
Takashi Iwai4a79ba32009-04-22 16:31:35 +02006171 alc_ssid_check(codec, 0x10, 0x15, 0x0f);
6172
Kailang Yangdf694da2005-12-05 19:42:22 +01006173 return 1;
6174}
6175
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006176/* additional initialization for auto-configuration model */
6177static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006178{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006179 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006180 alc260_auto_init_multi_out(codec);
6181 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006182 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02006183 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006184}
6185
Takashi Iwaicb53c622007-08-10 17:21:45 +02006186#ifdef CONFIG_SND_HDA_POWER_SAVE
6187static struct hda_amp_list alc260_loopbacks[] = {
6188 { 0x07, HDA_INPUT, 0 },
6189 { 0x07, HDA_INPUT, 1 },
6190 { 0x07, HDA_INPUT, 2 },
6191 { 0x07, HDA_INPUT, 3 },
6192 { 0x07, HDA_INPUT, 4 },
6193 { } /* end */
6194};
6195#endif
6196
Kailang Yangdf694da2005-12-05 19:42:22 +01006197/*
6198 * ALC260 configurations
6199 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006200static const char *alc260_models[ALC260_MODEL_LAST] = {
6201 [ALC260_BASIC] = "basic",
6202 [ALC260_HP] = "hp",
6203 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02006204 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006205 [ALC260_FUJITSU_S702X] = "fujitsu",
6206 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006207 [ALC260_WILL] = "will",
6208 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01006209 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006210#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006211 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006212#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006213 [ALC260_AUTO] = "auto",
6214};
6215
6216static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01006217 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006218 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01006219 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01006220 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01006221 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006222 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02006223 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02006224 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006225 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
6226 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
6227 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
6228 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
6229 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
6230 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
6231 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
6232 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
6233 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006234 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006235 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02006236 {}
6237};
6238
Kailang Yangdf694da2005-12-05 19:42:22 +01006239static struct alc_config_preset alc260_presets[] = {
6240 [ALC260_BASIC] = {
6241 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006242 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006243 .init_verbs = { alc260_init_verbs },
6244 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6245 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006246 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Kailang Yangdf694da2005-12-05 19:42:22 +01006247 .adc_nids = alc260_adc_nids,
6248 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6249 .channel_mode = alc260_modes,
6250 .input_mux = &alc260_capture_source,
6251 },
6252 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01006253 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006254 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006255 .init_verbs = { alc260_init_verbs,
6256 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006257 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6258 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006259 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6260 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006261 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6262 .channel_mode = alc260_modes,
6263 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006264 .unsol_event = alc260_hp_unsol_event,
6265 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006266 },
Kailang Yang3f878302008-08-26 13:02:23 +02006267 [ALC260_HP_DC7600] = {
6268 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006269 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02006270 .init_verbs = { alc260_init_verbs,
6271 alc260_hp_dc7600_verbs },
6272 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6273 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006274 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6275 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02006276 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6277 .channel_mode = alc260_modes,
6278 .input_mux = &alc260_capture_source,
6279 .unsol_event = alc260_hp_3012_unsol_event,
6280 .init_hook = alc260_hp_3012_automute,
6281 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006282 [ALC260_HP_3013] = {
6283 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006284 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006285 .init_verbs = { alc260_hp_3013_init_verbs,
6286 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006287 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6288 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006289 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6290 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006291 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6292 .channel_mode = alc260_modes,
6293 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006294 .unsol_event = alc260_hp_3013_unsol_event,
6295 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006296 },
6297 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006298 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006299 .init_verbs = { alc260_fujitsu_init_verbs },
6300 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6301 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01006302 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6303 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01006304 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6305 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006306 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
6307 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01006308 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006309 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006310 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006311 .init_verbs = { alc260_acer_init_verbs },
6312 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6313 .dac_nids = alc260_dac_nids,
6314 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6315 .adc_nids = alc260_dual_adc_nids,
6316 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6317 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006318 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
6319 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006320 },
Michael Schwingencc959482009-02-22 18:58:45 +01006321 [ALC260_FAVORIT100] = {
6322 .mixers = { alc260_favorit100_mixer },
6323 .init_verbs = { alc260_favorit100_init_verbs },
6324 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6325 .dac_nids = alc260_dac_nids,
6326 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6327 .adc_nids = alc260_dual_adc_nids,
6328 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6329 .channel_mode = alc260_modes,
6330 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
6331 .input_mux = alc260_favorit100_capture_sources,
6332 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006333 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006334 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006335 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
6336 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6337 .dac_nids = alc260_dac_nids,
6338 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6339 .adc_nids = alc260_adc_nids,
6340 .dig_out_nid = ALC260_DIGOUT_NID,
6341 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6342 .channel_mode = alc260_modes,
6343 .input_mux = &alc260_capture_source,
6344 },
6345 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006346 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006347 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
6348 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6349 .dac_nids = alc260_dac_nids,
6350 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6351 .adc_nids = alc260_adc_nids,
6352 .dig_out_nid = ALC260_DIGOUT_NID,
6353 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6354 .channel_mode = alc260_modes,
6355 .input_mux = &alc260_capture_source,
6356 .unsol_event = alc260_replacer_672v_unsol_event,
6357 .init_hook = alc260_replacer_672v_automute,
6358 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006359#ifdef CONFIG_SND_DEBUG
6360 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006361 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006362 .init_verbs = { alc260_test_init_verbs },
6363 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
6364 .dac_nids = alc260_test_dac_nids,
6365 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
6366 .adc_nids = alc260_test_adc_nids,
6367 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6368 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006369 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
6370 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006371 },
6372#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006373};
6374
Linus Torvalds1da177e2005-04-16 15:20:36 -07006375static int patch_alc260(struct hda_codec *codec)
6376{
6377 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006378 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006379
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006380 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006381 if (spec == NULL)
6382 return -ENOMEM;
6383
6384 codec->spec = spec;
6385
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006386 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
6387 alc260_models,
6388 alc260_cfg_tbl);
6389 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02006390 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai6c627f32009-05-18 12:33:36 +02006391 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01006392 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02006393 }
6394
Kailang Yangdf694da2005-12-05 19:42:22 +01006395 if (board_config == ALC260_AUTO) {
6396 /* automatic parse from the BIOS config */
6397 err = alc260_parse_auto_config(codec);
6398 if (err < 0) {
6399 alc_free(codec);
6400 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006401 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006402 printk(KERN_INFO
6403 "hda_codec: Cannot set up configuration "
6404 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006405 board_config = ALC260_BASIC;
6406 }
Takashi Iwai16ded522005-06-10 19:58:24 +02006407 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006408
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09006409 err = snd_hda_attach_beep_device(codec, 0x1);
6410 if (err < 0) {
6411 alc_free(codec);
6412 return err;
6413 }
6414
Kailang Yangdf694da2005-12-05 19:42:22 +01006415 if (board_config != ALC260_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02006416 setup_preset(codec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006417
Linus Torvalds1da177e2005-04-16 15:20:36 -07006418 spec->stream_analog_playback = &alc260_pcm_analog_playback;
6419 spec->stream_analog_capture = &alc260_pcm_analog_capture;
6420
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006421 spec->stream_digital_playback = &alc260_pcm_digital_playback;
6422 spec->stream_digital_capture = &alc260_pcm_digital_capture;
6423
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006424 if (!spec->adc_nids && spec->input_mux) {
6425 /* check whether NID 0x04 is valid */
6426 unsigned int wcap = get_wcaps(codec, 0x04);
Takashi Iwaia22d5432009-07-27 12:54:26 +02006427 wcap = get_wcaps_type(wcap);
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006428 /* get type */
6429 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
6430 spec->adc_nids = alc260_adc_nids_alt;
6431 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
6432 } else {
6433 spec->adc_nids = alc260_adc_nids;
6434 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
6435 }
6436 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02006437 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006438 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006439
Takashi Iwai2134ea42008-01-10 16:53:55 +01006440 spec->vmaster_nid = 0x08;
6441
Linus Torvalds1da177e2005-04-16 15:20:36 -07006442 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006443 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006444 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006445#ifdef CONFIG_SND_HDA_POWER_SAVE
6446 if (!spec->loopback.amplist)
6447 spec->loopback.amplist = alc260_loopbacks;
6448#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01006449 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006450
6451 return 0;
6452}
6453
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006454
Linus Torvalds1da177e2005-04-16 15:20:36 -07006455/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006456 * ALC882/883/885/888/889 support
Linus Torvalds1da177e2005-04-16 15:20:36 -07006457 *
6458 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
6459 * configuration. Each pin widget can choose any input DACs and a mixer.
6460 * Each ADC is connected from a mixer of all inputs. This makes possible
6461 * 6-channel independent captures.
6462 *
6463 * In addition, an independent DAC for the multi-playback (not used in this
6464 * driver yet).
6465 */
Kailang Yangdf694da2005-12-05 19:42:22 +01006466#define ALC882_DIGOUT_NID 0x06
6467#define ALC882_DIGIN_NID 0x0a
Takashi Iwai4953550a2009-06-30 15:28:30 +02006468#define ALC883_DIGOUT_NID ALC882_DIGOUT_NID
6469#define ALC883_DIGIN_NID ALC882_DIGIN_NID
6470#define ALC1200_DIGOUT_NID 0x10
6471
Linus Torvalds1da177e2005-04-16 15:20:36 -07006472
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01006473static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07006474 { 8, NULL }
6475};
6476
Takashi Iwai4953550a2009-06-30 15:28:30 +02006477/* DACs */
Linus Torvalds1da177e2005-04-16 15:20:36 -07006478static hda_nid_t alc882_dac_nids[4] = {
6479 /* front, rear, clfe, rear_surr */
6480 0x02, 0x03, 0x04, 0x05
6481};
Takashi Iwai4953550a2009-06-30 15:28:30 +02006482#define alc883_dac_nids alc882_dac_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07006483
Takashi Iwai4953550a2009-06-30 15:28:30 +02006484/* ADCs */
Kailang Yangdf694da2005-12-05 19:42:22 +01006485#define alc882_adc_nids alc880_adc_nids
6486#define alc882_adc_nids_alt alc880_adc_nids_alt
Takashi Iwai4953550a2009-06-30 15:28:30 +02006487#define alc883_adc_nids alc882_adc_nids_alt
6488static hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
6489static hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
6490#define alc889_adc_nids alc880_adc_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07006491
Takashi Iwaie1406342008-02-11 18:32:32 +01006492static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
6493static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
Takashi Iwai4953550a2009-06-30 15:28:30 +02006494#define alc883_capsrc_nids alc882_capsrc_nids_alt
6495static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
6496#define alc889_capsrc_nids alc882_capsrc_nids
Takashi Iwaie1406342008-02-11 18:32:32 +01006497
Linus Torvalds1da177e2005-04-16 15:20:36 -07006498/* input MUX */
6499/* FIXME: should be a matrix-type input source selection */
6500
6501static struct hda_input_mux alc882_capture_source = {
6502 .num_items = 4,
6503 .items = {
6504 { "Mic", 0x0 },
6505 { "Front Mic", 0x1 },
6506 { "Line", 0x2 },
6507 { "CD", 0x4 },
6508 },
6509};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006510
Takashi Iwai4953550a2009-06-30 15:28:30 +02006511#define alc883_capture_source alc882_capture_source
6512
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006513static struct hda_input_mux alc889_capture_source = {
6514 .num_items = 3,
6515 .items = {
6516 { "Front Mic", 0x0 },
6517 { "Mic", 0x3 },
6518 { "Line", 0x2 },
6519 },
6520};
6521
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006522static struct hda_input_mux mb5_capture_source = {
6523 .num_items = 3,
6524 .items = {
6525 { "Mic", 0x1 },
6526 { "Line", 0x2 },
6527 { "CD", 0x4 },
6528 },
6529};
6530
Takashi Iwai4953550a2009-06-30 15:28:30 +02006531static struct hda_input_mux alc883_3stack_6ch_intel = {
6532 .num_items = 4,
6533 .items = {
6534 { "Mic", 0x1 },
6535 { "Front Mic", 0x0 },
6536 { "Line", 0x2 },
6537 { "CD", 0x4 },
6538 },
6539};
6540
6541static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6542 .num_items = 2,
6543 .items = {
6544 { "Mic", 0x1 },
6545 { "Line", 0x2 },
6546 },
6547};
6548
6549static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6550 .num_items = 4,
6551 .items = {
6552 { "Mic", 0x0 },
6553 { "iMic", 0x1 },
6554 { "Line", 0x2 },
6555 { "CD", 0x4 },
6556 },
6557};
6558
6559static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
6560 .num_items = 2,
6561 .items = {
6562 { "Mic", 0x0 },
6563 { "Int Mic", 0x1 },
6564 },
6565};
6566
6567static struct hda_input_mux alc883_lenovo_sky_capture_source = {
6568 .num_items = 3,
6569 .items = {
6570 { "Mic", 0x0 },
6571 { "Front Mic", 0x1 },
6572 { "Line", 0x4 },
6573 },
6574};
6575
6576static struct hda_input_mux alc883_asus_eee1601_capture_source = {
6577 .num_items = 2,
6578 .items = {
6579 { "Mic", 0x0 },
6580 { "Line", 0x2 },
6581 },
6582};
6583
6584static struct hda_input_mux alc889A_mb31_capture_source = {
6585 .num_items = 2,
6586 .items = {
6587 { "Mic", 0x0 },
6588 /* Front Mic (0x01) unused */
6589 { "Line", 0x2 },
6590 /* Line 2 (0x03) unused */
6591 /* CD (0x04) unsused? */
6592 },
6593};
6594
6595/*
6596 * 2ch mode
6597 */
6598static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6599 { 2, NULL }
6600};
6601
Kailang Yangdf694da2005-12-05 19:42:22 +01006602/*
Kailang Yang272a5272007-05-14 11:00:38 +02006603 * 2ch mode
6604 */
6605static struct hda_verb alc882_3ST_ch2_init[] = {
6606 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6607 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6608 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6609 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6610 { } /* end */
6611};
6612
6613/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006614 * 4ch mode
6615 */
6616static struct hda_verb alc882_3ST_ch4_init[] = {
6617 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6618 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6619 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6620 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6621 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6622 { } /* end */
6623};
6624
6625/*
Kailang Yang272a5272007-05-14 11:00:38 +02006626 * 6ch mode
6627 */
6628static struct hda_verb alc882_3ST_ch6_init[] = {
6629 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6630 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6631 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6632 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6633 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6634 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6635 { } /* end */
6636};
6637
Takashi Iwai4953550a2009-06-30 15:28:30 +02006638static struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
Kailang Yang272a5272007-05-14 11:00:38 +02006639 { 2, alc882_3ST_ch2_init },
Takashi Iwai4953550a2009-06-30 15:28:30 +02006640 { 4, alc882_3ST_ch4_init },
Kailang Yang272a5272007-05-14 11:00:38 +02006641 { 6, alc882_3ST_ch6_init },
6642};
6643
Takashi Iwai4953550a2009-06-30 15:28:30 +02006644#define alc883_3ST_6ch_modes alc882_3ST_6ch_modes
6645
Kailang Yang272a5272007-05-14 11:00:38 +02006646/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006647 * 6ch mode
6648 */
6649static struct hda_verb alc882_sixstack_ch6_init[] = {
6650 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6651 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6652 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6653 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6654 { } /* end */
6655};
6656
6657/*
6658 * 8ch mode
6659 */
6660static struct hda_verb alc882_sixstack_ch8_init[] = {
6661 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6662 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6663 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6664 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6665 { } /* end */
6666};
6667
6668static struct hda_channel_mode alc882_sixstack_modes[2] = {
6669 { 6, alc882_sixstack_ch6_init },
6670 { 8, alc882_sixstack_ch8_init },
6671};
6672
Takashi Iwai87350ad2007-08-16 18:19:38 +02006673/*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04006674 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
Takashi Iwai87350ad2007-08-16 18:19:38 +02006675 */
6676
6677/*
6678 * 2ch mode
6679 */
6680static struct hda_verb alc885_mbp_ch2_init[] = {
6681 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6682 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6683 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6684 { } /* end */
6685};
6686
6687/*
6688 * 6ch mode
6689 */
6690static struct hda_verb alc885_mbp_ch6_init[] = {
6691 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6692 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6693 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6694 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6695 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6696 { } /* end */
6697};
6698
6699static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
6700 { 2, alc885_mbp_ch2_init },
6701 { 6, alc885_mbp_ch6_init },
6702};
6703
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006704/*
6705 * 2ch
6706 * Speakers/Woofer/HP = Front
6707 * LineIn = Input
6708 */
6709static struct hda_verb alc885_mb5_ch2_init[] = {
6710 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6711 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6712 { } /* end */
6713};
6714
6715/*
6716 * 6ch mode
6717 * Speakers/HP = Front
6718 * Woofer = LFE
6719 * LineIn = Surround
6720 */
6721static struct hda_verb alc885_mb5_ch6_init[] = {
6722 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6723 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6724 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6725 { } /* end */
6726};
6727
6728static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
6729 { 2, alc885_mb5_ch2_init },
6730 { 6, alc885_mb5_ch6_init },
6731};
Takashi Iwai87350ad2007-08-16 18:19:38 +02006732
Takashi Iwai4953550a2009-06-30 15:28:30 +02006733
6734/*
6735 * 2ch mode
6736 */
6737static struct hda_verb alc883_4ST_ch2_init[] = {
6738 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6739 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6740 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6741 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6742 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6743 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6744 { } /* end */
6745};
6746
6747/*
6748 * 4ch mode
6749 */
6750static struct hda_verb alc883_4ST_ch4_init[] = {
6751 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6752 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6753 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6754 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6755 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6756 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6757 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6758 { } /* end */
6759};
6760
6761/*
6762 * 6ch mode
6763 */
6764static struct hda_verb alc883_4ST_ch6_init[] = {
6765 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6766 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6767 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6768 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6769 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6770 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6771 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6772 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6773 { } /* end */
6774};
6775
6776/*
6777 * 8ch mode
6778 */
6779static struct hda_verb alc883_4ST_ch8_init[] = {
6780 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6781 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6782 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
6783 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6784 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6785 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6786 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6787 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6788 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6789 { } /* end */
6790};
6791
6792static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
6793 { 2, alc883_4ST_ch2_init },
6794 { 4, alc883_4ST_ch4_init },
6795 { 6, alc883_4ST_ch6_init },
6796 { 8, alc883_4ST_ch8_init },
6797};
6798
6799
6800/*
6801 * 2ch mode
6802 */
6803static struct hda_verb alc883_3ST_ch2_intel_init[] = {
6804 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6805 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6806 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6807 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6808 { } /* end */
6809};
6810
6811/*
6812 * 4ch mode
6813 */
6814static struct hda_verb alc883_3ST_ch4_intel_init[] = {
6815 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6816 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6817 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6818 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6819 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6820 { } /* end */
6821};
6822
6823/*
6824 * 6ch mode
6825 */
6826static struct hda_verb alc883_3ST_ch6_intel_init[] = {
6827 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6828 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6829 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
6830 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6831 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6832 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6833 { } /* end */
6834};
6835
6836static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
6837 { 2, alc883_3ST_ch2_intel_init },
6838 { 4, alc883_3ST_ch4_intel_init },
6839 { 6, alc883_3ST_ch6_intel_init },
6840};
6841
6842/*
Wu Fengguangdd7714c2009-07-30 14:36:35 +08006843 * 2ch mode
6844 */
6845static struct hda_verb alc889_ch2_intel_init[] = {
6846 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
6847 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 },
6848 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 },
6849 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00 },
6850 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6851 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6852 { } /* end */
6853};
6854
6855/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006856 * 6ch mode
6857 */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006858static struct hda_verb alc889_ch6_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08006859 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
6860 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
6861 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
6862 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
6863 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006864 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6865 { } /* end */
6866};
6867
6868/*
6869 * 8ch mode
6870 */
6871static struct hda_verb alc889_ch8_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08006872 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
6873 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
6874 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
6875 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
6876 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006877 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6878 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006879 { } /* end */
6880};
6881
Wu Fengguangdd7714c2009-07-30 14:36:35 +08006882static struct hda_channel_mode alc889_8ch_intel_modes[3] = {
6883 { 2, alc889_ch2_intel_init },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006884 { 6, alc889_ch6_intel_init },
6885 { 8, alc889_ch8_intel_init },
6886};
6887
6888/*
6889 * 6ch mode
6890 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02006891static struct hda_verb alc883_sixstack_ch6_init[] = {
6892 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6893 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6894 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6895 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6896 { } /* end */
6897};
6898
6899/*
6900 * 8ch mode
6901 */
6902static struct hda_verb alc883_sixstack_ch8_init[] = {
6903 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6904 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6905 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6906 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6907 { } /* end */
6908};
6909
6910static struct hda_channel_mode alc883_sixstack_modes[2] = {
6911 { 6, alc883_sixstack_ch6_init },
6912 { 8, alc883_sixstack_ch8_init },
6913};
6914
6915
Linus Torvalds1da177e2005-04-16 15:20:36 -07006916/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6917 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6918 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01006919static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02006920 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006921 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006922 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006923 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006924 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6925 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006926 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6927 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006928 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006929 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006930 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6931 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6932 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6933 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6934 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6935 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006936 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006937 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6938 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006939 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006940 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006941 { } /* end */
6942};
6943
Takashi Iwai87350ad2007-08-16 18:19:38 +02006944static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01006945 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6946 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
6947 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
6948 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
6949 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6950 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006951 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
6952 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01006953 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006954 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
6955 { } /* end */
6956};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006957
6958static struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006959 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6960 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
6961 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
6962 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
6963 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
6964 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
6965 HDA_CODEC_VOLUME("HP Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
6966 HDA_BIND_MUTE ("HP Playback Switch", 0x0f, 0x02, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006967 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6968 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6969 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
6970 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
6971 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
6972 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0x00, HDA_INPUT),
6973 { } /* end */
6974};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006975
Kailang Yangbdd148a2007-05-08 15:19:08 +02006976static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
6977 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6978 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6979 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6980 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6981 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6982 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6983 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6984 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6985 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02006986 { } /* end */
6987};
6988
Kailang Yang272a5272007-05-14 11:00:38 +02006989static struct snd_kcontrol_new alc882_targa_mixer[] = {
6990 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6991 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6992 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6993 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6994 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6995 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6996 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6997 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6998 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006999 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007000 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7001 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007002 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007003 { } /* end */
7004};
7005
7006/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
7007 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
7008 */
7009static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
7010 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7011 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7012 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7013 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
7014 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7015 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7016 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7017 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7018 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
7019 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
7020 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7021 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007022 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007023 { } /* end */
7024};
7025
Takashi Iwai914759b2007-09-06 14:52:04 +02007026static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
7027 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7028 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7029 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7030 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7031 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7032 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7033 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7034 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7035 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7036 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02007037 { } /* end */
7038};
7039
Kailang Yangdf694da2005-12-05 19:42:22 +01007040static struct snd_kcontrol_new alc882_chmode_mixer[] = {
7041 {
7042 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7043 .name = "Channel Mode",
7044 .info = alc_ch_mode_info,
7045 .get = alc_ch_mode_get,
7046 .put = alc_ch_mode_put,
7047 },
7048 { } /* end */
7049};
7050
Takashi Iwai4953550a2009-06-30 15:28:30 +02007051static struct hda_verb alc882_base_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007052 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007053 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7054 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7055 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007056 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007057 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7058 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7059 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007060 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007061 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7062 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7063 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007064 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007065 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7066 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7067 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007068
Takashi Iwaicb638122009-07-03 10:56:10 +02007069 /* mute analog input loopbacks */
7070 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7071 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7072 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7073 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7074 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7075
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007076 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007077 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007078 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007079 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007080 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007081 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007082 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007083 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007084 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007085 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007086 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007087 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007088 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007089 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007090 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007091 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007092 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007093 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007094 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7095 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007096 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007097 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7098 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007099 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007100 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7101 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7102 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7103 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7104 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007105 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007106 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007107
7108 /* FIXME: use matrix-type input source selection */
7109 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007110 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007111 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7112 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7113 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7114 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007115 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007116 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7117 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7118 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7119 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai05acb862005-06-10 19:50:25 +02007120 /* ADC2: mute amp left and right */
7121 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007122 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02007123 /* ADC3: mute amp left and right */
7124 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007125 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007126
7127 { }
7128};
7129
Takashi Iwai4953550a2009-06-30 15:28:30 +02007130static struct hda_verb alc882_adc1_init_verbs[] = {
7131 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7132 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7133 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7134 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7135 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7136 /* ADC1: mute amp left and right */
7137 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7138 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7139 { }
7140};
7141
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007142static struct hda_verb alc882_eapd_verbs[] = {
7143 /* change to EAPD mode */
7144 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007145 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007146 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007147};
7148
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007149static struct hda_verb alc889_eapd_verbs[] = {
7150 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
7151 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
7152 { }
7153};
7154
Wu Fengguang6732bd02009-07-30 09:19:14 +02007155static struct hda_verb alc_hp15_unsol_verbs[] = {
7156 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7157 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7158 {}
7159};
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007160
7161static struct hda_verb alc885_init_verbs[] = {
7162 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7163 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7164 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7165 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7166 /* Rear mixer */
7167 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7168 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7169 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7170 /* CLFE mixer */
7171 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7172 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7173 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7174 /* Side mixer */
7175 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7176 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7177 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7178
7179 /* mute analog input loopbacks */
7180 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7181 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7182 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7183
7184 /* Front HP Pin: output 0 (0x0c) */
Wu Fengguang6732bd02009-07-30 09:19:14 +02007185 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007186 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7187 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7188 /* Front Pin: output 0 (0x0c) */
7189 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7190 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7191 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7192 /* Rear Pin: output 1 (0x0d) */
7193 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7194 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7195 {0x19, AC_VERB_SET_CONNECT_SEL, 0x01},
7196 /* CLFE Pin: output 2 (0x0e) */
7197 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7198 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7199 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7200 /* Side Pin: output 3 (0x0f) */
7201 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7202 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7203 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7204 /* Mic (rear) pin: input vref at 80% */
7205 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7206 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7207 /* Front Mic pin: input vref at 80% */
7208 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7209 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7210 /* Line In pin: input */
7211 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7212 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7213
7214 /* Mixer elements: 0x18, , 0x1a, 0x1b */
7215 /* Input mixer1 */
7216 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7217 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7218 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7219 /* Input mixer2 */
7220 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7221 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7222 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7223 /* Input mixer3 */
7224 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7225 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7226 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7227 /* ADC2: mute amp left and right */
7228 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7229 /* ADC3: mute amp left and right */
7230 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7231
7232 { }
7233};
7234
7235static struct hda_verb alc885_init_input_verbs[] = {
7236 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7237 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7238 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7239 { }
7240};
7241
7242
7243/* Unmute Selector 24h and set the default input to front mic */
7244static struct hda_verb alc889_init_input_verbs[] = {
7245 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
7246 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7247 { }
7248};
7249
7250
Takashi Iwai4953550a2009-06-30 15:28:30 +02007251#define alc883_init_verbs alc882_base_init_verbs
7252
Tobin Davis9102cd12006-12-15 10:02:12 +01007253/* Mac Pro test */
7254static struct snd_kcontrol_new alc882_macpro_mixer[] = {
7255 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7256 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7257 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
7258 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
7259 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007260 /* FIXME: this looks suspicious...
Tobin Davis9102cd12006-12-15 10:02:12 +01007261 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
7262 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007263 */
Tobin Davis9102cd12006-12-15 10:02:12 +01007264 { } /* end */
7265};
7266
7267static struct hda_verb alc882_macpro_init_verbs[] = {
7268 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7269 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7270 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7271 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7272 /* Front Pin: output 0 (0x0c) */
7273 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7274 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7275 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7276 /* Front Mic pin: input vref at 80% */
7277 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7278 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7279 /* Speaker: output */
7280 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7281 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7282 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
7283 /* Headphone output (output 0 - 0x0c) */
7284 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7285 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7286 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7287
7288 /* FIXME: use matrix-type input source selection */
7289 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7290 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7291 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7292 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7293 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7294 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7295 /* Input mixer2 */
7296 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7297 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7298 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7299 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7300 /* Input mixer3 */
7301 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7302 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7303 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7304 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7305 /* ADC1: mute amp left and right */
7306 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7307 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7308 /* ADC2: mute amp left and right */
7309 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7310 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7311 /* ADC3: mute amp left and right */
7312 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7313 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7314
7315 { }
7316};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007317
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007318/* Macbook 5,1 */
7319static struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007320 /* DACs */
7321 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7322 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7323 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7324 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007325 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007326 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7327 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7328 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007329 /* Surround mixer */
7330 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7331 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7332 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7333 /* LFE mixer */
7334 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7335 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7336 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7337 /* HP mixer */
7338 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7339 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7340 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7341 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007342 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7343 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007344 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7345 /* LFE Pin (0x0e) */
7346 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7347 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7348 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
7349 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007350 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7351 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007352 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007353 /* Front Mic pin: input vref at 80% */
7354 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7355 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7356 /* Line In pin */
7357 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7358 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7359
7360 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7361 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7362 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7363 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7364 { }
7365};
7366
Takashi Iwai87350ad2007-08-16 18:19:38 +02007367/* Macbook Pro rev3 */
7368static struct hda_verb alc885_mbp3_init_verbs[] = {
7369 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7370 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7371 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7372 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7373 /* Rear mixer */
7374 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7375 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7376 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7377 /* Front Pin: output 0 (0x0c) */
7378 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7379 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7380 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7381 /* HP Pin: output 0 (0x0d) */
7382 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
7383 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7384 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7385 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7386 /* Mic (rear) pin: input vref at 80% */
7387 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7388 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7389 /* Front Mic pin: input vref at 80% */
7390 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7391 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7392 /* Line In pin: use output 1 when in LineOut mode */
7393 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7394 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7395 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
7396
7397 /* FIXME: use matrix-type input source selection */
7398 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7399 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7400 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7401 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7402 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7403 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7404 /* Input mixer2 */
7405 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7406 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7407 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7408 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7409 /* Input mixer3 */
7410 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7411 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7412 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7413 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7414 /* ADC1: mute amp left and right */
7415 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7416 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7417 /* ADC2: mute amp left and right */
7418 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7419 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7420 /* ADC3: mute amp left and right */
7421 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7422 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7423
7424 { }
7425};
7426
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007427/* iMac 24 mixer. */
7428static struct snd_kcontrol_new alc885_imac24_mixer[] = {
7429 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7430 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
7431 { } /* end */
7432};
7433
7434/* iMac 24 init verbs. */
7435static struct hda_verb alc885_imac24_init_verbs[] = {
7436 /* Internal speakers: output 0 (0x0c) */
7437 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7438 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7439 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7440 /* Internal speakers: output 0 (0x0c) */
7441 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7442 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7443 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
7444 /* Headphone: output 0 (0x0c) */
7445 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7446 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7447 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7448 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7449 /* Front Mic: input vref at 80% */
7450 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7451 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7452 { }
7453};
7454
7455/* Toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007456static void alc885_imac24_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007457{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007458 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007459
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007460 spec->autocfg.hp_pins[0] = 0x14;
7461 spec->autocfg.speaker_pins[0] = 0x18;
7462 spec->autocfg.speaker_pins[1] = 0x1a;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007463}
7464
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007465static void alc885_mbp3_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007466{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007467 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007468
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007469 spec->autocfg.hp_pins[0] = 0x15;
7470 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai87350ad2007-08-16 18:19:38 +02007471}
7472
7473
Kailang Yang272a5272007-05-14 11:00:38 +02007474static struct hda_verb alc882_targa_verbs[] = {
7475 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7476 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7477
7478 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7479 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007480
Kailang Yang272a5272007-05-14 11:00:38 +02007481 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7482 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7483 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7484
7485 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yang272a5272007-05-14 11:00:38 +02007486 { } /* end */
7487};
7488
7489/* toggle speaker-output according to the hp-jack state */
7490static void alc882_targa_automute(struct hda_codec *codec)
7491{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007492 struct alc_spec *spec = codec->spec;
7493 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02007494 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007495 spec->jack_present ? 1 : 3);
7496}
7497
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007498static void alc882_targa_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007499{
7500 struct alc_spec *spec = codec->spec;
7501
7502 spec->autocfg.hp_pins[0] = 0x14;
7503 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang272a5272007-05-14 11:00:38 +02007504}
7505
7506static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
7507{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007508 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02007509 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02007510}
7511
7512static struct hda_verb alc882_asus_a7j_verbs[] = {
7513 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7514 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7515
7516 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7517 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7518 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007519
Kailang Yang272a5272007-05-14 11:00:38 +02007520 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7521 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7522 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7523
7524 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7525 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7526 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7527 { } /* end */
7528};
7529
Takashi Iwai914759b2007-09-06 14:52:04 +02007530static struct hda_verb alc882_asus_a7m_verbs[] = {
7531 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7532 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7533
7534 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7535 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7536 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007537
Takashi Iwai914759b2007-09-06 14:52:04 +02007538 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7539 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7540 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7541
7542 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7543 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7544 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7545 { } /* end */
7546};
7547
Tobin Davis9102cd12006-12-15 10:02:12 +01007548static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
7549{
7550 unsigned int gpiostate, gpiomask, gpiodir;
7551
7552 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
7553 AC_VERB_GET_GPIO_DATA, 0);
7554
7555 if (!muted)
7556 gpiostate |= (1 << pin);
7557 else
7558 gpiostate &= ~(1 << pin);
7559
7560 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
7561 AC_VERB_GET_GPIO_MASK, 0);
7562 gpiomask |= (1 << pin);
7563
7564 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
7565 AC_VERB_GET_GPIO_DIRECTION, 0);
7566 gpiodir |= (1 << pin);
7567
7568
7569 snd_hda_codec_write(codec, codec->afg, 0,
7570 AC_VERB_SET_GPIO_MASK, gpiomask);
7571 snd_hda_codec_write(codec, codec->afg, 0,
7572 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
7573
7574 msleep(1);
7575
7576 snd_hda_codec_write(codec, codec->afg, 0,
7577 AC_VERB_SET_GPIO_DATA, gpiostate);
7578}
7579
Takashi Iwai7debbe52007-08-16 15:01:03 +02007580/* set up GPIO at initialization */
7581static void alc885_macpro_init_hook(struct hda_codec *codec)
7582{
7583 alc882_gpio_mute(codec, 0, 0);
7584 alc882_gpio_mute(codec, 1, 0);
7585}
7586
7587/* set up GPIO and update auto-muting at initialization */
7588static void alc885_imac24_init_hook(struct hda_codec *codec)
7589{
7590 alc885_macpro_init_hook(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007591 alc_automute_amp(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02007592}
7593
Kailang Yangdf694da2005-12-05 19:42:22 +01007594/*
7595 * generic initialization of ADC, input mixers and output mixers
7596 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007597static struct hda_verb alc883_auto_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01007598 /*
7599 * Unmute ADC0-2 and set the default input to mic-in
7600 */
Kailang Yangdf694da2005-12-05 19:42:22 +01007601 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7602 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7603 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7604 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7605
Takashi Iwaicb53c622007-08-10 17:21:45 +02007606 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01007607 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007608 * Note: PASD motherboards uses the Line In 2 as the input for
7609 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01007610 */
7611 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02007612 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7613 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7614 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7615 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7616 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01007617
7618 /*
7619 * Set up output mixers (0x0c - 0x0f)
7620 */
7621 /* set vol=0 to output mixers */
7622 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7623 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7624 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7625 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7626 /* set up input amps for analog loopback */
7627 /* Amp Indices: DAC = 0, mixer = 1 */
7628 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7629 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7630 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7631 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7632 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7633 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7634 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7635 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7636 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7637 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7638
7639 /* FIXME: use matrix-type input source selection */
7640 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Kailang Yangdf694da2005-12-05 19:42:22 +01007641 /* Input mixer2 */
7642 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7643 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7644 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7645 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7646 /* Input mixer3 */
7647 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7648 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7649 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7650 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7651
7652 { }
7653};
7654
Torben Schulzeb4c41d2009-05-18 15:02:35 +02007655/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
7656static struct hda_verb alc889A_mb31_ch2_init[] = {
7657 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7658 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7659 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7660 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7661 { } /* end */
7662};
7663
7664/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
7665static struct hda_verb alc889A_mb31_ch4_init[] = {
7666 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7667 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7668 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7669 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7670 { } /* end */
7671};
7672
7673/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
7674static struct hda_verb alc889A_mb31_ch5_init[] = {
7675 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
7676 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7677 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7678 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7679 { } /* end */
7680};
7681
7682/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
7683static struct hda_verb alc889A_mb31_ch6_init[] = {
7684 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
7685 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
7686 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7687 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7688 { } /* end */
7689};
7690
7691static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
7692 { 2, alc889A_mb31_ch2_init },
7693 { 4, alc889A_mb31_ch4_init },
7694 { 5, alc889A_mb31_ch5_init },
7695 { 6, alc889A_mb31_ch6_init },
7696};
7697
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007698static struct hda_verb alc883_medion_eapd_verbs[] = {
7699 /* eanable EAPD on medion laptop */
7700 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7701 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7702 { }
7703};
7704
Takashi Iwai4953550a2009-06-30 15:28:30 +02007705#define alc883_base_mixer alc882_base_mixer
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007706
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007707static struct snd_kcontrol_new alc883_mitac_mixer[] = {
7708 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7709 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7710 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7711 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7712 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7713 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7714 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7715 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7716 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7717 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7718 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7719 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7720 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007721 { } /* end */
7722};
7723
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007724static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007725 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7726 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7727 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7728 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7729 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7730 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7731 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7732 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7733 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7734 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01007735 { } /* end */
7736};
7737
Jiang zhefb97dc62008-03-06 11:07:11 +01007738static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
7739 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7740 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7741 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7742 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7743 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7744 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7745 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7746 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7747 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7748 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01007749 { } /* end */
7750};
7751
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007752static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
7753 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7754 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7755 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7756 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7757 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7758 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7759 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7760 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007761 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007762 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7763 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007764 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007765 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007766 { } /* end */
7767};
7768
7769static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
7770 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7771 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7772 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7773 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7774 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7775 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7776 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7777 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7778 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7779 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7780 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7781 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7782 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7783 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007784 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007785 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7786 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007787 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007788 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007789 { } /* end */
7790};
7791
Jiang zhe17bba1b2008-06-04 12:11:07 +02007792static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
7793 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7794 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7795 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7796 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7797 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7798 HDA_OUTPUT),
7799 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7800 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7801 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7802 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7803 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7804 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7805 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7806 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7807 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7808 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
7809 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7810 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7811 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7812 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02007813 { } /* end */
7814};
7815
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007816static struct snd_kcontrol_new alc885_8ch_intel_mixer[] = {
7817 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7818 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7819 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7820 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7821 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7822 HDA_OUTPUT),
7823 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7824 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7825 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7826 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7827 HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT),
7828 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7829 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7830 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7831 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
7832 HDA_CODEC_VOLUME("Mic Boost", 0x1b, 0, HDA_INPUT),
7833 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
7834 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7835 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7836 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7837 { } /* end */
7838};
7839
Takashi Iwaid1d985f2006-11-23 19:27:12 +01007840static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02007841 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007842 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007843 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007844 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007845 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7846 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007847 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7848 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007849 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7850 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7851 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7852 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7853 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7854 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007855 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007856 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7857 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007858 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007859 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007860 { } /* end */
7861};
7862
Sasha Alexandrc2592492009-06-16 14:52:54 -04007863static struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02007864 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7865 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7866 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7867 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7868 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7869 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7870 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7871 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7872 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7873 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7874 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7875 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7876 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7877 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007878 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007879 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007880 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007881};
Kailang Yangccc656c2006-10-17 12:32:26 +02007882
Sasha Alexandrc2592492009-06-16 14:52:54 -04007883static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02007884 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7885 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7886 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7887 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7888 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7889 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007890 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007891 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02007892 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7893 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7894 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007895 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007896};
Kailang Yangccc656c2006-10-17 12:32:26 +02007897
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007898static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
7899 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7900 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01007901 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7902 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007903 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7904 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7905 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7906 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007907 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007908};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007909
Kailang Yang272a5272007-05-14 11:00:38 +02007910static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
7911 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7912 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
7913 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7914 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7915 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7916 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7917 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7918 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7919 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007920 { } /* end */
7921};
7922
7923static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
7924 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7925 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7926 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7927 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7928 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7929 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7930 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7931 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7932 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007933 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02007934};
Kailang Yang272a5272007-05-14 11:00:38 +02007935
Tobin Davis2880a862007-08-07 11:50:26 +02007936static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02007937 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7938 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007939 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007940 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7941 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02007942 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7943 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7944 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007945 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02007946};
Tobin Davis2880a862007-08-07 11:50:26 +02007947
Tony Vroond2fd4b02009-06-21 00:40:10 +01007948static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
7949 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7950 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7951 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7952 HDA_BIND_MUTE("LFE Playback Switch", 0x0f, 2, HDA_INPUT),
Tony Vroon684a8842009-06-26 09:27:50 +01007953 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7954 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01007955 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7956 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7957 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7958 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7959 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7960 { } /* end */
7961};
7962
Kailang Yange2757d52008-08-26 13:17:46 +02007963static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
7964 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7965 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7966 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
7967 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
7968 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
7969 0x0d, 1, 0x0, HDA_OUTPUT),
7970 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
7971 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
7972 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
7973 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7974 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02007975 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7976 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7977 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7978 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7979 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7980 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7981 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7982 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7983 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7984 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02007985 { } /* end */
7986};
7987
Torben Schulzeb4c41d2009-05-18 15:02:35 +02007988static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
7989 /* Output mixers */
7990 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7991 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7992 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7993 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7994 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
7995 HDA_OUTPUT),
7996 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
7997 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
7998 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
7999 /* Output switches */
8000 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
8001 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
8002 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
8003 /* Boost mixers */
8004 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
8005 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
8006 /* Input mixers */
8007 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
8008 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
8009 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8010 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8011 { } /* end */
8012};
8013
Guido Günther3e1647c2009-06-05 00:47:26 +02008014static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
8015 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8016 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8017 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8018 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8019 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8020 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8021 { } /* end */
8022};
8023
Kailang Yange2757d52008-08-26 13:17:46 +02008024static struct hda_bind_ctls alc883_bind_cap_vol = {
8025 .ops = &snd_hda_bind_vol,
8026 .values = {
8027 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8028 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8029 0
8030 },
8031};
8032
8033static struct hda_bind_ctls alc883_bind_cap_switch = {
8034 .ops = &snd_hda_bind_sw,
8035 .values = {
8036 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8037 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8038 0
8039 },
8040};
8041
8042static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
8043 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8044 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8045 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8046 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8047 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8048 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8049 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8050 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008051 { } /* end */
8052};
8053
8054static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02008055 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
8056 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
8057 {
8058 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8059 /* .name = "Capture Source", */
8060 .name = "Input Source",
8061 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01008062 .info = alc_mux_enum_info,
8063 .get = alc_mux_enum_get,
8064 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02008065 },
8066 { } /* end */
8067};
8068
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008069static struct snd_kcontrol_new alc883_chmode_mixer[] = {
8070 {
8071 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8072 .name = "Channel Mode",
8073 .info = alc_ch_mode_info,
8074 .get = alc_ch_mode_get,
8075 .put = alc_ch_mode_put,
8076 },
8077 { } /* end */
8078};
8079
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008080/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008081static void alc883_mitac_setup(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008082{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008083 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008084
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008085 spec->autocfg.hp_pins[0] = 0x15;
8086 spec->autocfg.speaker_pins[0] = 0x14;
8087 spec->autocfg.speaker_pins[1] = 0x17;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008088}
8089
8090/* auto-toggle front mic */
8091/*
8092static void alc883_mitac_mic_automute(struct hda_codec *codec)
8093{
8094 unsigned int present;
8095 unsigned char bits;
8096
8097 present = snd_hda_codec_read(codec, 0x18, 0,
8098 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8099 bits = present ? HDA_AMP_MUTE : 0;
8100 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
8101}
8102*/
8103
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008104static struct hda_verb alc883_mitac_verbs[] = {
8105 /* HP */
8106 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8107 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8108 /* Subwoofer */
8109 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8110 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8111
8112 /* enable unsolicited event */
8113 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8114 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
8115
8116 { } /* end */
8117};
8118
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008119static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008120 /* HP */
8121 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8122 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8123 /* Int speaker */
8124 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
8125 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8126
8127 /* enable unsolicited event */
8128 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008129 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01008130
8131 { } /* end */
8132};
8133
Jiang zhefb97dc62008-03-06 11:07:11 +01008134static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
8135 /* HP */
8136 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8137 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8138 /* Subwoofer */
8139 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8140 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8141
8142 /* enable unsolicited event */
8143 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8144
8145 { } /* end */
8146};
8147
Sasha Alexandrc2592492009-06-16 14:52:54 -04008148static struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008149 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8150 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8151
8152 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8153 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008154
David Heidelberger64a8be72009-06-08 16:15:18 +02008155/* Connect Line-Out side jack (SPDIF) to Side */
8156 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8157 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8158 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8159/* Connect Mic jack to CLFE */
8160 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8161 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8162 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
8163/* Connect Line-in jack to Surround */
8164 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8165 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8166 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8167/* Connect HP out jack to Front */
8168 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8169 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8170 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02008171
8172 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02008173
8174 { } /* end */
8175};
8176
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008177static struct hda_verb alc883_lenovo_101e_verbs[] = {
8178 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8179 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
8180 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
8181 { } /* end */
8182};
8183
Kailang Yang272a5272007-05-14 11:00:38 +02008184static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
8185 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8186 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8187 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8188 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8189 { } /* end */
8190};
8191
8192static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
8193 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8194 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8195 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8196 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
8197 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8198 { } /* end */
8199};
8200
Kailang Yang189609a2007-08-20 11:31:23 +02008201static struct hda_verb alc883_haier_w66_verbs[] = {
8202 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8203 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8204
8205 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8206
8207 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8208 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8209 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8210 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8211 { } /* end */
8212};
8213
Kailang Yange2757d52008-08-26 13:17:46 +02008214static struct hda_verb alc888_lenovo_sky_verbs[] = {
8215 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8216 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8217 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8218 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8219 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8220 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8221 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8222 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8223 { } /* end */
8224};
8225
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008226static struct hda_verb alc888_6st_dell_verbs[] = {
8227 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8228 { }
8229};
8230
Guido Günther3e1647c2009-06-05 00:47:26 +02008231static struct hda_verb alc883_vaiott_verbs[] = {
8232 /* HP */
8233 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8234 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8235
8236 /* enable unsolicited event */
8237 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8238
8239 { } /* end */
8240};
8241
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008242static void alc888_3st_hp_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008243{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008244 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008245
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008246 spec->autocfg.hp_pins[0] = 0x1b;
8247 spec->autocfg.speaker_pins[0] = 0x14;
8248 spec->autocfg.speaker_pins[1] = 0x16;
8249 spec->autocfg.speaker_pins[2] = 0x18;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008250}
8251
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008252static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008253 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01008254 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
8255 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008256 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008257 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008258};
8259
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008260/*
8261 * 2ch mode
8262 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008263static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008264 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8265 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8266 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
8267 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008268 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008269};
8270
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008271/*
8272 * 4ch mode
8273 */
8274static struct hda_verb alc888_3st_hp_4ch_init[] = {
8275 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8276 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8277 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8278 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8279 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8280 { } /* end */
8281};
8282
8283/*
8284 * 6ch mode
8285 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008286static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008287 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8288 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008289 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008290 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8291 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008292 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8293 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008294};
8295
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008296static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008297 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008298 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008299 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008300};
8301
Kailang Yang272a5272007-05-14 11:00:38 +02008302/* toggle front-jack and RCA according to the hp-jack state */
8303static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
8304{
8305 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008306
Kailang Yang272a5272007-05-14 11:00:38 +02008307 present = snd_hda_codec_read(codec, 0x1b, 0,
8308 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008309 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8310 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8311 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8312 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008313}
8314
8315/* toggle RCA according to the front-jack state */
8316static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
8317{
8318 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008319
Kailang Yang272a5272007-05-14 11:00:38 +02008320 present = snd_hda_codec_read(codec, 0x14, 0,
8321 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008322 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8323 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008324}
Takashi Iwai47fd8302007-08-10 17:11:07 +02008325
Kailang Yang272a5272007-05-14 11:00:38 +02008326static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
8327 unsigned int res)
8328{
8329 if ((res >> 26) == ALC880_HP_EVENT)
8330 alc888_lenovo_ms7195_front_automute(codec);
8331 if ((res >> 26) == ALC880_FRONT_EVENT)
8332 alc888_lenovo_ms7195_rca_automute(codec);
8333}
8334
8335static struct hda_verb alc883_medion_md2_verbs[] = {
8336 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8337 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8338
8339 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8340
8341 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8342 { } /* end */
8343};
8344
8345/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008346static void alc883_medion_md2_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02008347{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008348 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008349
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008350 spec->autocfg.hp_pins[0] = 0x14;
8351 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yang272a5272007-05-14 11:00:38 +02008352}
8353
Kailang Yangccc656c2006-10-17 12:32:26 +02008354/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04008355#define alc883_targa_init_hook alc882_targa_init_hook
8356#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01008357
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008358static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
8359{
8360 unsigned int present;
8361
8362 present = snd_hda_codec_read(codec, 0x18, 0,
8363 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8364 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
8365 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8366}
8367
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008368static void alc883_clevo_m720_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008369{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008370 struct alc_spec *spec = codec->spec;
8371
8372 spec->autocfg.hp_pins[0] = 0x15;
8373 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008374}
8375
8376static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
8377{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008378 alc_automute_amp(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008379 alc883_clevo_m720_mic_automute(codec);
8380}
8381
8382static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01008383 unsigned int res)
8384{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008385 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008386 case ALC880_MIC_EVENT:
8387 alc883_clevo_m720_mic_automute(codec);
8388 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008389 default:
8390 alc_automute_amp_unsol_event(codec, res);
8391 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008392 }
Jiang zhe368c7a92008-03-04 11:20:33 +01008393}
8394
Jiang zhefb97dc62008-03-06 11:07:11 +01008395/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008396static void alc883_2ch_fujitsu_pi2515_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008397{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008398 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008399
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008400 spec->autocfg.hp_pins[0] = 0x14;
8401 spec->autocfg.speaker_pins[0] = 0x15;
Jiang zhefb97dc62008-03-06 11:07:11 +01008402}
8403
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008404static void alc883_haier_w66_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008405{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008406 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008407
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008408 spec->autocfg.hp_pins[0] = 0x1b;
8409 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang189609a2007-08-20 11:31:23 +02008410}
8411
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008412static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
8413{
8414 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008415 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008416
David Heidelberger64a8be72009-06-08 16:15:18 +02008417 present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0)
8418 & AC_PINSENSE_PRESENCE;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008419 bits = present ? HDA_AMP_MUTE : 0;
8420 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8421 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008422}
8423
8424static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
8425{
8426 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008427 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008428
8429 present = snd_hda_codec_read(codec, 0x1b, 0,
8430 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008431 bits = present ? HDA_AMP_MUTE : 0;
8432 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8433 HDA_AMP_MUTE, bits);
8434 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8435 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008436}
8437
8438static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
8439 unsigned int res)
8440{
8441 if ((res >> 26) == ALC880_HP_EVENT)
8442 alc883_lenovo_101e_all_automute(codec);
8443 if ((res >> 26) == ALC880_FRONT_EVENT)
8444 alc883_lenovo_101e_ispeaker_automute(codec);
8445}
8446
Takashi Iwai676a9b52007-08-16 15:23:35 +02008447/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008448static void alc883_acer_aspire_setup(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02008449{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008450 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008451
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008452 spec->autocfg.hp_pins[0] = 0x14;
8453 spec->autocfg.speaker_pins[0] = 0x15;
8454 spec->autocfg.speaker_pins[1] = 0x16;
Takashi Iwai676a9b52007-08-16 15:23:35 +02008455}
8456
Kailang Yangd1a991a2007-08-15 16:21:59 +02008457static struct hda_verb alc883_acer_eapd_verbs[] = {
8458 /* HP Pin: output 0 (0x0c) */
8459 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8460 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8461 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8462 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02008463 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8464 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008465 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008466 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
8467 /* eanable EAPD on medion laptop */
8468 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8469 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02008470 /* enable unsolicited event */
8471 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008472 { }
8473};
8474
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008475static void alc888_6st_dell_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008476{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008477 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008478
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008479 spec->autocfg.hp_pins[0] = 0x1b;
8480 spec->autocfg.speaker_pins[0] = 0x14;
8481 spec->autocfg.speaker_pins[1] = 0x15;
8482 spec->autocfg.speaker_pins[2] = 0x16;
8483 spec->autocfg.speaker_pins[3] = 0x17;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008484}
8485
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008486static void alc888_lenovo_sky_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008487{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008488 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008489
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008490 spec->autocfg.hp_pins[0] = 0x1b;
8491 spec->autocfg.speaker_pins[0] = 0x14;
8492 spec->autocfg.speaker_pins[1] = 0x15;
8493 spec->autocfg.speaker_pins[2] = 0x16;
8494 spec->autocfg.speaker_pins[3] = 0x17;
8495 spec->autocfg.speaker_pins[4] = 0x1a;
Kailang Yange2757d52008-08-26 13:17:46 +02008496}
8497
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008498static void alc883_vaiott_setup(struct hda_codec *codec)
Guido Günther3e1647c2009-06-05 00:47:26 +02008499{
8500 struct alc_spec *spec = codec->spec;
8501
8502 spec->autocfg.hp_pins[0] = 0x15;
8503 spec->autocfg.speaker_pins[0] = 0x14;
8504 spec->autocfg.speaker_pins[1] = 0x17;
Guido Günther3e1647c2009-06-05 00:47:26 +02008505}
8506
Kailang Yange2757d52008-08-26 13:17:46 +02008507static struct hda_verb alc888_asus_m90v_verbs[] = {
8508 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8509 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8510 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8511 /* enable unsolicited event */
8512 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8513 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8514 { } /* end */
8515};
8516
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008517static void alc883_mode2_setup(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02008518{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008519 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02008520
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008521 spec->autocfg.hp_pins[0] = 0x1b;
8522 spec->autocfg.speaker_pins[0] = 0x14;
8523 spec->autocfg.speaker_pins[1] = 0x15;
8524 spec->autocfg.speaker_pins[2] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008525 spec->ext_mic.pin = 0x18;
8526 spec->int_mic.pin = 0x19;
8527 spec->ext_mic.mux_idx = 0;
8528 spec->int_mic.mux_idx = 1;
8529 spec->auto_mic = 1;
Kailang Yange2757d52008-08-26 13:17:46 +02008530}
8531
8532static struct hda_verb alc888_asus_eee1601_verbs[] = {
8533 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8534 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8535 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8536 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8537 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8538 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
8539 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
8540 /* enable unsolicited event */
8541 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8542 { } /* end */
8543};
8544
Kailang Yange2757d52008-08-26 13:17:46 +02008545static void alc883_eee1601_inithook(struct hda_codec *codec)
8546{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008547 struct alc_spec *spec = codec->spec;
8548
8549 spec->autocfg.hp_pins[0] = 0x14;
8550 spec->autocfg.speaker_pins[0] = 0x1b;
8551 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008552}
8553
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008554static struct hda_verb alc889A_mb31_verbs[] = {
8555 /* Init rear pin (used as headphone output) */
8556 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
8557 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
8558 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8559 /* Init line pin (used as output in 4ch and 6ch mode) */
8560 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
8561 /* Init line 2 pin (used as headphone out by default) */
8562 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
8563 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
8564 { } /* end */
8565};
8566
8567/* Mute speakers according to the headphone jack state */
8568static void alc889A_mb31_automute(struct hda_codec *codec)
8569{
8570 unsigned int present;
8571
8572 /* Mute only in 2ch or 4ch mode */
8573 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
8574 == 0x00) {
8575 present = snd_hda_codec_read(codec, 0x15, 0,
8576 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
8577 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8578 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8579 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8580 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8581 }
8582}
8583
8584static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
8585{
8586 if ((res >> 26) == ALC880_HP_EVENT)
8587 alc889A_mb31_automute(codec);
8588}
8589
Takashi Iwai4953550a2009-06-30 15:28:30 +02008590
Takashi Iwaicb53c622007-08-10 17:21:45 +02008591#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwai4953550a2009-06-30 15:28:30 +02008592#define alc882_loopbacks alc880_loopbacks
Takashi Iwaicb53c622007-08-10 17:21:45 +02008593#endif
8594
Sasha Alexandrdef319f2009-06-16 16:00:15 -04008595/* pcm configuration: identical with ALC880 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008596#define alc882_pcm_analog_playback alc880_pcm_analog_playback
8597#define alc882_pcm_analog_capture alc880_pcm_analog_capture
8598#define alc882_pcm_digital_playback alc880_pcm_digital_playback
8599#define alc882_pcm_digital_capture alc880_pcm_digital_capture
8600
8601static hda_nid_t alc883_slave_dig_outs[] = {
8602 ALC1200_DIGOUT_NID, 0,
8603};
8604
8605static hda_nid_t alc1200_slave_dig_outs[] = {
8606 ALC883_DIGOUT_NID, 0,
8607};
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008608
8609/*
8610 * configuration and preset
8611 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008612static const char *alc882_models[ALC882_MODEL_LAST] = {
8613 [ALC882_3ST_DIG] = "3stack-dig",
8614 [ALC882_6ST_DIG] = "6stack-dig",
8615 [ALC882_ARIMA] = "arima",
8616 [ALC882_W2JC] = "w2jc",
8617 [ALC882_TARGA] = "targa",
8618 [ALC882_ASUS_A7J] = "asus-a7j",
8619 [ALC882_ASUS_A7M] = "asus-a7m",
8620 [ALC885_MACPRO] = "macpro",
8621 [ALC885_MB5] = "mb5",
8622 [ALC885_MBP3] = "mbp3",
8623 [ALC885_IMAC24] = "imac24",
8624 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008625 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
8626 [ALC883_3ST_6ch] = "3stack-6ch",
Takashi Iwai4953550a2009-06-30 15:28:30 +02008627 [ALC883_6ST_DIG] = "alc883-6stack-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008628 [ALC883_TARGA_DIG] = "targa-dig",
8629 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +02008630 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008631 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02008632 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008633 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaib1a91462009-06-21 10:56:44 +02008634 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
Hector Martin3b315d72009-06-02 10:54:19 +02008635 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008636 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02008637 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008638 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008639 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02008640 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
8641 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02008642 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02008643 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008644 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008645 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008646 [ALC883_MITAC] = "mitac",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008647 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01008648 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008649 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02008650 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008651 [ALC889A_INTEL] = "intel-alc889a",
8652 [ALC889_INTEL] = "intel-x58",
Wu Fengguang3ab90932008-11-17 09:51:09 +01008653 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008654 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c2009-06-05 00:47:26 +02008655 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwai4953550a2009-06-30 15:28:30 +02008656 [ALC882_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008657};
8658
Takashi Iwai4953550a2009-06-30 15:28:30 +02008659static struct snd_pci_quirk alc882_cfg_tbl[] = {
8660 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
8661
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008662 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01008663 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01008664 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008665 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
8666 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02008667 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008668 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
8669 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008670 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
8671 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +02008672 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
8673 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +02008674 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
8675 ALC888_ACER_ASPIRE_8930G),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008676 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
8677 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008678 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
Takashi Iwaidde65352009-06-25 08:25:35 +02008679 ALC888_ACER_ASPIRE_6530G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01008680 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
Tony Vroond2fd4b02009-06-21 00:40:10 +01008681 ALC888_ACER_ASPIRE_6530G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02008682 /* default Acer -- disabled as it causes more problems.
8683 * model=auto should work fine now
8684 */
8685 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008686
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008687 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008688
Tobin Davisfebe3372007-06-12 11:27:46 +02008689 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008690 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
8691 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01008692 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01008693 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03008694 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008695
8696 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
8697 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
8698 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Kailang Yanga01c30c2008-10-15 11:14:58 +02008699 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008700 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
8701 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
8702 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008703 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01008704 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01008705 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02008706 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008707
8708 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Travis Place97ec7102008-05-23 18:31:46 +02008709 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008710 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008711 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008712 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
8713 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02008714 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008715 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008716 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
8717
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008718 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
8719 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
8720 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008721 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Jiang zhe4383fae2008-04-14 12:58:57 +02008722 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008723 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008724 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01008725 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008726 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
8727 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
8728 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
8729 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
8730 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
8731 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
William Westonb1e44222009-07-08 01:10:05 -07008732 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008733 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
8734 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
8735 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +02008736 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008737 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
8738 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02008739 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01008740 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01008741 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01008742 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02008743 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -04008744 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008745 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
William Westonb1e44222009-07-08 01:10:05 -07008746 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008747
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008748 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008749 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
8750 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
Takashi Iwaidea0a502009-02-09 17:14:52 +01008751 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04008752 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008753 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008754 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02008755 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01008756 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02008757 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008758 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02008759 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02008760 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008761 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
8762 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02008763 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02008764 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01008765 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01008766 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02008767 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008768
Jiang zhe17bba1b2008-06-04 12:11:07 +02008769 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
8770 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008771 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008772 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
8773 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
8774 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008775 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008776
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008777 {}
8778};
8779
Takashi Iwai4953550a2009-06-30 15:28:30 +02008780/* codec SSID table for Intel Mac */
8781static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
8782 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
8783 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
8784 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
8785 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
8786 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
8787 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
8788 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
8789 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
8790 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
8791 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
8792 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
8793 /* FIXME: HP jack sense seems not working for MBP 5,1, so apparently
8794 * no perfect solution yet
8795 */
8796 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
8797 {} /* terminator */
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08008798};
8799
Takashi Iwai4953550a2009-06-30 15:28:30 +02008800static struct alc_config_preset alc882_presets[] = {
8801 [ALC882_3ST_DIG] = {
8802 .mixers = { alc882_base_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008803 .init_verbs = { alc882_base_init_verbs,
8804 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02008805 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8806 .dac_nids = alc882_dac_nids,
8807 .dig_out_nid = ALC882_DIGOUT_NID,
8808 .dig_in_nid = ALC882_DIGIN_NID,
8809 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
8810 .channel_mode = alc882_ch_modes,
8811 .need_dac_fix = 1,
8812 .input_mux = &alc882_capture_source,
8813 },
8814 [ALC882_6ST_DIG] = {
8815 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008816 .init_verbs = { alc882_base_init_verbs,
8817 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02008818 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8819 .dac_nids = alc882_dac_nids,
8820 .dig_out_nid = ALC882_DIGOUT_NID,
8821 .dig_in_nid = ALC882_DIGIN_NID,
8822 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
8823 .channel_mode = alc882_sixstack_modes,
8824 .input_mux = &alc882_capture_source,
8825 },
8826 [ALC882_ARIMA] = {
8827 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008828 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
8829 alc882_eapd_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02008830 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8831 .dac_nids = alc882_dac_nids,
8832 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
8833 .channel_mode = alc882_sixstack_modes,
8834 .input_mux = &alc882_capture_source,
8835 },
8836 [ALC882_W2JC] = {
8837 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008838 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
8839 alc882_eapd_verbs, alc880_gpio1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02008840 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8841 .dac_nids = alc882_dac_nids,
8842 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
8843 .channel_mode = alc880_threestack_modes,
8844 .need_dac_fix = 1,
8845 .input_mux = &alc882_capture_source,
8846 .dig_out_nid = ALC882_DIGOUT_NID,
8847 },
8848 [ALC885_MBP3] = {
8849 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
8850 .init_verbs = { alc885_mbp3_init_verbs,
8851 alc880_gpio1_init_verbs },
8852 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8853 .dac_nids = alc882_dac_nids,
8854 .channel_mode = alc885_mbp_6ch_modes,
8855 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
8856 .input_mux = &alc882_capture_source,
8857 .dig_out_nid = ALC882_DIGOUT_NID,
8858 .dig_in_nid = ALC882_DIGIN_NID,
8859 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008860 .setup = alc885_mbp3_setup,
8861 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +02008862 },
8863 [ALC885_MB5] = {
8864 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
8865 .init_verbs = { alc885_mb5_init_verbs,
8866 alc880_gpio1_init_verbs },
8867 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8868 .dac_nids = alc882_dac_nids,
8869 .channel_mode = alc885_mb5_6ch_modes,
8870 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
8871 .input_mux = &mb5_capture_source,
8872 .dig_out_nid = ALC882_DIGOUT_NID,
8873 .dig_in_nid = ALC882_DIGIN_NID,
8874 },
8875 [ALC885_MACPRO] = {
8876 .mixers = { alc882_macpro_mixer },
8877 .init_verbs = { alc882_macpro_init_verbs },
8878 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8879 .dac_nids = alc882_dac_nids,
8880 .dig_out_nid = ALC882_DIGOUT_NID,
8881 .dig_in_nid = ALC882_DIGIN_NID,
8882 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
8883 .channel_mode = alc882_ch_modes,
8884 .input_mux = &alc882_capture_source,
8885 .init_hook = alc885_macpro_init_hook,
8886 },
8887 [ALC885_IMAC24] = {
8888 .mixers = { alc885_imac24_mixer },
8889 .init_verbs = { alc885_imac24_init_verbs },
8890 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8891 .dac_nids = alc882_dac_nids,
8892 .dig_out_nid = ALC882_DIGOUT_NID,
8893 .dig_in_nid = ALC882_DIGIN_NID,
8894 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
8895 .channel_mode = alc882_ch_modes,
8896 .input_mux = &alc882_capture_source,
8897 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008898 .setup = alc885_imac24_setup,
Takashi Iwai4953550a2009-06-30 15:28:30 +02008899 .init_hook = alc885_imac24_init_hook,
8900 },
8901 [ALC882_TARGA] = {
8902 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008903 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
Takashi Iwai31909b82009-07-10 12:33:48 +02008904 alc880_gpio3_init_verbs, alc882_targa_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02008905 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8906 .dac_nids = alc882_dac_nids,
8907 .dig_out_nid = ALC882_DIGOUT_NID,
8908 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
8909 .adc_nids = alc882_adc_nids,
8910 .capsrc_nids = alc882_capsrc_nids,
8911 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
8912 .channel_mode = alc882_3ST_6ch_modes,
8913 .need_dac_fix = 1,
8914 .input_mux = &alc882_capture_source,
8915 .unsol_event = alc882_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008916 .setup = alc882_targa_setup,
8917 .init_hook = alc882_targa_automute,
Takashi Iwai4953550a2009-06-30 15:28:30 +02008918 },
8919 [ALC882_ASUS_A7J] = {
8920 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008921 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
8922 alc882_asus_a7j_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02008923 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8924 .dac_nids = alc882_dac_nids,
8925 .dig_out_nid = ALC882_DIGOUT_NID,
8926 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
8927 .adc_nids = alc882_adc_nids,
8928 .capsrc_nids = alc882_capsrc_nids,
8929 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
8930 .channel_mode = alc882_3ST_6ch_modes,
8931 .need_dac_fix = 1,
8932 .input_mux = &alc882_capture_source,
8933 },
8934 [ALC882_ASUS_A7M] = {
8935 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008936 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
8937 alc882_eapd_verbs, alc880_gpio1_init_verbs,
Takashi Iwai4953550a2009-06-30 15:28:30 +02008938 alc882_asus_a7m_verbs },
8939 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8940 .dac_nids = alc882_dac_nids,
8941 .dig_out_nid = ALC882_DIGOUT_NID,
8942 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
8943 .channel_mode = alc880_threestack_modes,
8944 .need_dac_fix = 1,
8945 .input_mux = &alc882_capture_source,
8946 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008947 [ALC883_3ST_2ch_DIG] = {
8948 .mixers = { alc883_3ST_2ch_mixer },
8949 .init_verbs = { alc883_init_verbs },
8950 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8951 .dac_nids = alc883_dac_nids,
8952 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008953 .dig_in_nid = ALC883_DIGIN_NID,
8954 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8955 .channel_mode = alc883_3ST_2ch_modes,
8956 .input_mux = &alc883_capture_source,
8957 },
8958 [ALC883_3ST_6ch_DIG] = {
8959 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8960 .init_verbs = { alc883_init_verbs },
8961 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8962 .dac_nids = alc883_dac_nids,
8963 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008964 .dig_in_nid = ALC883_DIGIN_NID,
8965 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8966 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008967 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008968 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008969 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008970 [ALC883_3ST_6ch] = {
8971 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8972 .init_verbs = { alc883_init_verbs },
8973 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8974 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008975 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8976 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008977 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008978 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008979 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02008980 [ALC883_3ST_6ch_INTEL] = {
8981 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
8982 .init_verbs = { alc883_init_verbs },
8983 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8984 .dac_nids = alc883_dac_nids,
8985 .dig_out_nid = ALC883_DIGOUT_NID,
8986 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08008987 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +02008988 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
8989 .channel_mode = alc883_3ST_6ch_intel_modes,
8990 .need_dac_fix = 1,
8991 .input_mux = &alc883_3stack_6ch_intel,
8992 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008993 [ALC889A_INTEL] = {
8994 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +02008995 .init_verbs = { alc885_init_verbs, alc885_init_input_verbs,
8996 alc_hp15_unsol_verbs },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008997 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8998 .dac_nids = alc883_dac_nids,
8999 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9000 .adc_nids = alc889_adc_nids,
9001 .dig_out_nid = ALC883_DIGOUT_NID,
9002 .dig_in_nid = ALC883_DIGIN_NID,
9003 .slave_dig_outs = alc883_slave_dig_outs,
9004 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9005 .channel_mode = alc889_8ch_intel_modes,
9006 .capsrc_nids = alc889_capsrc_nids,
9007 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009008 .setup = alc889_automute_setup,
9009 .init_hook = alc_automute_amp,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009010 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009011 .need_dac_fix = 1,
9012 },
9013 [ALC889_INTEL] = {
9014 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
9015 .init_verbs = { alc885_init_verbs, alc889_init_input_verbs,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009016 alc889_eapd_verbs, alc_hp15_unsol_verbs},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009017 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9018 .dac_nids = alc883_dac_nids,
9019 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9020 .adc_nids = alc889_adc_nids,
9021 .dig_out_nid = ALC883_DIGOUT_NID,
9022 .dig_in_nid = ALC883_DIGIN_NID,
9023 .slave_dig_outs = alc883_slave_dig_outs,
9024 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9025 .channel_mode = alc889_8ch_intel_modes,
9026 .capsrc_nids = alc889_capsrc_nids,
9027 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009028 .setup = alc889_automute_setup,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009029 .init_hook = alc889_intel_init_hook,
9030 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009031 .need_dac_fix = 1,
9032 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009033 [ALC883_6ST_DIG] = {
9034 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9035 .init_verbs = { alc883_init_verbs },
9036 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9037 .dac_nids = alc883_dac_nids,
9038 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009039 .dig_in_nid = ALC883_DIGIN_NID,
9040 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9041 .channel_mode = alc883_sixstack_modes,
9042 .input_mux = &alc883_capture_source,
9043 },
Kailang Yangccc656c2006-10-17 12:32:26 +02009044 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009045 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
David Heidelberger005b1072009-07-09 18:45:46 +02009046 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9047 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009048 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9049 .dac_nids = alc883_dac_nids,
9050 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009051 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9052 .channel_mode = alc883_3ST_6ch_modes,
9053 .need_dac_fix = 1,
9054 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009055 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009056 .setup = alc882_targa_setup,
9057 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009058 },
9059 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009060 .mixers = { alc883_targa_2ch_mixer},
David Heidelberger005b1072009-07-09 18:45:46 +02009061 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9062 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009063 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9064 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009065 .adc_nids = alc883_adc_nids_alt,
9066 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangccc656c2006-10-17 12:32:26 +02009067 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009068 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9069 .channel_mode = alc883_3ST_2ch_modes,
9070 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009071 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009072 .setup = alc882_targa_setup,
9073 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009074 },
David Heidelberger64a8be72009-06-08 16:15:18 +02009075 [ALC883_TARGA_8ch_DIG] = {
9076 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9077 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009078 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +02009079 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9080 .dac_nids = alc883_dac_nids,
9081 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9082 .adc_nids = alc883_adc_nids_rev,
9083 .capsrc_nids = alc883_capsrc_nids_rev,
9084 .dig_out_nid = ALC883_DIGOUT_NID,
9085 .dig_in_nid = ALC883_DIGIN_NID,
9086 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
9087 .channel_mode = alc883_4ST_8ch_modes,
9088 .need_dac_fix = 1,
9089 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009090 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009091 .setup = alc882_targa_setup,
9092 .init_hook = alc882_targa_automute,
David Heidelberger64a8be72009-06-08 16:15:18 +02009093 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009094 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009095 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009096 /* On TravelMate laptops, GPIO 0 enables the internal speaker
9097 * and the headphone jack. Turn this on and rely on the
9098 * standard mute methods whenever the user wants to turn
9099 * these outputs off.
9100 */
9101 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
9102 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9103 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009104 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9105 .channel_mode = alc883_3ST_2ch_modes,
9106 .input_mux = &alc883_capture_source,
9107 },
Tobin Davis2880a862007-08-07 11:50:26 +02009108 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009109 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02009110 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02009111 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9112 .dac_nids = alc883_dac_nids,
9113 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02009114 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9115 .channel_mode = alc883_3ST_2ch_modes,
9116 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009117 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009118 .setup = alc883_acer_aspire_setup,
9119 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +02009120 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009121 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009122 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009123 alc883_chmode_mixer },
9124 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9125 alc888_acer_aspire_4930g_verbs },
9126 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9127 .dac_nids = alc883_dac_nids,
9128 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9129 .adc_nids = alc883_adc_nids_rev,
9130 .capsrc_nids = alc883_capsrc_nids_rev,
9131 .dig_out_nid = ALC883_DIGOUT_NID,
9132 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9133 .channel_mode = alc883_3ST_6ch_modes,
9134 .need_dac_fix = 1,
9135 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009136 ARRAY_SIZE(alc888_2_capture_sources),
9137 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009138 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009139 .setup = alc888_acer_aspire_4930g_setup,
9140 .init_hook = alc_automute_amp,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009141 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01009142 [ALC888_ACER_ASPIRE_6530G] = {
9143 .mixers = { alc888_acer_aspire_6530_mixer },
9144 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9145 alc888_acer_aspire_6530g_verbs },
9146 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9147 .dac_nids = alc883_dac_nids,
9148 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9149 .adc_nids = alc883_adc_nids_rev,
9150 .capsrc_nids = alc883_capsrc_nids_rev,
9151 .dig_out_nid = ALC883_DIGOUT_NID,
9152 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9153 .channel_mode = alc883_3ST_2ch_modes,
9154 .num_mux_defs =
9155 ARRAY_SIZE(alc888_2_capture_sources),
9156 .input_mux = alc888_acer_aspire_6530_sources,
9157 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009158 .setup = alc888_acer_aspire_6530g_setup,
9159 .init_hook = alc_automute_amp,
Tony Vroond2fd4b02009-06-21 00:40:10 +01009160 },
Hector Martin3b315d72009-06-02 10:54:19 +02009161 [ALC888_ACER_ASPIRE_8930G] = {
9162 .mixers = { alc888_base_mixer,
9163 alc883_chmode_mixer },
9164 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin018df412009-06-04 00:13:40 +02009165 alc889_acer_aspire_8930g_verbs },
Hector Martin3b315d72009-06-02 10:54:19 +02009166 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9167 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +02009168 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9169 .adc_nids = alc889_adc_nids,
9170 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +02009171 .dig_out_nid = ALC883_DIGOUT_NID,
9172 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9173 .channel_mode = alc883_3ST_6ch_modes,
9174 .need_dac_fix = 1,
9175 .const_channel_count = 6,
9176 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +02009177 ARRAY_SIZE(alc889_capture_sources),
9178 .input_mux = alc889_capture_sources,
Hector Martin3b315d72009-06-02 10:54:19 +02009179 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009180 .setup = alc889_acer_aspire_8930g_setup,
9181 .init_hook = alc_automute_amp,
Hector Martin3b315d72009-06-02 10:54:19 +02009182 },
Tobin Davisc07584c2006-10-13 12:32:16 +02009183 [ALC883_MEDION] = {
9184 .mixers = { alc883_fivestack_mixer,
9185 alc883_chmode_mixer },
9186 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009187 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02009188 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9189 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009190 .adc_nids = alc883_adc_nids_alt,
9191 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Tobin Davisc07584c2006-10-13 12:32:16 +02009192 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9193 .channel_mode = alc883_sixstack_modes,
9194 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009195 },
Kailang Yang272a5272007-05-14 11:00:38 +02009196 [ALC883_MEDION_MD2] = {
9197 .mixers = { alc883_medion_md2_mixer},
9198 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
9199 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9200 .dac_nids = alc883_dac_nids,
9201 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009202 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9203 .channel_mode = alc883_3ST_2ch_modes,
9204 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009205 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009206 .setup = alc883_medion_md2_setup,
9207 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +02009208 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009209 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009210 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009211 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
9212 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9213 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009214 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9215 .channel_mode = alc883_3ST_2ch_modes,
9216 .input_mux = &alc883_capture_source,
9217 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009218 [ALC883_CLEVO_M720] = {
9219 .mixers = { alc883_clevo_m720_mixer },
9220 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01009221 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9222 .dac_nids = alc883_dac_nids,
9223 .dig_out_nid = ALC883_DIGOUT_NID,
9224 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9225 .channel_mode = alc883_3ST_2ch_modes,
9226 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009227 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009228 .setup = alc883_clevo_m720_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009229 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +01009230 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009231 [ALC883_LENOVO_101E_2ch] = {
9232 .mixers = { alc883_lenovo_101e_2ch_mixer},
9233 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
9234 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9235 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009236 .adc_nids = alc883_adc_nids_alt,
9237 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009238 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9239 .channel_mode = alc883_3ST_2ch_modes,
9240 .input_mux = &alc883_lenovo_101e_capture_source,
9241 .unsol_event = alc883_lenovo_101e_unsol_event,
9242 .init_hook = alc883_lenovo_101e_all_automute,
9243 },
Kailang Yang272a5272007-05-14 11:00:38 +02009244 [ALC883_LENOVO_NB0763] = {
9245 .mixers = { alc883_lenovo_nb0763_mixer },
9246 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
9247 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9248 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02009249 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9250 .channel_mode = alc883_3ST_2ch_modes,
9251 .need_dac_fix = 1,
9252 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009253 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009254 .setup = alc883_medion_md2_setup,
9255 .init_hook = alc_automute_amp,
Kailang Yang272a5272007-05-14 11:00:38 +02009256 },
9257 [ALC888_LENOVO_MS7195_DIG] = {
9258 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9259 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
9260 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9261 .dac_nids = alc883_dac_nids,
9262 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009263 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9264 .channel_mode = alc883_3ST_6ch_modes,
9265 .need_dac_fix = 1,
9266 .input_mux = &alc883_capture_source,
9267 .unsol_event = alc883_lenovo_ms7195_unsol_event,
9268 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02009269 },
9270 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009271 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +02009272 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
9273 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9274 .dac_nids = alc883_dac_nids,
9275 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02009276 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9277 .channel_mode = alc883_3ST_2ch_modes,
9278 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009279 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009280 .setup = alc883_haier_w66_setup,
9281 .init_hook = alc_automute_amp,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009282 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009283 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009284 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009285 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009286 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9287 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009288 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
9289 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009290 .need_dac_fix = 1,
9291 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009292 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009293 .setup = alc888_3st_hp_setup,
9294 .init_hook = alc_automute_amp,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009295 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009296 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01009297 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009298 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
9299 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9300 .dac_nids = alc883_dac_nids,
9301 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009302 .dig_in_nid = ALC883_DIGIN_NID,
9303 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9304 .channel_mode = alc883_sixstack_modes,
9305 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009306 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009307 .setup = alc888_6st_dell_setup,
9308 .init_hook = alc_automute_amp,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009309 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009310 [ALC883_MITAC] = {
9311 .mixers = { alc883_mitac_mixer },
9312 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
9313 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9314 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009315 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9316 .channel_mode = alc883_3ST_2ch_modes,
9317 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009318 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009319 .setup = alc883_mitac_setup,
9320 .init_hook = alc_automute_amp,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009321 },
Jiang zhefb97dc62008-03-06 11:07:11 +01009322 [ALC883_FUJITSU_PI2515] = {
9323 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
9324 .init_verbs = { alc883_init_verbs,
9325 alc883_2ch_fujitsu_pi2515_verbs},
9326 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9327 .dac_nids = alc883_dac_nids,
9328 .dig_out_nid = ALC883_DIGOUT_NID,
9329 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9330 .channel_mode = alc883_3ST_2ch_modes,
9331 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009332 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009333 .setup = alc883_2ch_fujitsu_pi2515_setup,
9334 .init_hook = alc_automute_amp,
Jiang zhefb97dc62008-03-06 11:07:11 +01009335 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009336 [ALC888_FUJITSU_XA3530] = {
9337 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
9338 .init_verbs = { alc883_init_verbs,
9339 alc888_fujitsu_xa3530_verbs },
9340 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9341 .dac_nids = alc883_dac_nids,
9342 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9343 .adc_nids = alc883_adc_nids_rev,
9344 .capsrc_nids = alc883_capsrc_nids_rev,
9345 .dig_out_nid = ALC883_DIGOUT_NID,
9346 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
9347 .channel_mode = alc888_4ST_8ch_intel_modes,
9348 .num_mux_defs =
9349 ARRAY_SIZE(alc888_2_capture_sources),
9350 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009351 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009352 .setup = alc888_fujitsu_xa3530_setup,
9353 .init_hook = alc_automute_amp,
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009354 },
Kailang Yange2757d52008-08-26 13:17:46 +02009355 [ALC888_LENOVO_SKY] = {
9356 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
9357 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
9358 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9359 .dac_nids = alc883_dac_nids,
9360 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +02009361 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9362 .channel_mode = alc883_sixstack_modes,
9363 .need_dac_fix = 1,
9364 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009365 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009366 .setup = alc888_lenovo_sky_setup,
9367 .init_hook = alc_automute_amp,
Kailang Yange2757d52008-08-26 13:17:46 +02009368 },
9369 [ALC888_ASUS_M90V] = {
9370 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9371 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
9372 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9373 .dac_nids = alc883_dac_nids,
9374 .dig_out_nid = ALC883_DIGOUT_NID,
9375 .dig_in_nid = ALC883_DIGIN_NID,
9376 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9377 .channel_mode = alc883_3ST_6ch_modes,
9378 .need_dac_fix = 1,
9379 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009380 .unsol_event = alc_sku_unsol_event,
9381 .setup = alc883_mode2_setup,
9382 .init_hook = alc_inithook,
Kailang Yange2757d52008-08-26 13:17:46 +02009383 },
9384 [ALC888_ASUS_EEE1601] = {
9385 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009386 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +02009387 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
9388 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9389 .dac_nids = alc883_dac_nids,
9390 .dig_out_nid = ALC883_DIGOUT_NID,
9391 .dig_in_nid = ALC883_DIGIN_NID,
9392 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9393 .channel_mode = alc883_3ST_2ch_modes,
9394 .need_dac_fix = 1,
9395 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009396 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +02009397 .init_hook = alc883_eee1601_inithook,
9398 },
Wu Fengguang3ab90932008-11-17 09:51:09 +01009399 [ALC1200_ASUS_P5Q] = {
9400 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9401 .init_verbs = { alc883_init_verbs },
9402 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9403 .dac_nids = alc883_dac_nids,
9404 .dig_out_nid = ALC1200_DIGOUT_NID,
9405 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +08009406 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +01009407 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9408 .channel_mode = alc883_sixstack_modes,
9409 .input_mux = &alc883_capture_source,
9410 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009411 [ALC889A_MB31] = {
9412 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
9413 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
9414 alc880_gpio1_init_verbs },
9415 .adc_nids = alc883_adc_nids,
9416 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
9417 .dac_nids = alc883_dac_nids,
9418 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9419 .channel_mode = alc889A_mb31_6ch_modes,
9420 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
9421 .input_mux = &alc889A_mb31_capture_source,
9422 .dig_out_nid = ALC883_DIGOUT_NID,
9423 .unsol_event = alc889A_mb31_unsol_event,
9424 .init_hook = alc889A_mb31_automute,
9425 },
Guido Günther3e1647c2009-06-05 00:47:26 +02009426 [ALC883_SONY_VAIO_TT] = {
9427 .mixers = { alc883_vaiott_mixer },
9428 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
9429 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9430 .dac_nids = alc883_dac_nids,
9431 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9432 .channel_mode = alc883_3ST_2ch_modes,
9433 .input_mux = &alc883_capture_source,
9434 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009435 .setup = alc883_vaiott_setup,
9436 .init_hook = alc_automute_amp,
Guido Günther3e1647c2009-06-05 00:47:26 +02009437 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009438};
9439
9440
9441/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02009442 * Pin config fixes
9443 */
9444enum {
9445 PINFIX_ABIT_AW9D_MAX
9446};
9447
9448static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
9449 { 0x15, 0x01080104 }, /* side */
9450 { 0x16, 0x01011012 }, /* rear */
9451 { 0x17, 0x01016011 }, /* clfe */
9452 { }
9453};
9454
9455static const struct alc_pincfg *alc882_pin_fixes[] = {
9456 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
9457};
9458
9459static struct snd_pci_quirk alc882_pinfix_tbl[] = {
9460 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
9461 {}
9462};
9463
9464/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009465 * BIOS auto configuration
9466 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009467static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009468 hda_nid_t nid, int pin_type,
9469 int dac_idx)
9470{
9471 /* set as output */
9472 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009473 int idx;
9474
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009475 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009476 if (spec->multiout.dac_nids[dac_idx] == 0x25)
9477 idx = 4;
9478 else
9479 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009480 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
9481
9482}
9483
Takashi Iwai4953550a2009-06-30 15:28:30 +02009484static void alc882_auto_init_multi_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009485{
9486 struct alc_spec *spec = codec->spec;
9487 int i;
9488
9489 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009490 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009491 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009492 if (nid)
Takashi Iwai4953550a2009-06-30 15:28:30 +02009493 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009494 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009495 }
9496}
9497
Takashi Iwai4953550a2009-06-30 15:28:30 +02009498static void alc882_auto_init_hp_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009499{
9500 struct alc_spec *spec = codec->spec;
9501 hda_nid_t pin;
9502
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009503 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009504 if (pin) /* connect to front */
9505 /* use dac 0 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009506 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009507 pin = spec->autocfg.speaker_pins[0];
9508 if (pin)
Takashi Iwai4953550a2009-06-30 15:28:30 +02009509 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009510}
9511
Takashi Iwai4953550a2009-06-30 15:28:30 +02009512static void alc882_auto_init_analog_input(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009513{
9514 struct alc_spec *spec = codec->spec;
9515 int i;
9516
9517 for (i = 0; i < AUTO_PIN_LAST; i++) {
9518 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai4953550a2009-06-30 15:28:30 +02009519 if (!nid)
9520 continue;
Takashi Iwai0d971c92009-06-30 16:11:11 +02009521 alc_set_input_pin(codec, nid, i);
Takashi Iwai4953550a2009-06-30 15:28:30 +02009522 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
9523 snd_hda_codec_write(codec, nid, 0,
9524 AC_VERB_SET_AMP_GAIN_MUTE,
9525 AMP_OUT_MUTE);
9526 }
9527}
9528
9529static void alc882_auto_init_input_src(struct hda_codec *codec)
9530{
9531 struct alc_spec *spec = codec->spec;
9532 int c;
9533
9534 for (c = 0; c < spec->num_adc_nids; c++) {
9535 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
9536 hda_nid_t nid = spec->capsrc_nids[c];
9537 unsigned int mux_idx;
9538 const struct hda_input_mux *imux;
9539 int conns, mute, idx, item;
9540
9541 conns = snd_hda_get_connections(codec, nid, conn_list,
9542 ARRAY_SIZE(conn_list));
9543 if (conns < 0)
9544 continue;
9545 mux_idx = c >= spec->num_mux_defs ? 0 : c;
9546 imux = &spec->input_mux[mux_idx];
9547 for (idx = 0; idx < conns; idx++) {
9548 /* if the current connection is the selected one,
9549 * unmute it as default - otherwise mute it
9550 */
9551 mute = AMP_IN_MUTE(idx);
9552 for (item = 0; item < imux->num_items; item++) {
9553 if (imux->items[item].index == idx) {
9554 if (spec->cur_mux[c] == item)
9555 mute = AMP_IN_UNMUTE(idx);
9556 break;
9557 }
9558 }
9559 /* check if we have a selector or mixer
9560 * we could check for the widget type instead, but
9561 * just check for Amp-In presence (in case of mixer
9562 * without amp-in there is something wrong, this
9563 * function shouldn't be used or capsrc nid is wrong)
9564 */
9565 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009566 snd_hda_codec_write(codec, nid, 0,
9567 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009568 mute);
9569 else if (mute != AMP_IN_MUTE(idx))
9570 snd_hda_codec_write(codec, nid, 0,
9571 AC_VERB_SET_CONNECT_SEL,
9572 idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009573 }
9574 }
9575}
9576
Takashi Iwai4953550a2009-06-30 15:28:30 +02009577/* add mic boosts if needed */
9578static int alc_auto_add_mic_boost(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009579{
9580 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +02009581 int err;
9582 hda_nid_t nid;
9583
9584 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
9585 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
9586 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9587 "Mic Boost",
9588 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9589 if (err < 0)
9590 return err;
9591 }
9592 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
9593 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
9594 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9595 "Front Mic Boost",
9596 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9597 if (err < 0)
9598 return err;
9599 }
9600 return 0;
9601}
9602
9603/* almost identical with ALC880 parser... */
9604static int alc882_parse_auto_config(struct hda_codec *codec)
9605{
9606 struct alc_spec *spec = codec->spec;
9607 struct auto_pin_cfg *autocfg = &spec->autocfg;
9608 unsigned int wcap;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009609 int i;
Takashi Iwai4953550a2009-06-30 15:28:30 +02009610 int err = alc880_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009611
9612 if (err < 0)
9613 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02009614 else if (!err)
9615 return 0; /* no config found */
9616
9617 err = alc_auto_add_mic_boost(codec);
9618 if (err < 0)
9619 return err;
9620
9621 /* hack - override the init verbs */
9622 spec->init_verbs[0] = alc883_auto_init_verbs;
Takashi Iwai4953550a2009-06-30 15:28:30 +02009623 /* if ADC 0x07 is available, initialize it, too */
9624 wcap = get_wcaps(codec, 0x07);
Takashi Iwaia22d5432009-07-27 12:54:26 +02009625 wcap = get_wcaps_type(wcap);
Takashi Iwai4953550a2009-06-30 15:28:30 +02009626 if (wcap == AC_WID_AUD_IN)
9627 add_verb(spec, alc882_adc1_init_verbs);
Takashi Iwai776e1842007-08-29 15:07:11 +02009628
Takashi Iwai4953550a2009-06-30 15:28:30 +02009629 /* digital-mic input pin is excluded in alc880_auto_create..()
9630 * because it's under 0x18
9631 */
9632 if (autocfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
9633 autocfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
9634 struct hda_input_mux *imux = &spec->private_imux[0];
9635 for (i = 1; i < 3; i++)
9636 memcpy(&spec->private_imux[i],
9637 &spec->private_imux[0],
9638 sizeof(spec->private_imux[0]));
9639 imux->items[imux->num_items].label = "Int DMic";
9640 imux->items[imux->num_items].index = 0x0b;
9641 imux->num_items++;
9642 spec->num_mux_defs = 3;
9643 spec->input_mux = spec->private_imux;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009644 }
9645
Takashi Iwai776e1842007-08-29 15:07:11 +02009646 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009647}
9648
9649/* additional initialization for auto-configuration model */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009650static void alc882_auto_init(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009651{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009652 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +02009653 alc882_auto_init_multi_out(codec);
9654 alc882_auto_init_hp_out(codec);
9655 alc882_auto_init_analog_input(codec);
9656 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009657 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02009658 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009659}
9660
Takashi Iwai4953550a2009-06-30 15:28:30 +02009661static int patch_alc882(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009662{
9663 struct alc_spec *spec;
9664 int err, board_config;
9665
9666 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
9667 if (spec == NULL)
9668 return -ENOMEM;
9669
9670 codec->spec = spec;
9671
Takashi Iwai4953550a2009-06-30 15:28:30 +02009672 switch (codec->vendor_id) {
9673 case 0x10ec0882:
9674 case 0x10ec0885:
9675 break;
9676 default:
9677 /* ALC883 and variants */
9678 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
9679 break;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009680 }
9681
Takashi Iwai4953550a2009-06-30 15:28:30 +02009682 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
9683 alc882_models,
9684 alc882_cfg_tbl);
9685
9686 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
9687 board_config = snd_hda_check_board_codec_sid_config(codec,
9688 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
9689
9690 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02009691 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009692 codec->chip_name);
9693 board_config = ALC882_AUTO;
9694 }
9695
9696 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
9697
9698 if (board_config == ALC882_AUTO) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009699 /* automatic parse from the BIOS config */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009700 err = alc882_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009701 if (err < 0) {
9702 alc_free(codec);
9703 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009704 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009705 printk(KERN_INFO
9706 "hda_codec: Cannot set up configuration "
9707 "from BIOS. Using base mode...\n");
Takashi Iwai4953550a2009-06-30 15:28:30 +02009708 board_config = ALC882_3ST_DIG;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009709 }
9710 }
9711
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09009712 err = snd_hda_attach_beep_device(codec, 0x1);
9713 if (err < 0) {
9714 alc_free(codec);
9715 return err;
9716 }
9717
Takashi Iwai4953550a2009-06-30 15:28:30 +02009718 if (board_config != ALC882_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02009719 setup_preset(codec, &alc882_presets[board_config]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009720
Takashi Iwai4953550a2009-06-30 15:28:30 +02009721 spec->stream_analog_playback = &alc882_pcm_analog_playback;
9722 spec->stream_analog_capture = &alc882_pcm_analog_capture;
9723 /* FIXME: setup DAC5 */
9724 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
9725 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
9726
9727 spec->stream_digital_playback = &alc882_pcm_digital_playback;
9728 spec->stream_digital_capture = &alc882_pcm_digital_capture;
9729
9730 if (codec->vendor_id == 0x10ec0888)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02009731 spec->init_amp = ALC_INIT_DEFAULT; /* always initialize */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009732
9733 if (!spec->adc_nids && spec->input_mux) {
9734 int i;
9735 spec->num_adc_nids = 0;
9736 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
9737 hda_nid_t cap;
9738 hda_nid_t nid = alc882_adc_nids[i];
9739 unsigned int wcap = get_wcaps(codec, nid);
9740 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02009741 wcap = get_wcaps_type(wcap);
Takashi Iwai4953550a2009-06-30 15:28:30 +02009742 if (wcap != AC_WID_AUD_IN)
9743 continue;
9744 spec->private_adc_nids[spec->num_adc_nids] = nid;
9745 err = snd_hda_get_connections(codec, nid, &cap, 1);
9746 if (err < 0)
9747 continue;
9748 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
9749 spec->num_adc_nids++;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009750 }
Takashi Iwai4953550a2009-06-30 15:28:30 +02009751 spec->adc_nids = spec->private_adc_nids;
9752 spec->capsrc_nids = spec->private_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +02009753 }
9754
Takashi Iwaib59bdf32009-08-11 09:47:30 +02009755 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01009756 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009757
Takashi Iwai2134ea42008-01-10 16:53:55 +01009758 spec->vmaster_nid = 0x0c;
9759
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009760 codec->patch_ops = alc_patch_ops;
Takashi Iwai4953550a2009-06-30 15:28:30 +02009761 if (board_config == ALC882_AUTO)
9762 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02009763#ifdef CONFIG_SND_HDA_POWER_SAVE
9764 if (!spec->loopback.amplist)
Takashi Iwai4953550a2009-06-30 15:28:30 +02009765 spec->loopback.amplist = alc882_loopbacks;
Takashi Iwaicb53c622007-08-10 17:21:45 +02009766#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01009767 codec->proc_widget_hook = print_realtek_coef;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009768
9769 return 0;
9770}
9771
Takashi Iwai4953550a2009-06-30 15:28:30 +02009772
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009773/*
Kailang Yangdf694da2005-12-05 19:42:22 +01009774 * ALC262 support
9775 */
9776
9777#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
9778#define ALC262_DIGIN_NID ALC880_DIGIN_NID
9779
9780#define alc262_dac_nids alc260_dac_nids
9781#define alc262_adc_nids alc882_adc_nids
9782#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +01009783#define alc262_capsrc_nids alc882_capsrc_nids
9784#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +01009785
9786#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01009787#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01009788
Kailang Yang4e555fe2008-08-26 13:05:55 +02009789static hda_nid_t alc262_dmic_adc_nids[1] = {
9790 /* ADC0 */
9791 0x09
9792};
9793
9794static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
9795
Kailang Yangdf694da2005-12-05 19:42:22 +01009796static struct snd_kcontrol_new alc262_base_mixer[] = {
9797 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9798 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9799 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9800 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9801 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9802 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9803 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9804 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009805 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009806 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9807 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009808 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009809 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
9810 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9811 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
9812 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009813 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01009814};
9815
Takashi Iwaice875f02008-01-28 18:17:43 +01009816/* update HP, line and mono-out pins according to the master switch */
9817static void alc262_hp_master_update(struct hda_codec *codec)
9818{
9819 struct alc_spec *spec = codec->spec;
9820 int val = spec->master_sw;
9821
9822 /* HP & line-out */
9823 snd_hda_codec_write_cache(codec, 0x1b, 0,
9824 AC_VERB_SET_PIN_WIDGET_CONTROL,
9825 val ? PIN_HP : 0);
9826 snd_hda_codec_write_cache(codec, 0x15, 0,
9827 AC_VERB_SET_PIN_WIDGET_CONTROL,
9828 val ? PIN_HP : 0);
9829 /* mono (speaker) depending on the HP jack sense */
9830 val = val && !spec->jack_present;
9831 snd_hda_codec_write_cache(codec, 0x16, 0,
9832 AC_VERB_SET_PIN_WIDGET_CONTROL,
9833 val ? PIN_OUT : 0);
9834}
9835
9836static void alc262_hp_bpc_automute(struct hda_codec *codec)
9837{
9838 struct alc_spec *spec = codec->spec;
9839 unsigned int presence;
9840 presence = snd_hda_codec_read(codec, 0x1b, 0,
9841 AC_VERB_GET_PIN_SENSE, 0);
9842 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9843 alc262_hp_master_update(codec);
9844}
9845
9846static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
9847{
9848 if ((res >> 26) != ALC880_HP_EVENT)
9849 return;
9850 alc262_hp_bpc_automute(codec);
9851}
9852
9853static void alc262_hp_wildwest_automute(struct hda_codec *codec)
9854{
9855 struct alc_spec *spec = codec->spec;
9856 unsigned int presence;
9857 presence = snd_hda_codec_read(codec, 0x15, 0,
9858 AC_VERB_GET_PIN_SENSE, 0);
9859 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9860 alc262_hp_master_update(codec);
9861}
9862
9863static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
9864 unsigned int res)
9865{
9866 if ((res >> 26) != ALC880_HP_EVENT)
9867 return;
9868 alc262_hp_wildwest_automute(codec);
9869}
9870
Takashi Iwaib72519b2009-05-08 14:31:55 +02009871#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +01009872
9873static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
9874 struct snd_ctl_elem_value *ucontrol)
9875{
9876 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9877 struct alc_spec *spec = codec->spec;
9878 int val = !!*ucontrol->value.integer.value;
9879
9880 if (val == spec->master_sw)
9881 return 0;
9882 spec->master_sw = val;
9883 alc262_hp_master_update(codec);
9884 return 1;
9885}
9886
Takashi Iwaib72519b2009-05-08 14:31:55 +02009887#define ALC262_HP_MASTER_SWITCH \
9888 { \
9889 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
9890 .name = "Master Playback Switch", \
9891 .info = snd_ctl_boolean_mono_info, \
9892 .get = alc262_hp_master_sw_get, \
9893 .put = alc262_hp_master_sw_put, \
9894 }
9895
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009896static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +02009897 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009898 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9899 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9900 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009901 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9902 HDA_OUTPUT),
9903 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9904 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009905 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9906 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009907 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009908 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9909 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009910 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009911 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9912 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9913 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9914 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009915 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
9916 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
9917 { } /* end */
9918};
9919
Kailang Yangcd7509a2007-01-26 18:33:17 +01009920static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +02009921 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +01009922 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9923 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9924 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9925 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009926 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9927 HDA_OUTPUT),
9928 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9929 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009930 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
9931 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009932 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009933 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9934 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9935 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9936 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009937 { } /* end */
9938};
9939
9940static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
9941 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9942 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009943 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009944 { } /* end */
9945};
9946
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009947/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009948static void alc262_hp_t5735_setup(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009949{
9950 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009951
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009952 spec->autocfg.hp_pins[0] = 0x15;
9953 spec->autocfg.speaker_pins[0] = 0x0c; /* HACK: not actually a pin */
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009954}
9955
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009956static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +01009957 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9958 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009959 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9960 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9961 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9962 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9963 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9964 { } /* end */
9965};
9966
9967static struct hda_verb alc262_hp_t5735_verbs[] = {
9968 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9969 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9970
9971 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9972 { }
9973};
9974
Kailang Yang8c427222008-01-10 13:03:59 +01009975static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +01009976 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9977 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01009978 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
9979 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +01009980 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9981 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9982 { } /* end */
9983};
9984
9985static struct hda_verb alc262_hp_rp5700_verbs[] = {
9986 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9987 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9988 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9989 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9990 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9991 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9992 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9993 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9994 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9995 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9996 {}
9997};
9998
9999static struct hda_input_mux alc262_hp_rp5700_capture_source = {
10000 .num_items = 1,
10001 .items = {
10002 { "Line", 0x1 },
10003 },
10004};
10005
Takashi Iwai42171c12009-05-08 14:11:43 +020010006/* bind hp and internal speaker mute (with plug check) as master switch */
10007static void alc262_hippo_master_update(struct hda_codec *codec)
10008{
10009 struct alc_spec *spec = codec->spec;
10010 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10011 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
10012 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
10013 unsigned int mute;
10014
10015 /* HP */
10016 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
10017 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
10018 HDA_AMP_MUTE, mute);
10019 /* mute internal speaker per jack sense */
10020 if (spec->jack_present)
10021 mute = HDA_AMP_MUTE;
10022 if (line_nid)
10023 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
10024 HDA_AMP_MUTE, mute);
10025 if (speaker_nid && speaker_nid != line_nid)
10026 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
10027 HDA_AMP_MUTE, mute);
10028}
10029
10030#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
10031
10032static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
10033 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +020010034{
10035 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +020010036 struct alc_spec *spec = codec->spec;
10037 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010038
Takashi Iwai42171c12009-05-08 14:11:43 +020010039 if (val == spec->master_sw)
10040 return 0;
10041 spec->master_sw = val;
10042 alc262_hippo_master_update(codec);
10043 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010044}
Takashi Iwai5b319542007-07-26 11:49:22 +020010045
Takashi Iwai42171c12009-05-08 14:11:43 +020010046#define ALC262_HIPPO_MASTER_SWITCH \
10047 { \
10048 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10049 .name = "Master Playback Switch", \
10050 .info = snd_ctl_boolean_mono_info, \
10051 .get = alc262_hippo_master_sw_get, \
10052 .put = alc262_hippo_master_sw_put, \
10053 }
10054
10055static struct snd_kcontrol_new alc262_hippo_mixer[] = {
10056 ALC262_HIPPO_MASTER_SWITCH,
10057 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10058 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10059 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10060 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10061 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10062 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10063 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10064 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10065 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10066 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10067 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10068 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10069 { } /* end */
10070};
10071
10072static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
10073 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10074 ALC262_HIPPO_MASTER_SWITCH,
10075 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10076 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10077 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10078 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10079 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10080 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10081 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10082 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10083 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10084 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10085 { } /* end */
10086};
10087
10088/* mute/unmute internal speaker according to the hp jack and mute state */
10089static void alc262_hippo_automute(struct hda_codec *codec)
10090{
10091 struct alc_spec *spec = codec->spec;
10092 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10093 unsigned int present;
10094
10095 /* need to execute and sync at first */
10096 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
10097 present = snd_hda_codec_read(codec, hp_nid, 0,
10098 AC_VERB_GET_PIN_SENSE, 0);
10099 spec->jack_present = (present & 0x80000000) != 0;
10100 alc262_hippo_master_update(codec);
10101}
10102
10103static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
10104{
10105 if ((res >> 26) != ALC880_HP_EVENT)
10106 return;
10107 alc262_hippo_automute(codec);
10108}
10109
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010110static void alc262_hippo_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020010111{
10112 struct alc_spec *spec = codec->spec;
10113
10114 spec->autocfg.hp_pins[0] = 0x15;
10115 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020010116}
10117
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010118static void alc262_hippo1_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020010119{
10120 struct alc_spec *spec = codec->spec;
10121
10122 spec->autocfg.hp_pins[0] = 0x1b;
10123 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020010124}
10125
10126
Kailang Yang272a5272007-05-14 11:00:38 +020010127static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +020010128 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020010129 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +020010130 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10131 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10132 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10133 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10134 { } /* end */
10135};
10136
Kailang Yang83c34212007-07-05 11:43:05 +020010137static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020010138 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10139 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +020010140 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10141 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10142 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10143 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10144 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10145 { } /* end */
10146};
Kailang Yang272a5272007-05-14 11:00:38 +020010147
Tony Vroonba340e82009-02-02 19:01:30 +000010148static struct snd_kcontrol_new alc262_tyan_mixer[] = {
10149 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10150 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
10151 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
10152 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
10153 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10154 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10155 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10156 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10157 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10158 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10159 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10160 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10161 { } /* end */
10162};
10163
10164static struct hda_verb alc262_tyan_verbs[] = {
10165 /* Headphone automute */
10166 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10167 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10168 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10169
10170 /* P11 AUX_IN, white 4-pin connector */
10171 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10172 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
10173 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
10174 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
10175
10176 {}
10177};
10178
10179/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010180static void alc262_tyan_setup(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000010181{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010182 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000010183
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010184 spec->autocfg.hp_pins[0] = 0x1b;
10185 spec->autocfg.speaker_pins[0] = 0x15;
Tony Vroonba340e82009-02-02 19:01:30 +000010186}
10187
Tony Vroonba340e82009-02-02 19:01:30 +000010188
Kailang Yangdf694da2005-12-05 19:42:22 +010010189#define alc262_capture_mixer alc882_capture_mixer
10190#define alc262_capture_alt_mixer alc882_capture_alt_mixer
10191
10192/*
10193 * generic initialization of ADC, input mixers and output mixers
10194 */
10195static struct hda_verb alc262_init_verbs[] = {
10196 /*
10197 * Unmute ADC0-2 and set the default input to mic-in
10198 */
10199 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10200 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10201 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10202 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10203 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10204 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10205
Takashi Iwaicb53c622007-08-10 17:21:45 +020010206 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010207 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010208 * Note: PASD motherboards uses the Line In 2 as the input for
10209 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010210 */
10211 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010212 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10213 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10214 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10215 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10216 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010217
10218 /*
10219 * Set up output mixers (0x0c - 0x0e)
10220 */
10221 /* set vol=0 to output mixers */
10222 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10223 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10224 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10225 /* set up input amps for analog loopback */
10226 /* Amp Indices: DAC = 0, mixer = 1 */
10227 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10228 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10229 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10230 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10231 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10232 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10233
10234 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10235 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10236 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10237 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10238 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10239 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10240
10241 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10242 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10243 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10244 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10245 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020010246
Kailang Yangdf694da2005-12-05 19:42:22 +010010247 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10248 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020010249
Kailang Yangdf694da2005-12-05 19:42:22 +010010250 /* FIXME: use matrix-type input source selection */
10251 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10252 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10253 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10254 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10255 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10256 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10257 /* Input mixer2 */
10258 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10259 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10260 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10261 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10262 /* Input mixer3 */
10263 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10264 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10265 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010266 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010010267
10268 { }
10269};
10270
Kailang Yang4e555fe2008-08-26 13:05:55 +020010271static struct hda_verb alc262_eapd_verbs[] = {
10272 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10273 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10274 { }
10275};
10276
Kailang Yangccc656c2006-10-17 12:32:26 +020010277static struct hda_verb alc262_hippo1_unsol_verbs[] = {
10278 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10279 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10280 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10281
10282 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10283 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10284 {}
10285};
10286
Kailang Yang272a5272007-05-14 11:00:38 +020010287static struct hda_verb alc262_sony_unsol_verbs[] = {
10288 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10289 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10290 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
10291
10292 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10293 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090010294 {}
Kailang Yang272a5272007-05-14 11:00:38 +020010295};
10296
Kailang Yang4e555fe2008-08-26 13:05:55 +020010297static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
10298 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10299 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10300 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10301 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10302 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020010303 { } /* end */
10304};
10305
10306static struct hda_verb alc262_toshiba_s06_verbs[] = {
10307 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10308 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10309 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10310 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10311 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
10312 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10313 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
10314 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10315 {}
10316};
10317
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010318static void alc262_toshiba_s06_setup(struct hda_codec *codec)
Kailang Yang4e555fe2008-08-26 13:05:55 +020010319{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010320 struct alc_spec *spec = codec->spec;
10321
10322 spec->autocfg.hp_pins[0] = 0x15;
10323 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010324 spec->ext_mic.pin = 0x18;
10325 spec->ext_mic.mux_idx = 0;
10326 spec->int_mic.pin = 0x12;
10327 spec->int_mic.mux_idx = 9;
10328 spec->auto_mic = 1;
Kailang Yang4e555fe2008-08-26 13:05:55 +020010329}
10330
Takashi Iwai834be882006-03-01 14:16:17 +010010331/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010332 * nec model
10333 * 0x15 = headphone
10334 * 0x16 = internal speaker
10335 * 0x18 = external mic
10336 */
10337
10338static struct snd_kcontrol_new alc262_nec_mixer[] = {
10339 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
10340 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
10341
10342 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10343 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10344 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10345
10346 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10347 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10348 { } /* end */
10349};
10350
10351static struct hda_verb alc262_nec_verbs[] = {
10352 /* Unmute Speaker */
10353 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10354
10355 /* Headphone */
10356 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10357 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10358
10359 /* External mic to headphone */
10360 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10361 /* External mic to speaker */
10362 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10363 {}
10364};
10365
10366/*
Takashi Iwai834be882006-03-01 14:16:17 +010010367 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010010368 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
10369 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010010370 */
10371
10372#define ALC_HP_EVENT 0x37
10373
10374static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
10375 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10376 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010010377 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10378 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010010379 {}
10380};
10381
Jiang zhe0e31daf2008-03-20 12:12:39 +010010382static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
10383 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10384 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10385 {}
10386};
10387
Takashi Iwai834be882006-03-01 14:16:17 +010010388static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010389 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010010390 .items = {
10391 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010392 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010010393 { "CD", 0x4 },
10394 },
10395};
10396
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010397static struct hda_input_mux alc262_HP_capture_source = {
10398 .num_items = 5,
10399 .items = {
10400 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020010401 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010402 { "Line", 0x2 },
10403 { "CD", 0x4 },
10404 { "AUX IN", 0x6 },
10405 },
10406};
10407
zhejiangaccbe492007-08-31 12:36:05 +020010408static struct hda_input_mux alc262_HP_D7000_capture_source = {
10409 .num_items = 4,
10410 .items = {
10411 { "Mic", 0x0 },
10412 { "Front Mic", 0x2 },
10413 { "Line", 0x1 },
10414 { "CD", 0x4 },
10415 },
10416};
10417
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010418/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010010419static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
10420{
10421 struct alc_spec *spec = codec->spec;
10422 unsigned int mute;
10423
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010424 if (force || !spec->sense_updated) {
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010425 unsigned int present;
Takashi Iwai834be882006-03-01 14:16:17 +010010426 /* need to execute and sync at first */
10427 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010428 /* check laptop HP jack */
10429 present = snd_hda_codec_read(codec, 0x14, 0,
10430 AC_VERB_GET_PIN_SENSE, 0);
10431 /* need to execute and sync at first */
10432 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10433 /* check docking HP jack */
10434 present |= snd_hda_codec_read(codec, 0x1b, 0,
10435 AC_VERB_GET_PIN_SENSE, 0);
10436 if (present & AC_PINSENSE_PRESENCE)
10437 spec->jack_present = 1;
10438 else
10439 spec->jack_present = 0;
Takashi Iwai834be882006-03-01 14:16:17 +010010440 spec->sense_updated = 1;
10441 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010442 /* unmute internal speaker only if both HPs are unplugged and
10443 * master switch is on
10444 */
10445 if (spec->jack_present)
10446 mute = HDA_AMP_MUTE;
10447 else
Takashi Iwai834be882006-03-01 14:16:17 +010010448 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010449 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10450 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010010451}
10452
10453/* unsolicited event for HP jack sensing */
10454static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
10455 unsigned int res)
10456{
10457 if ((res >> 26) != ALC_HP_EVENT)
10458 return;
10459 alc262_fujitsu_automute(codec, 1);
10460}
10461
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010462static void alc262_fujitsu_init_hook(struct hda_codec *codec)
10463{
10464 alc262_fujitsu_automute(codec, 1);
10465}
10466
Takashi Iwai834be882006-03-01 14:16:17 +010010467/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020010468static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
10469 .ops = &snd_hda_bind_vol,
10470 .values = {
10471 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
10472 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
10473 0
10474 },
10475};
Takashi Iwai834be882006-03-01 14:16:17 +010010476
Jiang zhe0e31daf2008-03-20 12:12:39 +010010477/* mute/unmute internal speaker according to the hp jack and mute state */
10478static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
10479{
10480 struct alc_spec *spec = codec->spec;
10481 unsigned int mute;
10482
10483 if (force || !spec->sense_updated) {
10484 unsigned int present_int_hp;
10485 /* need to execute and sync at first */
10486 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10487 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
10488 AC_VERB_GET_PIN_SENSE, 0);
10489 spec->jack_present = (present_int_hp & 0x80000000) != 0;
10490 spec->sense_updated = 1;
10491 }
10492 if (spec->jack_present) {
10493 /* mute internal speaker */
10494 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10495 HDA_AMP_MUTE, HDA_AMP_MUTE);
10496 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10497 HDA_AMP_MUTE, HDA_AMP_MUTE);
10498 } else {
10499 /* unmute internal speaker if necessary */
10500 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
10501 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10502 HDA_AMP_MUTE, mute);
10503 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10504 HDA_AMP_MUTE, mute);
10505 }
10506}
10507
10508/* unsolicited event for HP jack sensing */
10509static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
10510 unsigned int res)
10511{
10512 if ((res >> 26) != ALC_HP_EVENT)
10513 return;
10514 alc262_lenovo_3000_automute(codec, 1);
10515}
10516
Takashi Iwai8de56b72009-07-24 16:51:47 +020010517static int amp_stereo_mute_update(struct hda_codec *codec, hda_nid_t nid,
10518 int dir, int idx, long *valp)
10519{
10520 int i, change = 0;
10521
10522 for (i = 0; i < 2; i++, valp++)
10523 change |= snd_hda_codec_amp_update(codec, nid, i, dir, idx,
10524 HDA_AMP_MUTE,
10525 *valp ? 0 : HDA_AMP_MUTE);
10526 return change;
10527}
10528
Takashi Iwai834be882006-03-01 14:16:17 +010010529/* bind hp and internal speaker mute (with plug check) */
10530static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
10531 struct snd_ctl_elem_value *ucontrol)
10532{
10533 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10534 long *valp = ucontrol->value.integer.value;
10535 int change;
10536
Takashi Iwai8de56b72009-07-24 16:51:47 +020010537 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
10538 change |= amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Takashi Iwai82beb8f2007-08-10 17:09:26 +020010539 if (change)
10540 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010010541 return change;
10542}
10543
10544static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020010545 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010010546 {
10547 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10548 .name = "Master Playback Switch",
10549 .info = snd_hda_mixer_amp_switch_info,
10550 .get = snd_hda_mixer_amp_switch_get,
10551 .put = alc262_fujitsu_master_sw_put,
10552 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10553 },
10554 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10555 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10556 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10557 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10558 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010559 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10560 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10561 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010010562 { } /* end */
10563};
10564
Jiang zhe0e31daf2008-03-20 12:12:39 +010010565/* bind hp and internal speaker mute (with plug check) */
10566static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
10567 struct snd_ctl_elem_value *ucontrol)
10568{
10569 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10570 long *valp = ucontrol->value.integer.value;
10571 int change;
10572
Takashi Iwai8de56b72009-07-24 16:51:47 +020010573 change = amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Jiang zhe0e31daf2008-03-20 12:12:39 +010010574 if (change)
10575 alc262_lenovo_3000_automute(codec, 0);
10576 return change;
10577}
10578
10579static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
10580 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10581 {
10582 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10583 .name = "Master Playback Switch",
10584 .info = snd_hda_mixer_amp_switch_info,
10585 .get = snd_hda_mixer_amp_switch_get,
10586 .put = alc262_lenovo_3000_master_sw_put,
10587 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
10588 },
10589 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10590 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10591 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10592 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10593 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10594 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10595 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10596 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10597 { } /* end */
10598};
10599
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010600static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
10601 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020010602 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010603 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10604 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10605 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10606 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10607 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10608 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10609 { } /* end */
10610};
10611
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010612/* additional init verbs for Benq laptops */
10613static struct hda_verb alc262_EAPD_verbs[] = {
10614 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10615 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
10616 {}
10617};
10618
Kailang Yang83c34212007-07-05 11:43:05 +020010619static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
10620 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10621 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10622
10623 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10624 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
10625 {}
10626};
10627
Tobin Davisf651b502007-10-26 12:40:47 +020010628/* Samsung Q1 Ultra Vista model setup */
10629static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010630 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10631 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010632 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10633 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10634 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010635 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010636 { } /* end */
10637};
10638
10639static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010640 /* output mixer */
10641 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10642 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10643 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10644 /* speaker */
10645 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10646 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10647 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10648 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10649 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020010650 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010651 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10652 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10653 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10654 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10655 /* internal mic */
10656 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10657 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10658 /* ADC, choose mic */
10659 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10660 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10661 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10662 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10663 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10664 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10665 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10666 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10667 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
10668 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020010669 {}
10670};
10671
Tobin Davisf651b502007-10-26 12:40:47 +020010672/* mute/unmute internal speaker according to the hp jack and mute state */
10673static void alc262_ultra_automute(struct hda_codec *codec)
10674{
10675 struct alc_spec *spec = codec->spec;
10676 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020010677
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010678 mute = 0;
10679 /* auto-mute only when HP is used as HP */
10680 if (!spec->cur_mux[0]) {
10681 unsigned int present;
10682 /* need to execute and sync at first */
10683 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
10684 present = snd_hda_codec_read(codec, 0x15, 0,
10685 AC_VERB_GET_PIN_SENSE, 0);
10686 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
10687 if (spec->jack_present)
10688 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020010689 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010690 /* mute/unmute internal speaker */
10691 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10692 HDA_AMP_MUTE, mute);
10693 /* mute/unmute HP */
10694 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10695 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020010696}
10697
10698/* unsolicited event for HP jack sensing */
10699static void alc262_ultra_unsol_event(struct hda_codec *codec,
10700 unsigned int res)
10701{
10702 if ((res >> 26) != ALC880_HP_EVENT)
10703 return;
10704 alc262_ultra_automute(codec);
10705}
10706
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010707static struct hda_input_mux alc262_ultra_capture_source = {
10708 .num_items = 2,
10709 .items = {
10710 { "Mic", 0x1 },
10711 { "Headphone", 0x7 },
10712 },
10713};
10714
10715static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
10716 struct snd_ctl_elem_value *ucontrol)
10717{
10718 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10719 struct alc_spec *spec = codec->spec;
10720 int ret;
10721
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010722 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010723 if (!ret)
10724 return 0;
10725 /* reprogram the HP pin as mic or HP according to the input source */
10726 snd_hda_codec_write_cache(codec, 0x15, 0,
10727 AC_VERB_SET_PIN_WIDGET_CONTROL,
10728 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
10729 alc262_ultra_automute(codec); /* mute/unmute HP */
10730 return ret;
10731}
10732
10733static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
10734 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10735 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10736 {
10737 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10738 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010739 .info = alc_mux_enum_info,
10740 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010741 .put = alc262_ultra_mux_enum_put,
10742 },
10743 { } /* end */
10744};
10745
Kailang Yangdf694da2005-12-05 19:42:22 +010010746/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010747static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
10748 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010010749{
10750 hda_nid_t nid;
10751 int err;
10752
10753 spec->multiout.num_dacs = 1; /* only use one dac */
10754 spec->multiout.dac_nids = spec->private_dac_nids;
10755 spec->multiout.dac_nids[0] = 2;
10756
10757 nid = cfg->line_out_pins[0];
10758 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010759 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10760 "Front Playback Volume",
10761 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
10762 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010763 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010764 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10765 "Front Playback Switch",
10766 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
10767 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010768 return err;
10769 }
10770
Takashi Iwai82bc9552006-03-21 11:24:42 +010010771 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010772 if (nid) {
10773 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010774 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10775 "Speaker Playback Volume",
10776 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10777 HDA_OUTPUT));
10778 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010779 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010780 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10781 "Speaker Playback Switch",
10782 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10783 HDA_OUTPUT));
10784 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010785 return err;
10786 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010787 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10788 "Speaker Playback Switch",
10789 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10790 HDA_OUTPUT));
10791 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010792 return err;
10793 }
10794 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +020010795 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010796 if (nid) {
10797 /* spec->multiout.hp_nid = 2; */
10798 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010799 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10800 "Headphone Playback Volume",
10801 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10802 HDA_OUTPUT));
10803 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010804 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010805 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10806 "Headphone Playback Switch",
10807 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10808 HDA_OUTPUT));
10809 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010810 return err;
10811 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010812 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10813 "Headphone Playback Switch",
10814 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10815 HDA_OUTPUT));
10816 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010817 return err;
10818 }
10819 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010820 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010010821}
10822
Takashi Iwai8c927b42009-06-22 10:56:54 +020010823static int alc262_auto_create_analog_input_ctls(struct alc_spec *spec,
10824 const struct auto_pin_cfg *cfg)
10825{
10826 int err;
10827
10828 err = alc880_auto_create_analog_input_ctls(spec, cfg);
10829 if (err < 0)
10830 return err;
10831 /* digital-mic input pin is excluded in alc880_auto_create..()
10832 * because it's under 0x18
10833 */
10834 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
10835 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
10836 struct hda_input_mux *imux = &spec->private_imux[0];
10837 imux->items[imux->num_items].label = "Int Mic";
10838 imux->items[imux->num_items].index = 0x09;
10839 imux->num_items++;
10840 }
10841 return 0;
10842}
10843
Kailang Yangdf694da2005-12-05 19:42:22 +010010844
10845/*
10846 * generic initialization of ADC, input mixers and output mixers
10847 */
10848static struct hda_verb alc262_volume_init_verbs[] = {
10849 /*
10850 * Unmute ADC0-2 and set the default input to mic-in
10851 */
10852 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10853 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10854 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10855 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10856 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10857 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10858
Takashi Iwaicb53c622007-08-10 17:21:45 +020010859 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010860 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010861 * Note: PASD motherboards uses the Line In 2 as the input for
10862 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010863 */
10864 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010865 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10866 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10867 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10868 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10869 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010870
10871 /*
10872 * Set up output mixers (0x0c - 0x0f)
10873 */
10874 /* set vol=0 to output mixers */
10875 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10876 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10877 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020010878
Kailang Yangdf694da2005-12-05 19:42:22 +010010879 /* set up input amps for analog loopback */
10880 /* Amp Indices: DAC = 0, mixer = 1 */
10881 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10882 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10883 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10884 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10885 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10886 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10887
10888 /* FIXME: use matrix-type input source selection */
10889 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10890 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10891 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10892 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10893 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10894 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10895 /* Input mixer2 */
10896 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10897 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10898 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10899 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10900 /* Input mixer3 */
10901 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10902 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10903 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10904 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10905
10906 { }
10907};
10908
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010909static struct hda_verb alc262_HP_BPC_init_verbs[] = {
10910 /*
10911 * Unmute ADC0-2 and set the default input to mic-in
10912 */
10913 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10914 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10915 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10916 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10917 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10918 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10919
Takashi Iwaicb53c622007-08-10 17:21:45 +020010920 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010921 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010922 * Note: PASD motherboards uses the Line In 2 as the input for
10923 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010924 */
10925 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010926 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10927 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10928 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10929 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10930 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10931 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10932 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020010933
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010934 /*
10935 * Set up output mixers (0x0c - 0x0e)
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},
10941
10942 /* 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
Takashi Iwaice875f02008-01-28 18:17:43 +010010951 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010952 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10953 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10954
10955 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10956 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10957
10958 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10959 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10960
10961 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10962 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10963 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10964 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10965 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10966
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020010967 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010968 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10969 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020010970 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010971 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10972 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10973
10974
10975 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020010976 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
10977 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010978 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020010979 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
10980 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10981 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10982 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10983 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
10984 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
10985 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
10986 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010987 /* Input mixer2 */
10988 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020010989 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
10990 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10991 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10992 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10993 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
10994 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
10995 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
10996 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010997 /* Input mixer3 */
10998 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020010999 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11000 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11001 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11002 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11003 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11004 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11005 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11006 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011007
Takashi Iwaice875f02008-01-28 18:17:43 +010011008 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11009
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011010 { }
11011};
11012
Kailang Yangcd7509a2007-01-26 18:33:17 +010011013static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
11014 /*
11015 * Unmute ADC0-2 and set the default input to mic-in
11016 */
11017 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11018 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11019 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11020 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11021 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11022 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11023
Takashi Iwaicb53c622007-08-10 17:21:45 +020011024 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010011025 * mixer widget
11026 * Note: PASD motherboards uses the Line In 2 as the input for front
11027 * panel mic (mic 2)
11028 */
11029 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011030 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11031 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11032 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11033 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11034 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11035 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11036 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11037 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010011038 /*
11039 * Set up output mixers (0x0c - 0x0e)
11040 */
11041 /* set vol=0 to output mixers */
11042 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11043 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11044 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11045
11046 /* set up input amps for analog loopback */
11047 /* Amp Indices: DAC = 0, mixer = 1 */
11048 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11049 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11050 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11051 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11052 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11053 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11054
11055
11056 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
11057 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
11058 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
11059 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
11060 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11061 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
11062 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
11063
11064 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11065 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11066
11067 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11068 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11069
11070 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
11071 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11072 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11073 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
11074 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11075 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11076
11077 /* FIXME: use matrix-type input source selection */
11078 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11079 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11080 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
11081 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
11082 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
11083 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
11084 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
11085 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11086 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
11087 /* Input mixer2 */
11088 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11089 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11090 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11091 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11092 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11093 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11094 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11095 /* Input mixer3 */
11096 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11097 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11098 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11099 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11100 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11101 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11102 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11103
Takashi Iwaice875f02008-01-28 18:17:43 +010011104 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11105
Kailang Yangcd7509a2007-01-26 18:33:17 +010011106 { }
11107};
11108
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011109static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
11110
11111 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
11112 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11113 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
11114
11115 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
11116 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11117 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11118 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11119
11120 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
11121 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11122 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11123 {}
11124};
11125
11126
Takashi Iwaicb53c622007-08-10 17:21:45 +020011127#ifdef CONFIG_SND_HDA_POWER_SAVE
11128#define alc262_loopbacks alc880_loopbacks
11129#endif
11130
Sasha Alexandrdef319f2009-06-16 16:00:15 -040011131/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011132#define alc262_pcm_analog_playback alc880_pcm_analog_playback
11133#define alc262_pcm_analog_capture alc880_pcm_analog_capture
11134#define alc262_pcm_digital_playback alc880_pcm_digital_playback
11135#define alc262_pcm_digital_capture alc880_pcm_digital_capture
11136
11137/*
11138 * BIOS auto configuration
11139 */
11140static int alc262_parse_auto_config(struct hda_codec *codec)
11141{
11142 struct alc_spec *spec = codec->spec;
11143 int err;
11144 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
11145
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011146 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11147 alc262_ignore);
11148 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011149 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011150 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011151 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011152 spec->multiout.max_channels = 2;
11153 spec->no_analog = 1;
11154 goto dig_only;
11155 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011156 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011157 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011158 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
11159 if (err < 0)
11160 return err;
11161 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
11162 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011163 return err;
11164
11165 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11166
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011167 dig_only:
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011168 if (spec->autocfg.dig_outs) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011169 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011170 spec->dig_out_type = spec->autocfg.dig_out_type[0];
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011171 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011172 if (spec->autocfg.dig_in_pin)
11173 spec->dig_in_nid = ALC262_DIGIN_NID;
11174
Takashi Iwai603c4012008-07-30 15:01:44 +020011175 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011176 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010011177
Takashi Iwaid88897e2008-10-31 15:01:37 +010011178 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020011179 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011180 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010011181
Takashi Iwai776e1842007-08-29 15:07:11 +020011182 err = alc_auto_add_mic_boost(codec);
11183 if (err < 0)
11184 return err;
11185
Takashi Iwai4a79ba32009-04-22 16:31:35 +020011186 alc_ssid_check(codec, 0x15, 0x14, 0x1b);
11187
Kailang Yangdf694da2005-12-05 19:42:22 +010011188 return 1;
11189}
11190
11191#define alc262_auto_init_multi_out alc882_auto_init_multi_out
11192#define alc262_auto_init_hp_out alc882_auto_init_hp_out
11193#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020011194#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010011195
11196
11197/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011198static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010011199{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011200 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010011201 alc262_auto_init_multi_out(codec);
11202 alc262_auto_init_hp_out(codec);
11203 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020011204 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011205 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020011206 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010011207}
11208
11209/*
11210 * configuration and preset
11211 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011212static const char *alc262_models[ALC262_MODEL_LAST] = {
11213 [ALC262_BASIC] = "basic",
11214 [ALC262_HIPPO] = "hippo",
11215 [ALC262_HIPPO_1] = "hippo_1",
11216 [ALC262_FUJITSU] = "fujitsu",
11217 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010011218 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010011219 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010011220 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011221 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020011222 [ALC262_BENQ_T31] = "benq-t31",
11223 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020011224 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011225 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020011226 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010011227 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011228 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000011229 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011230 [ALC262_AUTO] = "auto",
11231};
11232
11233static struct snd_pci_quirk alc262_cfg_tbl[] = {
11234 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011235 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011236 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
11237 ALC262_HP_BPC),
11238 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
11239 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010011240 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
11241 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011242 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011243 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011244 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011245 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011246 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011247 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011248 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011249 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011250 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
11251 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
11252 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011253 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
11254 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010011255 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011256 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011257 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011258 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010011259 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020011260 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Takashi Iwaif872a912009-02-26 00:57:01 +010011261 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
11262 ALC262_SONY_ASSAMD),
Akio Idehara36ca6e12008-06-09 22:57:40 +090011263 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011264 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020011265 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011266 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010011267 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000011268 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011269 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
11270 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110011271 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010011272 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011273 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020011274 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011275 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010011276 {}
11277};
11278
11279static struct alc_config_preset alc262_presets[] = {
11280 [ALC262_BASIC] = {
11281 .mixers = { alc262_base_mixer },
11282 .init_verbs = { alc262_init_verbs },
11283 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11284 .dac_nids = alc262_dac_nids,
11285 .hp_nid = 0x03,
11286 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11287 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010011288 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010011289 },
Kailang Yangccc656c2006-10-17 12:32:26 +020011290 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011291 .mixers = { alc262_hippo_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020011292 .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020011293 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11294 .dac_nids = alc262_dac_nids,
11295 .hp_nid = 0x03,
11296 .dig_out_nid = ALC262_DIGOUT_NID,
11297 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11298 .channel_mode = alc262_modes,
11299 .input_mux = &alc262_capture_source,
11300 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011301 .setup = alc262_hippo_setup,
11302 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020011303 },
11304 [ALC262_HIPPO_1] = {
11305 .mixers = { alc262_hippo1_mixer },
11306 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
11307 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11308 .dac_nids = alc262_dac_nids,
11309 .hp_nid = 0x02,
11310 .dig_out_nid = ALC262_DIGOUT_NID,
11311 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11312 .channel_mode = alc262_modes,
11313 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020011314 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011315 .setup = alc262_hippo1_setup,
11316 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020011317 },
Takashi Iwai834be882006-03-01 14:16:17 +010011318 [ALC262_FUJITSU] = {
11319 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011320 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11321 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010011322 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11323 .dac_nids = alc262_dac_nids,
11324 .hp_nid = 0x03,
11325 .dig_out_nid = ALC262_DIGOUT_NID,
11326 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11327 .channel_mode = alc262_modes,
11328 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011329 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011330 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010011331 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011332 [ALC262_HP_BPC] = {
11333 .mixers = { alc262_HP_BPC_mixer },
11334 .init_verbs = { alc262_HP_BPC_init_verbs },
11335 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11336 .dac_nids = alc262_dac_nids,
11337 .hp_nid = 0x03,
11338 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11339 .channel_mode = alc262_modes,
11340 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011341 .unsol_event = alc262_hp_bpc_unsol_event,
11342 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011343 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011344 [ALC262_HP_BPC_D7000_WF] = {
11345 .mixers = { alc262_HP_BPC_WildWest_mixer },
11346 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11347 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11348 .dac_nids = alc262_dac_nids,
11349 .hp_nid = 0x03,
11350 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11351 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011352 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011353 .unsol_event = alc262_hp_wildwest_unsol_event,
11354 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011355 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011356 [ALC262_HP_BPC_D7000_WL] = {
11357 .mixers = { alc262_HP_BPC_WildWest_mixer,
11358 alc262_HP_BPC_WildWest_option_mixer },
11359 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11360 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11361 .dac_nids = alc262_dac_nids,
11362 .hp_nid = 0x03,
11363 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11364 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011365 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011366 .unsol_event = alc262_hp_wildwest_unsol_event,
11367 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011368 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011369 [ALC262_HP_TC_T5735] = {
11370 .mixers = { alc262_hp_t5735_mixer },
11371 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
11372 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11373 .dac_nids = alc262_dac_nids,
11374 .hp_nid = 0x03,
11375 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11376 .channel_mode = alc262_modes,
11377 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011378 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011379 .setup = alc262_hp_t5735_setup,
11380 .init_hook = alc_automute_amp,
Kailang Yang8c427222008-01-10 13:03:59 +010011381 },
11382 [ALC262_HP_RP5700] = {
11383 .mixers = { alc262_hp_rp5700_mixer },
11384 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
11385 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11386 .dac_nids = alc262_dac_nids,
11387 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11388 .channel_mode = alc262_modes,
11389 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011390 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011391 [ALC262_BENQ_ED8] = {
11392 .mixers = { alc262_base_mixer },
11393 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
11394 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11395 .dac_nids = alc262_dac_nids,
11396 .hp_nid = 0x03,
11397 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11398 .channel_mode = alc262_modes,
11399 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011400 },
Kailang Yang272a5272007-05-14 11:00:38 +020011401 [ALC262_SONY_ASSAMD] = {
11402 .mixers = { alc262_sony_mixer },
11403 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
11404 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11405 .dac_nids = alc262_dac_nids,
11406 .hp_nid = 0x02,
11407 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11408 .channel_mode = alc262_modes,
11409 .input_mux = &alc262_capture_source,
11410 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011411 .setup = alc262_hippo_setup,
11412 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020011413 },
11414 [ALC262_BENQ_T31] = {
11415 .mixers = { alc262_benq_t31_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020011416 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
11417 alc_hp15_unsol_verbs },
Kailang Yang83c34212007-07-05 11:43:05 +020011418 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11419 .dac_nids = alc262_dac_nids,
11420 .hp_nid = 0x03,
11421 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11422 .channel_mode = alc262_modes,
11423 .input_mux = &alc262_capture_source,
11424 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011425 .setup = alc262_hippo_setup,
11426 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020011427 },
Tobin Davisf651b502007-10-26 12:40:47 +020011428 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011429 .mixers = { alc262_ultra_mixer },
11430 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011431 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020011432 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11433 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020011434 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11435 .channel_mode = alc262_modes,
11436 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011437 .adc_nids = alc262_adc_nids, /* ADC0 */
11438 .capsrc_nids = alc262_capsrc_nids,
11439 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020011440 .unsol_event = alc262_ultra_unsol_event,
11441 .init_hook = alc262_ultra_automute,
11442 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010011443 [ALC262_LENOVO_3000] = {
11444 .mixers = { alc262_lenovo_3000_mixer },
11445 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11446 alc262_lenovo_3000_unsol_verbs },
11447 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11448 .dac_nids = alc262_dac_nids,
11449 .hp_nid = 0x03,
11450 .dig_out_nid = ALC262_DIGOUT_NID,
11451 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11452 .channel_mode = alc262_modes,
11453 .input_mux = &alc262_fujitsu_capture_source,
11454 .unsol_event = alc262_lenovo_3000_unsol_event,
11455 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011456 [ALC262_NEC] = {
11457 .mixers = { alc262_nec_mixer },
11458 .init_verbs = { alc262_nec_verbs },
11459 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11460 .dac_nids = alc262_dac_nids,
11461 .hp_nid = 0x03,
11462 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11463 .channel_mode = alc262_modes,
11464 .input_mux = &alc262_capture_source,
11465 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020011466 [ALC262_TOSHIBA_S06] = {
11467 .mixers = { alc262_toshiba_s06_mixer },
11468 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
11469 alc262_eapd_verbs },
11470 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11471 .capsrc_nids = alc262_dmic_capsrc_nids,
11472 .dac_nids = alc262_dac_nids,
11473 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020011474 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020011475 .dig_out_nid = ALC262_DIGOUT_NID,
11476 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11477 .channel_mode = alc262_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011478 .unsol_event = alc_sku_unsol_event,
11479 .setup = alc262_toshiba_s06_setup,
11480 .init_hook = alc_inithook,
Kailang Yang4e555fe2008-08-26 13:05:55 +020011481 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011482 [ALC262_TOSHIBA_RX1] = {
11483 .mixers = { alc262_toshiba_rx1_mixer },
11484 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
11485 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11486 .dac_nids = alc262_dac_nids,
11487 .hp_nid = 0x03,
11488 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11489 .channel_mode = alc262_modes,
11490 .input_mux = &alc262_capture_source,
11491 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011492 .setup = alc262_hippo_setup,
11493 .init_hook = alc262_hippo_automute,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011494 },
Tony Vroonba340e82009-02-02 19:01:30 +000011495 [ALC262_TYAN] = {
11496 .mixers = { alc262_tyan_mixer },
11497 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
11498 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11499 .dac_nids = alc262_dac_nids,
11500 .hp_nid = 0x02,
11501 .dig_out_nid = ALC262_DIGOUT_NID,
11502 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11503 .channel_mode = alc262_modes,
11504 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011505 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011506 .setup = alc262_tyan_setup,
11507 .init_hook = alc_automute_amp,
Tony Vroonba340e82009-02-02 19:01:30 +000011508 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011509};
11510
11511static int patch_alc262(struct hda_codec *codec)
11512{
11513 struct alc_spec *spec;
11514 int board_config;
11515 int err;
11516
Robert P. J. Daydc041e02006-12-19 14:44:15 +010011517 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010011518 if (spec == NULL)
11519 return -ENOMEM;
11520
11521 codec->spec = spec;
11522#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011523 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
11524 * under-run
11525 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011526 {
11527 int tmp;
11528 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11529 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
11530 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11531 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
11532 }
11533#endif
11534
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020011535 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
11536
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011537 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
11538 alc262_models,
11539 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010011540
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011541 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020011542 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
11543 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010011544 board_config = ALC262_AUTO;
11545 }
11546
11547 if (board_config == ALC262_AUTO) {
11548 /* automatic parse from the BIOS config */
11549 err = alc262_parse_auto_config(codec);
11550 if (err < 0) {
11551 alc_free(codec);
11552 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011553 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011554 printk(KERN_INFO
11555 "hda_codec: Cannot set up configuration "
11556 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011557 board_config = ALC262_BASIC;
11558 }
11559 }
11560
Takashi Iwai07eba612009-02-19 08:06:35 +010011561 if (!spec->no_analog) {
11562 err = snd_hda_attach_beep_device(codec, 0x1);
11563 if (err < 0) {
11564 alc_free(codec);
11565 return err;
11566 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090011567 }
11568
Kailang Yangdf694da2005-12-05 19:42:22 +010011569 if (board_config != ALC262_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020011570 setup_preset(codec, &alc262_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010011571
Kailang Yangdf694da2005-12-05 19:42:22 +010011572 spec->stream_analog_playback = &alc262_pcm_analog_playback;
11573 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020011574
Kailang Yangdf694da2005-12-05 19:42:22 +010011575 spec->stream_digital_playback = &alc262_pcm_digital_playback;
11576 spec->stream_digital_capture = &alc262_pcm_digital_capture;
11577
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011578 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai8c927b42009-06-22 10:56:54 +020011579 int i;
11580 /* check whether the digital-mic has to be supported */
11581 for (i = 0; i < spec->input_mux->num_items; i++) {
11582 if (spec->input_mux->items[i].index >= 9)
11583 break;
11584 }
11585 if (i < spec->input_mux->num_items) {
11586 /* use only ADC0 */
11587 spec->adc_nids = alc262_dmic_adc_nids;
11588 spec->num_adc_nids = 1;
11589 spec->capsrc_nids = alc262_dmic_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010011590 } else {
Takashi Iwai8c927b42009-06-22 10:56:54 +020011591 /* all analog inputs */
11592 /* check whether NID 0x07 is valid */
11593 unsigned int wcap = get_wcaps(codec, 0x07);
11594
11595 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020011596 wcap = get_wcaps_type(wcap);
Takashi Iwai8c927b42009-06-22 10:56:54 +020011597 if (wcap != AC_WID_AUD_IN) {
11598 spec->adc_nids = alc262_adc_nids_alt;
11599 spec->num_adc_nids =
11600 ARRAY_SIZE(alc262_adc_nids_alt);
11601 spec->capsrc_nids = alc262_capsrc_nids_alt;
11602 } else {
11603 spec->adc_nids = alc262_adc_nids;
11604 spec->num_adc_nids =
11605 ARRAY_SIZE(alc262_adc_nids);
11606 spec->capsrc_nids = alc262_capsrc_nids;
11607 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011608 }
11609 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011610 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020011611 set_capture_mixer(codec);
Takashi Iwai07eba612009-02-19 08:06:35 +010011612 if (!spec->no_analog)
11613 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010011614
Takashi Iwai2134ea42008-01-10 16:53:55 +010011615 spec->vmaster_nid = 0x0c;
11616
Kailang Yangdf694da2005-12-05 19:42:22 +010011617 codec->patch_ops = alc_patch_ops;
11618 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011619 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011620#ifdef CONFIG_SND_HDA_POWER_SAVE
11621 if (!spec->loopback.amplist)
11622 spec->loopback.amplist = alc262_loopbacks;
11623#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010011624 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020011625
Kailang Yangdf694da2005-12-05 19:42:22 +010011626 return 0;
11627}
11628
Kailang Yangdf694da2005-12-05 19:42:22 +010011629/*
Kailang Yanga361d842007-06-05 12:30:55 +020011630 * ALC268 channel source setting (2 channel)
11631 */
11632#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
11633#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020011634
Kailang Yanga361d842007-06-05 12:30:55 +020011635static hda_nid_t alc268_dac_nids[2] = {
11636 /* front, hp */
11637 0x02, 0x03
11638};
11639
11640static hda_nid_t alc268_adc_nids[2] = {
11641 /* ADC0-1 */
11642 0x08, 0x07
11643};
11644
11645static hda_nid_t alc268_adc_nids_alt[1] = {
11646 /* ADC0 */
11647 0x08
11648};
11649
Takashi Iwaie1406342008-02-11 18:32:32 +010011650static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
11651
Kailang Yanga361d842007-06-05 12:30:55 +020011652static struct snd_kcontrol_new alc268_base_mixer[] = {
11653 /* output mixer control */
11654 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11655 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11656 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11657 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011658 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11659 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11660 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020011661 { }
11662};
11663
Takashi Iwai42171c12009-05-08 14:11:43 +020011664static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
11665 /* output mixer control */
11666 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11667 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11668 ALC262_HIPPO_MASTER_SWITCH,
11669 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11670 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11671 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11672 { }
11673};
11674
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011675/* bind Beep switches of both NID 0x0f and 0x10 */
11676static struct hda_bind_ctls alc268_bind_beep_sw = {
11677 .ops = &snd_hda_bind_sw,
11678 .values = {
11679 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
11680 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
11681 0
11682 },
11683};
11684
11685static struct snd_kcontrol_new alc268_beep_mixer[] = {
11686 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
11687 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
11688 { }
11689};
11690
Kailang Yangd1a991a2007-08-15 16:21:59 +020011691static struct hda_verb alc268_eapd_verbs[] = {
11692 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11693 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11694 { }
11695};
11696
Takashi Iwaid2738092007-08-16 14:59:45 +020011697/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020011698static struct hda_verb alc268_toshiba_verbs[] = {
11699 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11700 { } /* end */
11701};
11702
11703/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020011704/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020011705static struct hda_bind_ctls alc268_acer_bind_master_vol = {
11706 .ops = &snd_hda_bind_vol,
11707 .values = {
11708 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
11709 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
11710 0
11711 },
11712};
11713
Takashi Iwai889c4392007-08-23 18:56:52 +020011714/* mute/unmute internal speaker according to the hp jack and mute state */
11715static void alc268_acer_automute(struct hda_codec *codec, int force)
11716{
11717 struct alc_spec *spec = codec->spec;
11718 unsigned int mute;
11719
11720 if (force || !spec->sense_updated) {
11721 unsigned int present;
11722 present = snd_hda_codec_read(codec, 0x14, 0,
11723 AC_VERB_GET_PIN_SENSE, 0);
11724 spec->jack_present = (present & 0x80000000) != 0;
11725 spec->sense_updated = 1;
11726 }
11727 if (spec->jack_present)
11728 mute = HDA_AMP_MUTE; /* mute internal speaker */
11729 else /* unmute internal speaker if necessary */
11730 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
11731 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11732 HDA_AMP_MUTE, mute);
11733}
11734
11735
11736/* bind hp and internal speaker mute (with plug check) */
11737static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
11738 struct snd_ctl_elem_value *ucontrol)
11739{
11740 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11741 long *valp = ucontrol->value.integer.value;
11742 int change;
11743
Takashi Iwai8de56b72009-07-24 16:51:47 +020011744 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
Takashi Iwai889c4392007-08-23 18:56:52 +020011745 if (change)
11746 alc268_acer_automute(codec, 0);
11747 return change;
11748}
Takashi Iwaid2738092007-08-16 14:59:45 +020011749
Kailang Yang8ef355d2008-08-26 13:10:22 +020011750static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
11751 /* output mixer control */
11752 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11753 {
11754 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11755 .name = "Master Playback Switch",
11756 .info = snd_hda_mixer_amp_switch_info,
11757 .get = snd_hda_mixer_amp_switch_get,
11758 .put = alc268_acer_master_sw_put,
11759 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11760 },
11761 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
11762 { }
11763};
11764
Takashi Iwaid2738092007-08-16 14:59:45 +020011765static struct snd_kcontrol_new alc268_acer_mixer[] = {
11766 /* output mixer control */
11767 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11768 {
11769 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11770 .name = "Master Playback Switch",
11771 .info = snd_hda_mixer_amp_switch_info,
11772 .get = snd_hda_mixer_amp_switch_get,
11773 .put = alc268_acer_master_sw_put,
11774 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11775 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011776 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11777 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11778 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020011779 { }
11780};
11781
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011782static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
11783 /* output mixer control */
11784 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11785 {
11786 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11787 .name = "Master Playback Switch",
11788 .info = snd_hda_mixer_amp_switch_info,
11789 .get = snd_hda_mixer_amp_switch_get,
11790 .put = alc268_acer_master_sw_put,
11791 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11792 },
11793 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11794 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11795 { }
11796};
11797
Kailang Yang8ef355d2008-08-26 13:10:22 +020011798static struct hda_verb alc268_acer_aspire_one_verbs[] = {
11799 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11800 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11801 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11802 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11803 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
11804 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
11805 { }
11806};
11807
Takashi Iwaid2738092007-08-16 14:59:45 +020011808static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011809 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
11810 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020011811 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11812 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011813 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11814 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020011815 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11816 { }
11817};
11818
11819/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020011820#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011821#define alc268_toshiba_setup alc262_hippo_setup
11822#define alc268_toshiba_automute alc262_hippo_automute
Takashi Iwaid2738092007-08-16 14:59:45 +020011823
11824static void alc268_acer_unsol_event(struct hda_codec *codec,
11825 unsigned int res)
11826{
Takashi Iwai889c4392007-08-23 18:56:52 +020011827 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020011828 return;
11829 alc268_acer_automute(codec, 1);
11830}
11831
Takashi Iwai889c4392007-08-23 18:56:52 +020011832static void alc268_acer_init_hook(struct hda_codec *codec)
11833{
11834 alc268_acer_automute(codec, 1);
11835}
11836
Kailang Yang8ef355d2008-08-26 13:10:22 +020011837/* toggle speaker-output according to the hp-jack state */
11838static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
11839{
11840 unsigned int present;
11841 unsigned char bits;
11842
11843 present = snd_hda_codec_read(codec, 0x15, 0,
11844 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11845 bits = present ? AMP_IN_MUTE(0) : 0;
11846 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
11847 AMP_IN_MUTE(0), bits);
11848 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
11849 AMP_IN_MUTE(0), bits);
11850}
11851
Kailang Yang8ef355d2008-08-26 13:10:22 +020011852static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
11853 unsigned int res)
11854{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011855 switch (res >> 26) {
11856 case ALC880_HP_EVENT:
Kailang Yang8ef355d2008-08-26 13:10:22 +020011857 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011858 break;
11859 case ALC880_MIC_EVENT:
11860 alc_mic_automute(codec);
11861 break;
11862 }
11863}
11864
11865static void alc268_acer_lc_setup(struct hda_codec *codec)
11866{
11867 struct alc_spec *spec = codec->spec;
11868 spec->ext_mic.pin = 0x18;
11869 spec->ext_mic.mux_idx = 0;
11870 spec->int_mic.pin = 0x12;
11871 spec->int_mic.mux_idx = 6;
11872 spec->auto_mic = 1;
Kailang Yang8ef355d2008-08-26 13:10:22 +020011873}
11874
11875static void alc268_acer_lc_init_hook(struct hda_codec *codec)
11876{
11877 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011878 alc_mic_automute(codec);
Kailang Yang8ef355d2008-08-26 13:10:22 +020011879}
11880
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011881static struct snd_kcontrol_new alc268_dell_mixer[] = {
11882 /* output mixer control */
11883 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11884 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11885 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11886 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11887 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11888 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11889 { }
11890};
11891
11892static struct hda_verb alc268_dell_verbs[] = {
11893 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11894 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11895 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011896 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011897 { }
11898};
11899
11900/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011901static void alc268_dell_setup(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011902{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011903 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011904
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011905 spec->autocfg.hp_pins[0] = 0x15;
11906 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011907 spec->ext_mic.pin = 0x18;
11908 spec->ext_mic.mux_idx = 0;
11909 spec->int_mic.pin = 0x19;
11910 spec->int_mic.mux_idx = 1;
11911 spec->auto_mic = 1;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011912}
11913
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011914static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
11915 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11916 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11917 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11918 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11919 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11920 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
11921 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
11922 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11923 { }
11924};
11925
11926static struct hda_verb alc267_quanta_il1_verbs[] = {
11927 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11928 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
11929 { }
11930};
11931
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011932static void alc267_quanta_il1_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011933{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011934 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011935 spec->autocfg.hp_pins[0] = 0x15;
11936 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011937 spec->ext_mic.pin = 0x18;
11938 spec->ext_mic.mux_idx = 0;
11939 spec->int_mic.pin = 0x19;
11940 spec->int_mic.mux_idx = 1;
11941 spec->auto_mic = 1;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011942}
11943
Kailang Yanga361d842007-06-05 12:30:55 +020011944/*
11945 * generic initialization of ADC, input mixers and output mixers
11946 */
11947static struct hda_verb alc268_base_init_verbs[] = {
11948 /* Unmute DAC0-1 and set vol = 0 */
11949 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011950 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011951
11952 /*
11953 * Set up output mixers (0x0c - 0x0e)
11954 */
11955 /* set vol=0 to output mixers */
11956 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020011957 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
11958
11959 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11960 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11961
11962 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11963 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11964 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11965 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11966 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11967 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11968 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11969 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11970
11971 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11972 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11973 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11974 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011975 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011976
11977 /* set PCBEEP vol = 0, mute connections */
11978 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11979 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11980 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020011981
Jiang Zhea9b3aa82007-12-20 13:13:13 +010011982 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020011983
Jiang Zhea9b3aa82007-12-20 13:13:13 +010011984 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
11985 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11986 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
11987 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011988
Kailang Yanga361d842007-06-05 12:30:55 +020011989 { }
11990};
11991
11992/*
11993 * generic initialization of ADC, input mixers and output mixers
11994 */
11995static struct hda_verb alc268_volume_init_verbs[] = {
11996 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010011997 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11998 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011999
12000 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12001 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12002 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12003 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12004 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12005
Kailang Yanga361d842007-06-05 12:30:55 +020012006 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012007 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12008 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12009
12010 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012011 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012012
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012013 /* set PCBEEP vol = 0, mute connections */
12014 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12015 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12016 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012017
12018 { }
12019};
12020
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012021static struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = {
12022 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12023 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12024 { } /* end */
12025};
12026
Kailang Yanga361d842007-06-05 12:30:55 +020012027static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
12028 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12029 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012030 _DEFINE_CAPSRC(1),
Kailang Yanga361d842007-06-05 12:30:55 +020012031 { } /* end */
12032};
12033
12034static struct snd_kcontrol_new alc268_capture_mixer[] = {
12035 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12036 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12037 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
12038 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012039 _DEFINE_CAPSRC(2),
Kailang Yanga361d842007-06-05 12:30:55 +020012040 { } /* end */
12041};
12042
12043static struct hda_input_mux alc268_capture_source = {
12044 .num_items = 4,
12045 .items = {
12046 { "Mic", 0x0 },
12047 { "Front Mic", 0x1 },
12048 { "Line", 0x2 },
12049 { "CD", 0x3 },
12050 },
12051};
12052
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012053static struct hda_input_mux alc268_acer_capture_source = {
12054 .num_items = 3,
12055 .items = {
12056 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012057 { "Internal Mic", 0x1 },
12058 { "Line", 0x2 },
12059 },
12060};
12061
12062static struct hda_input_mux alc268_acer_dmic_capture_source = {
12063 .num_items = 3,
12064 .items = {
12065 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012066 { "Internal Mic", 0x6 },
12067 { "Line", 0x2 },
12068 },
12069};
12070
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012071#ifdef CONFIG_SND_DEBUG
12072static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012073 /* Volume widgets */
12074 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12075 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12076 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
12077 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
12078 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
12079 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
12080 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
12081 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
12082 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
12083 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
12084 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
12085 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
12086 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010012087 /* The below appears problematic on some hardwares */
12088 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012089 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12090 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
12091 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
12092 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
12093
12094 /* Modes for retasking pin widgets */
12095 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
12096 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
12097 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
12098 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
12099
12100 /* Controls for GPIO pins, assuming they are configured as outputs */
12101 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
12102 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
12103 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
12104 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
12105
12106 /* Switches to allow the digital SPDIF output pin to be enabled.
12107 * The ALC268 does not have an SPDIF input.
12108 */
12109 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
12110
12111 /* A switch allowing EAPD to be enabled. Some laptops seem to use
12112 * this output to turn on an external amplifier.
12113 */
12114 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
12115 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
12116
12117 { } /* end */
12118};
12119#endif
12120
Kailang Yanga361d842007-06-05 12:30:55 +020012121/* create input playback/capture controls for the given pin */
12122static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
12123 const char *ctlname, int idx)
12124{
12125 char name[32];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012126 hda_nid_t dac;
Kailang Yanga361d842007-06-05 12:30:55 +020012127 int err;
12128
12129 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012130 switch (nid) {
12131 case 0x14:
12132 case 0x16:
12133 dac = 0x02;
12134 break;
12135 case 0x15:
12136 dac = 0x03;
12137 break;
12138 default:
12139 return 0;
12140 }
12141 if (spec->multiout.dac_nids[0] != dac &&
12142 spec->multiout.dac_nids[1] != dac) {
Kailang Yanga361d842007-06-05 12:30:55 +020012143 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012144 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
Kailang Yanga361d842007-06-05 12:30:55 +020012145 HDA_OUTPUT));
12146 if (err < 0)
12147 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012148 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
12149 }
12150
Kailang Yanga361d842007-06-05 12:30:55 +020012151 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012152 if (nid != 0x16)
12153 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
Kailang Yanga361d842007-06-05 12:30:55 +020012154 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012155 else /* mono */
12156 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
12157 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020012158 if (err < 0)
12159 return err;
12160 return 0;
12161}
12162
12163/* add playback controls from the parsed DAC table */
12164static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
12165 const struct auto_pin_cfg *cfg)
12166{
12167 hda_nid_t nid;
12168 int err;
12169
Kailang Yanga361d842007-06-05 12:30:55 +020012170 spec->multiout.dac_nids = spec->private_dac_nids;
Kailang Yanga361d842007-06-05 12:30:55 +020012171
12172 nid = cfg->line_out_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012173 if (nid) {
12174 const char *name;
12175 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
12176 name = "Speaker";
12177 else
12178 name = "Front";
12179 err = alc268_new_analog_output(spec, nid, name, 0);
12180 if (err < 0)
12181 return err;
12182 }
Kailang Yanga361d842007-06-05 12:30:55 +020012183
12184 nid = cfg->speaker_pins[0];
12185 if (nid == 0x1d) {
12186 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12187 "Speaker Playback Volume",
12188 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
12189 if (err < 0)
12190 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012191 } else {
12192 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
12193 if (err < 0)
12194 return err;
Kailang Yanga361d842007-06-05 12:30:55 +020012195 }
12196 nid = cfg->hp_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012197 if (nid) {
12198 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
12199 if (err < 0)
12200 return err;
12201 }
Kailang Yanga361d842007-06-05 12:30:55 +020012202
12203 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
12204 if (nid == 0x16) {
12205 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12206 "Mono Playback Switch",
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012207 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020012208 if (err < 0)
12209 return err;
12210 }
Kailang Yangea1fb292008-08-26 12:58:38 +020012211 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020012212}
12213
12214/* create playback/capture controls for input pins */
12215static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
12216 const struct auto_pin_cfg *cfg)
12217{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012218 struct hda_input_mux *imux = &spec->private_imux[0];
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030012219 int i, idx1, dmic_nid;
Kailang Yanga361d842007-06-05 12:30:55 +020012220
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030012221 dmic_nid = 0x12;
12222 while (dmic_nid <= 0x13) {
12223 for (i = 0; i < AUTO_PIN_LAST; i++) {
12224 switch (cfg->input_pins[i]) {
12225 case 0x18:
12226 idx1 = 0; /* Mic 1 */
12227 break;
12228 case 0x19:
12229 idx1 = 1; /* Mic 2 */
12230 break;
12231 case 0x1a:
12232 idx1 = 2; /* Line In */
12233 break;
12234 case 0x1c:
12235 idx1 = 3; /* CD */
12236 break;
12237 case 0x12:
12238 case 0x13:
12239 if (cfg->input_pins[i] != dmic_nid)
12240 continue;
12241 idx1 = 6; /* digital mics */
12242 break;
12243 default:
12244 continue;
12245 }
12246 imux->items[imux->num_items].label =
12247 auto_pin_cfg_labels[i];
12248 imux->items[imux->num_items].index = idx1;
12249 imux->num_items++;
Kailang Yanga361d842007-06-05 12:30:55 +020012250 }
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030012251 imux++;
12252 dmic_nid++;
Kailang Yanga361d842007-06-05 12:30:55 +020012253 }
12254 return 0;
12255}
12256
12257static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
12258{
12259 struct alc_spec *spec = codec->spec;
12260 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
12261 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
12262 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
12263 unsigned int dac_vol1, dac_vol2;
12264
12265 if (speaker_nid) {
12266 snd_hda_codec_write(codec, speaker_nid, 0,
12267 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
12268 snd_hda_codec_write(codec, 0x0f, 0,
12269 AC_VERB_SET_AMP_GAIN_MUTE,
12270 AMP_IN_UNMUTE(1));
12271 snd_hda_codec_write(codec, 0x10, 0,
12272 AC_VERB_SET_AMP_GAIN_MUTE,
12273 AMP_IN_UNMUTE(1));
12274 } else {
12275 snd_hda_codec_write(codec, 0x0f, 0,
12276 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12277 snd_hda_codec_write(codec, 0x10, 0,
12278 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12279 }
12280
12281 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020012282 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012283 dac_vol2 = AMP_OUT_ZERO;
12284 else if (line_nid == 0x15)
12285 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020012286 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012287 dac_vol2 = AMP_OUT_ZERO;
12288 else if (hp_nid == 0x15)
12289 dac_vol1 = AMP_OUT_ZERO;
12290 if (line_nid != 0x16 || hp_nid != 0x16 ||
12291 spec->autocfg.line_out_pins[1] != 0x16 ||
12292 spec->autocfg.line_out_pins[2] != 0x16)
12293 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
12294
12295 snd_hda_codec_write(codec, 0x02, 0,
12296 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
12297 snd_hda_codec_write(codec, 0x03, 0,
12298 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
12299}
12300
Sasha Alexandrdef319f2009-06-16 16:00:15 -040012301/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020012302#define alc268_pcm_analog_playback alc880_pcm_analog_playback
12303#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010012304#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020012305#define alc268_pcm_digital_playback alc880_pcm_digital_playback
12306
12307/*
12308 * BIOS auto configuration
12309 */
12310static int alc268_parse_auto_config(struct hda_codec *codec)
12311{
12312 struct alc_spec *spec = codec->spec;
12313 int err;
12314 static hda_nid_t alc268_ignore[] = { 0 };
12315
12316 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12317 alc268_ignore);
12318 if (err < 0)
12319 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012320 if (!spec->autocfg.line_outs) {
12321 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
12322 spec->multiout.max_channels = 2;
12323 spec->no_analog = 1;
12324 goto dig_only;
12325 }
Kailang Yanga361d842007-06-05 12:30:55 +020012326 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012327 }
Kailang Yanga361d842007-06-05 12:30:55 +020012328 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
12329 if (err < 0)
12330 return err;
12331 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
12332 if (err < 0)
12333 return err;
12334
12335 spec->multiout.max_channels = 2;
12336
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012337 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020012338 /* digital only support output */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012339 if (spec->autocfg.dig_outs) {
Kailang Yanga361d842007-06-05 12:30:55 +020012340 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012341 spec->dig_out_type = spec->autocfg.dig_out_type[0];
12342 }
Takashi Iwai603c4012008-07-30 15:01:44 +020012343 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012344 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020012345
Takashi Iwai892981f2009-03-02 08:04:35 +010012346 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012347 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012348
Takashi Iwaid88897e2008-10-31 15:01:37 +010012349 add_verb(spec, alc268_volume_init_verbs);
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030012350 spec->num_mux_defs = 2;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012351 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020012352
Takashi Iwai776e1842007-08-29 15:07:11 +020012353 err = alc_auto_add_mic_boost(codec);
12354 if (err < 0)
12355 return err;
12356
Takashi Iwai1d955eb2009-06-29 11:33:53 +020012357 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
12358
Kailang Yanga361d842007-06-05 12:30:55 +020012359 return 1;
12360}
12361
12362#define alc268_auto_init_multi_out alc882_auto_init_multi_out
12363#define alc268_auto_init_hp_out alc882_auto_init_hp_out
12364#define alc268_auto_init_analog_input alc882_auto_init_analog_input
12365
12366/* init callback for auto-configuration model -- overriding the default init */
12367static void alc268_auto_init(struct hda_codec *codec)
12368{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012369 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020012370 alc268_auto_init_multi_out(codec);
12371 alc268_auto_init_hp_out(codec);
12372 alc268_auto_init_mono_speaker_out(codec);
12373 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012374 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012375 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020012376}
12377
12378/*
12379 * configuration and preset
12380 */
12381static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012382 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020012383 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012384 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020012385 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012386 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020012387 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012388 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012389 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012390#ifdef CONFIG_SND_DEBUG
12391 [ALC268_TEST] = "test",
12392#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012393 [ALC268_AUTO] = "auto",
12394};
12395
12396static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020012397 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012398 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010012399 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012400 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010012401 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020012402 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
12403 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012404 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Takashi Iwai57d13922009-01-08 15:52:09 +010012405 SND_PCI_QUIRK(0x1028, 0x02b0, "Dell Inspiron Mini9", ALC268_DELL),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012406 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
12407 ALC268_TOSHIBA),
Kailang Yanga361d842007-06-05 12:30:55 +020012408 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012409 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
12410 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
12411 ALC268_TOSHIBA),
Tony Vroon378bd6a2008-06-04 12:08:30 +020012412 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020012413 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012414 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012415 SND_PCI_QUIRK(0x1854, 0x1775, "LG R510", ALC268_DELL),
Kailang Yanga361d842007-06-05 12:30:55 +020012416 {}
12417};
12418
12419static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012420 [ALC267_QUANTA_IL1] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012421 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer,
12422 alc268_capture_nosrc_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012423 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12424 alc267_quanta_il1_verbs },
12425 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12426 .dac_nids = alc268_dac_nids,
12427 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12428 .adc_nids = alc268_adc_nids_alt,
12429 .hp_nid = 0x03,
12430 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12431 .channel_mode = alc268_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012432 .unsol_event = alc_sku_unsol_event,
12433 .setup = alc267_quanta_il1_setup,
12434 .init_hook = alc_inithook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012435 },
Kailang Yanga361d842007-06-05 12:30:55 +020012436 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012437 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12438 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020012439 .init_verbs = { alc268_base_init_verbs },
12440 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12441 .dac_nids = alc268_dac_nids,
12442 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12443 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012444 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020012445 .hp_nid = 0x03,
12446 .dig_out_nid = ALC268_DIGOUT_NID,
12447 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12448 .channel_mode = alc268_modes,
12449 .input_mux = &alc268_capture_source,
12450 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012451 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012452 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012453 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012454 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12455 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012456 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12457 .dac_nids = alc268_dac_nids,
12458 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12459 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012460 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012461 .hp_nid = 0x03,
12462 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12463 .channel_mode = alc268_modes,
12464 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012465 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012466 .setup = alc268_toshiba_setup,
12467 .init_hook = alc268_toshiba_automute,
Takashi Iwaid2738092007-08-16 14:59:45 +020012468 },
12469 [ALC268_ACER] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012470 .mixers = { alc268_acer_mixer, alc268_capture_nosrc_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012471 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012472 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12473 alc268_acer_verbs },
12474 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12475 .dac_nids = alc268_dac_nids,
12476 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12477 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012478 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020012479 .hp_nid = 0x02,
12480 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12481 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012482 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012483 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020012484 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012485 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012486 [ALC268_ACER_DMIC] = {
12487 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
12488 alc268_beep_mixer },
12489 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12490 alc268_acer_verbs },
12491 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12492 .dac_nids = alc268_dac_nids,
12493 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12494 .adc_nids = alc268_adc_nids_alt,
12495 .capsrc_nids = alc268_capsrc_nids,
12496 .hp_nid = 0x02,
12497 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12498 .channel_mode = alc268_modes,
12499 .input_mux = &alc268_acer_dmic_capture_source,
12500 .unsol_event = alc268_acer_unsol_event,
12501 .init_hook = alc268_acer_init_hook,
12502 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012503 [ALC268_ACER_ASPIRE_ONE] = {
12504 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010012505 alc268_beep_mixer,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012506 alc268_capture_nosrc_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012507 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12508 alc268_acer_aspire_one_verbs },
12509 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12510 .dac_nids = alc268_dac_nids,
12511 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12512 .adc_nids = alc268_adc_nids_alt,
12513 .capsrc_nids = alc268_capsrc_nids,
12514 .hp_nid = 0x03,
12515 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12516 .channel_mode = alc268_modes,
Kailang Yang8ef355d2008-08-26 13:10:22 +020012517 .unsol_event = alc268_acer_lc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012518 .setup = alc268_acer_lc_setup,
Kailang Yang8ef355d2008-08-26 13:10:22 +020012519 .init_hook = alc268_acer_lc_init_hook,
12520 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012521 [ALC268_DELL] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012522 .mixers = { alc268_dell_mixer, alc268_beep_mixer,
12523 alc268_capture_nosrc_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012524 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12525 alc268_dell_verbs },
12526 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12527 .dac_nids = alc268_dac_nids,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012528 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12529 .adc_nids = alc268_adc_nids_alt,
12530 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012531 .hp_nid = 0x02,
12532 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12533 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012534 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012535 .setup = alc268_dell_setup,
12536 .init_hook = alc_inithook,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012537 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012538 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012539 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12540 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012541 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12542 alc268_toshiba_verbs },
12543 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12544 .dac_nids = alc268_dac_nids,
12545 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12546 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012547 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012548 .hp_nid = 0x03,
12549 .dig_out_nid = ALC268_DIGOUT_NID,
12550 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12551 .channel_mode = alc268_modes,
12552 .input_mux = &alc268_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012553 .setup = alc268_toshiba_setup,
12554 .init_hook = alc268_toshiba_automute,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012555 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012556#ifdef CONFIG_SND_DEBUG
12557 [ALC268_TEST] = {
12558 .mixers = { alc268_test_mixer, alc268_capture_mixer },
12559 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12560 alc268_volume_init_verbs },
12561 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12562 .dac_nids = alc268_dac_nids,
12563 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12564 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012565 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012566 .hp_nid = 0x03,
12567 .dig_out_nid = ALC268_DIGOUT_NID,
12568 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12569 .channel_mode = alc268_modes,
12570 .input_mux = &alc268_capture_source,
12571 },
12572#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012573};
12574
12575static int patch_alc268(struct hda_codec *codec)
12576{
12577 struct alc_spec *spec;
12578 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010012579 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020012580
12581 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
12582 if (spec == NULL)
12583 return -ENOMEM;
12584
12585 codec->spec = spec;
12586
12587 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
12588 alc268_models,
12589 alc268_cfg_tbl);
12590
12591 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020012592 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
12593 codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020012594 board_config = ALC268_AUTO;
12595 }
12596
12597 if (board_config == ALC268_AUTO) {
12598 /* automatic parse from the BIOS config */
12599 err = alc268_parse_auto_config(codec);
12600 if (err < 0) {
12601 alc_free(codec);
12602 return err;
12603 } else if (!err) {
12604 printk(KERN_INFO
12605 "hda_codec: Cannot set up configuration "
12606 "from BIOS. Using base mode...\n");
12607 board_config = ALC268_3ST;
12608 }
12609 }
12610
12611 if (board_config != ALC268_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020012612 setup_preset(codec, &alc268_presets[board_config]);
Kailang Yanga361d842007-06-05 12:30:55 +020012613
Kailang Yanga361d842007-06-05 12:30:55 +020012614 spec->stream_analog_playback = &alc268_pcm_analog_playback;
12615 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010012616 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020012617
Kailang Yanga361d842007-06-05 12:30:55 +020012618 spec->stream_digital_playback = &alc268_pcm_digital_playback;
12619
Takashi Iwai22971e32009-02-10 11:56:44 +010012620 has_beep = 0;
12621 for (i = 0; i < spec->num_mixers; i++) {
12622 if (spec->mixers[i] == alc268_beep_mixer) {
12623 has_beep = 1;
12624 break;
12625 }
12626 }
12627
12628 if (has_beep) {
12629 err = snd_hda_attach_beep_device(codec, 0x1);
12630 if (err < 0) {
12631 alc_free(codec);
12632 return err;
12633 }
12634 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
12635 /* override the amp caps for beep generator */
12636 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012637 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
12638 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
12639 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
12640 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010012641 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012642
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012643 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012644 /* check whether NID 0x07 is valid */
12645 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010012646 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020012647
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012648 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020012649 wcap = get_wcaps_type(wcap);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012650 if (spec->auto_mic ||
12651 wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012652 spec->adc_nids = alc268_adc_nids_alt;
12653 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012654 if (spec->auto_mic || spec->input_mux->num_items == 1)
12655 add_mixer(spec, alc268_capture_nosrc_mixer);
12656 else
12657 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012658 } else {
12659 spec->adc_nids = alc268_adc_nids;
12660 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012661 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020012662 }
Takashi Iwaie1406342008-02-11 18:32:32 +010012663 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai85860c02008-02-19 15:00:15 +010012664 /* set default input source */
12665 for (i = 0; i < spec->num_adc_nids; i++)
12666 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
12667 0, AC_VERB_SET_CONNECT_SEL,
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030012668 i < spec->num_mux_defs ?
12669 spec->input_mux[i].items[0].index :
Takashi Iwai85860c02008-02-19 15:00:15 +010012670 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020012671 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010012672
12673 spec->vmaster_nid = 0x02;
12674
Kailang Yanga361d842007-06-05 12:30:55 +020012675 codec->patch_ops = alc_patch_ops;
12676 if (board_config == ALC268_AUTO)
12677 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020012678
Takashi Iwaidaead532008-11-28 12:55:36 +010012679 codec->proc_widget_hook = print_realtek_coef;
12680
Kailang Yanga361d842007-06-05 12:30:55 +020012681 return 0;
12682}
12683
12684/*
Kailang Yangf6a92242007-12-13 16:52:54 +010012685 * ALC269 channel source setting (2 channel)
12686 */
12687#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
12688
12689#define alc269_dac_nids alc260_dac_nids
12690
12691static hda_nid_t alc269_adc_nids[1] = {
12692 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020012693 0x08,
12694};
12695
Takashi Iwaie01bf502008-08-21 16:25:07 +020012696static hda_nid_t alc269_capsrc_nids[1] = {
12697 0x23,
12698};
12699
12700/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
12701 * not a mux!
12702 */
12703
Kailang Yangf6a92242007-12-13 16:52:54 +010012704#define alc269_modes alc260_modes
12705#define alc269_capture_source alc880_lg_lw_capture_source
12706
12707static struct snd_kcontrol_new alc269_base_mixer[] = {
12708 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12709 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12710 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12711 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12712 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12713 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12714 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12715 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12716 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12717 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12718 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12719 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
12720 { } /* end */
12721};
12722
Kailang Yang60db6b52008-08-26 13:13:00 +020012723static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
12724 /* output mixer control */
12725 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12726 {
12727 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12728 .name = "Master Playback Switch",
12729 .info = snd_hda_mixer_amp_switch_info,
12730 .get = snd_hda_mixer_amp_switch_get,
12731 .put = alc268_acer_master_sw_put,
12732 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12733 },
12734 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12735 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12736 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12737 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12738 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12739 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020012740 { }
12741};
12742
Tony Vroon64154832008-11-06 15:08:49 +000012743static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
12744 /* output mixer control */
12745 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12746 {
12747 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12748 .name = "Master Playback Switch",
12749 .info = snd_hda_mixer_amp_switch_info,
12750 .get = snd_hda_mixer_amp_switch_get,
12751 .put = alc268_acer_master_sw_put,
12752 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12753 },
12754 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12755 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12756 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12757 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12758 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12759 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12760 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
12761 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
12762 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000012763 { }
12764};
12765
Kailang Yangf53281e2008-07-18 12:36:43 +020012766static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
Takashi Iwaiaa202452009-07-03 15:00:54 +020012767 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010012768 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwaiaa202452009-07-03 15:00:54 +020012769 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010012770 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yangf53281e2008-07-18 12:36:43 +020012771 { } /* end */
12772};
12773
Kailang Yangf6a92242007-12-13 16:52:54 +010012774/* capture mixer elements */
Kailang Yangf53281e2008-07-18 12:36:43 +020012775static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
12776 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12777 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012778 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12779 { } /* end */
12780};
12781
12782/* FSC amilo */
Takashi Iwaiaa202452009-07-03 15:00:54 +020012783#define alc269_fujitsu_mixer alc269_eeepc_mixer
Kailang Yangf53281e2008-07-18 12:36:43 +020012784
Kailang Yang60db6b52008-08-26 13:13:00 +020012785static struct hda_verb alc269_quanta_fl1_verbs[] = {
12786 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12787 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12788 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12789 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12790 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12791 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12792 { }
12793};
12794
Tony Vroon64154832008-11-06 15:08:49 +000012795static struct hda_verb alc269_lifebook_verbs[] = {
12796 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12797 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
12798 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12799 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12800 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12801 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12802 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12803 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12804 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12805 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12806 { }
12807};
12808
Kailang Yang60db6b52008-08-26 13:13:00 +020012809/* toggle speaker-output according to the hp-jack state */
12810static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
12811{
12812 unsigned int present;
12813 unsigned char bits;
12814
12815 present = snd_hda_codec_read(codec, 0x15, 0,
12816 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12817 bits = present ? AMP_IN_MUTE(0) : 0;
12818 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12819 AMP_IN_MUTE(0), bits);
12820 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12821 AMP_IN_MUTE(0), bits);
12822
12823 snd_hda_codec_write(codec, 0x20, 0,
12824 AC_VERB_SET_COEF_INDEX, 0x0c);
12825 snd_hda_codec_write(codec, 0x20, 0,
12826 AC_VERB_SET_PROC_COEF, 0x680);
12827
12828 snd_hda_codec_write(codec, 0x20, 0,
12829 AC_VERB_SET_COEF_INDEX, 0x0c);
12830 snd_hda_codec_write(codec, 0x20, 0,
12831 AC_VERB_SET_PROC_COEF, 0x480);
12832}
12833
Tony Vroon64154832008-11-06 15:08:49 +000012834/* toggle speaker-output according to the hp-jacks state */
12835static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
12836{
12837 unsigned int present;
12838 unsigned char bits;
12839
12840 /* Check laptop headphone socket */
12841 present = snd_hda_codec_read(codec, 0x15, 0,
12842 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12843
12844 /* Check port replicator headphone socket */
12845 present |= snd_hda_codec_read(codec, 0x1a, 0,
12846 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12847
12848 bits = present ? AMP_IN_MUTE(0) : 0;
12849 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12850 AMP_IN_MUTE(0), bits);
12851 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12852 AMP_IN_MUTE(0), bits);
12853
12854 snd_hda_codec_write(codec, 0x20, 0,
12855 AC_VERB_SET_COEF_INDEX, 0x0c);
12856 snd_hda_codec_write(codec, 0x20, 0,
12857 AC_VERB_SET_PROC_COEF, 0x680);
12858
12859 snd_hda_codec_write(codec, 0x20, 0,
12860 AC_VERB_SET_COEF_INDEX, 0x0c);
12861 snd_hda_codec_write(codec, 0x20, 0,
12862 AC_VERB_SET_PROC_COEF, 0x480);
12863}
12864
Tony Vroon64154832008-11-06 15:08:49 +000012865static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
12866{
12867 unsigned int present_laptop;
12868 unsigned int present_dock;
12869
12870 present_laptop = snd_hda_codec_read(codec, 0x18, 0,
12871 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12872
12873 present_dock = snd_hda_codec_read(codec, 0x1b, 0,
12874 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12875
12876 /* Laptop mic port overrides dock mic port, design decision */
12877 if (present_dock)
12878 snd_hda_codec_write(codec, 0x23, 0,
12879 AC_VERB_SET_CONNECT_SEL, 0x3);
12880 if (present_laptop)
12881 snd_hda_codec_write(codec, 0x23, 0,
12882 AC_VERB_SET_CONNECT_SEL, 0x0);
12883 if (!present_dock && !present_laptop)
12884 snd_hda_codec_write(codec, 0x23, 0,
12885 AC_VERB_SET_CONNECT_SEL, 0x1);
12886}
12887
Kailang Yang60db6b52008-08-26 13:13:00 +020012888static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
12889 unsigned int res)
12890{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012891 switch (res >> 26) {
12892 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020012893 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012894 break;
12895 case ALC880_MIC_EVENT:
12896 alc_mic_automute(codec);
12897 break;
12898 }
Kailang Yang60db6b52008-08-26 13:13:00 +020012899}
12900
Tony Vroon64154832008-11-06 15:08:49 +000012901static void alc269_lifebook_unsol_event(struct hda_codec *codec,
12902 unsigned int res)
12903{
12904 if ((res >> 26) == ALC880_HP_EVENT)
12905 alc269_lifebook_speaker_automute(codec);
12906 if ((res >> 26) == ALC880_MIC_EVENT)
12907 alc269_lifebook_mic_autoswitch(codec);
12908}
12909
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012910static void alc269_quanta_fl1_setup(struct hda_codec *codec)
12911{
12912 struct alc_spec *spec = codec->spec;
12913 spec->ext_mic.pin = 0x18;
12914 spec->ext_mic.mux_idx = 0;
12915 spec->int_mic.pin = 0x19;
12916 spec->int_mic.mux_idx = 1;
12917 spec->auto_mic = 1;
12918}
12919
Kailang Yang60db6b52008-08-26 13:13:00 +020012920static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
12921{
12922 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012923 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020012924}
12925
Tony Vroon64154832008-11-06 15:08:49 +000012926static void alc269_lifebook_init_hook(struct hda_codec *codec)
12927{
12928 alc269_lifebook_speaker_automute(codec);
12929 alc269_lifebook_mic_autoswitch(codec);
12930}
12931
Kailang Yang60db6b52008-08-26 13:13:00 +020012932static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
12933 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12934 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
12935 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12936 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
12937 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12938 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12939 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12940 {}
12941};
12942
12943static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
12944 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12945 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
12946 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12947 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
12948 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12949 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12950 {}
12951};
12952
12953/* toggle speaker-output according to the hp-jack state */
12954static void alc269_speaker_automute(struct hda_codec *codec)
12955{
12956 unsigned int present;
12957 unsigned char bits;
12958
12959 present = snd_hda_codec_read(codec, 0x15, 0,
12960 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12961 bits = present ? AMP_IN_MUTE(0) : 0;
12962 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12963 AMP_IN_MUTE(0), bits);
12964 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12965 AMP_IN_MUTE(0), bits);
12966}
12967
Kailang Yang60db6b52008-08-26 13:13:00 +020012968/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012969static void alc269_eeepc_unsol_event(struct hda_codec *codec,
Kailang Yang60db6b52008-08-26 13:13:00 +020012970 unsigned int res)
12971{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012972 switch (res >> 26) {
12973 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020012974 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012975 break;
12976 case ALC880_MIC_EVENT:
12977 alc_mic_automute(codec);
12978 break;
12979 }
Kailang Yang60db6b52008-08-26 13:13:00 +020012980}
12981
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012982static void alc269_eeepc_dmic_setup(struct hda_codec *codec)
12983{
12984 struct alc_spec *spec = codec->spec;
12985 spec->ext_mic.pin = 0x18;
12986 spec->ext_mic.mux_idx = 0;
12987 spec->int_mic.pin = 0x12;
12988 spec->int_mic.mux_idx = 5;
12989 spec->auto_mic = 1;
12990}
12991
12992static void alc269_eeepc_amic_setup(struct hda_codec *codec)
12993{
12994 struct alc_spec *spec = codec->spec;
12995 spec->ext_mic.pin = 0x18;
12996 spec->ext_mic.mux_idx = 0;
12997 spec->int_mic.pin = 0x19;
12998 spec->int_mic.mux_idx = 1;
12999 spec->auto_mic = 1;
13000}
13001
13002static void alc269_eeepc_inithook(struct hda_codec *codec)
Kailang Yang60db6b52008-08-26 13:13:00 +020013003{
13004 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013005 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020013006}
13007
Kailang Yangf6a92242007-12-13 16:52:54 +010013008/*
13009 * generic initialization of ADC, input mixers and output mixers
13010 */
13011static struct hda_verb alc269_init_verbs[] = {
13012 /*
13013 * Unmute ADC0 and set the default input to mic-in
13014 */
Kailang Yang60db6b52008-08-26 13:13:00 +020013015 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010013016
13017 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
13018 * analog-loopback mixer widget
13019 * Note: PASD motherboards uses the Line In 2 as the input for
13020 * front panel mic (mic 2)
13021 */
13022 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
13023 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13024 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13025 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13026 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13027 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
13028
13029 /*
13030 * Set up output mixers (0x0c - 0x0e)
13031 */
13032 /* set vol=0 to output mixers */
13033 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13034 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13035
13036 /* set up input amps for analog loopback */
13037 /* Amp Indices: DAC = 0, mixer = 1 */
13038 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13039 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13040 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13041 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13042 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13043 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13044
13045 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13046 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13047 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13048 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13049 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13050 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13051 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13052
13053 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13054 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13055 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13056 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13057 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13058 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13059 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13060
13061 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
13062 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
13063
13064 /* FIXME: use matrix-type input source selection */
13065 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
13066 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang60db6b52008-08-26 13:13:00 +020013067 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13068 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangf6a92242007-12-13 16:52:54 +010013069 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13070 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13071
13072 /* set EAPD */
13073 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13074 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
13075 { }
13076};
13077
13078/* add playback controls from the parsed DAC table */
13079static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
13080 const struct auto_pin_cfg *cfg)
13081{
13082 hda_nid_t nid;
13083 int err;
13084
13085 spec->multiout.num_dacs = 1; /* only use one dac */
13086 spec->multiout.dac_nids = spec->private_dac_nids;
13087 spec->multiout.dac_nids[0] = 2;
13088
13089 nid = cfg->line_out_pins[0];
13090 if (nid) {
13091 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13092 "Front Playback Volume",
13093 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
13094 if (err < 0)
13095 return err;
13096 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13097 "Front Playback Switch",
13098 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
13099 if (err < 0)
13100 return err;
13101 }
13102
13103 nid = cfg->speaker_pins[0];
13104 if (nid) {
13105 if (!cfg->line_out_pins[0]) {
13106 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13107 "Speaker Playback Volume",
13108 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
13109 HDA_OUTPUT));
13110 if (err < 0)
13111 return err;
13112 }
13113 if (nid == 0x16) {
13114 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13115 "Speaker Playback Switch",
13116 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13117 HDA_OUTPUT));
13118 if (err < 0)
13119 return err;
13120 } else {
13121 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13122 "Speaker Playback Switch",
13123 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13124 HDA_OUTPUT));
13125 if (err < 0)
13126 return err;
13127 }
13128 }
13129 nid = cfg->hp_pins[0];
13130 if (nid) {
13131 /* spec->multiout.hp_nid = 2; */
13132 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
13133 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13134 "Headphone Playback Volume",
13135 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
13136 HDA_OUTPUT));
13137 if (err < 0)
13138 return err;
13139 }
13140 if (nid == 0x16) {
13141 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13142 "Headphone Playback Switch",
13143 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13144 HDA_OUTPUT));
13145 if (err < 0)
13146 return err;
13147 } else {
13148 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13149 "Headphone Playback Switch",
13150 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13151 HDA_OUTPUT));
13152 if (err < 0)
13153 return err;
13154 }
13155 }
13156 return 0;
13157}
13158
Takashi Iwai8c927b42009-06-22 10:56:54 +020013159#define alc269_auto_create_analog_input_ctls \
13160 alc262_auto_create_analog_input_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010013161
13162#ifdef CONFIG_SND_HDA_POWER_SAVE
13163#define alc269_loopbacks alc880_loopbacks
13164#endif
13165
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013166/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010013167#define alc269_pcm_analog_playback alc880_pcm_analog_playback
13168#define alc269_pcm_analog_capture alc880_pcm_analog_capture
13169#define alc269_pcm_digital_playback alc880_pcm_digital_playback
13170#define alc269_pcm_digital_capture alc880_pcm_digital_capture
13171
Takashi Iwaif03d3112009-03-05 14:18:16 +010013172static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
13173 .substreams = 1,
13174 .channels_min = 2,
13175 .channels_max = 8,
13176 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13177 /* NID is set in alc_build_pcms */
13178 .ops = {
13179 .open = alc880_playback_pcm_open,
13180 .prepare = alc880_playback_pcm_prepare,
13181 .cleanup = alc880_playback_pcm_cleanup
13182 },
13183};
13184
13185static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
13186 .substreams = 1,
13187 .channels_min = 2,
13188 .channels_max = 2,
13189 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13190 /* NID is set in alc_build_pcms */
13191};
13192
Kailang Yangf6a92242007-12-13 16:52:54 +010013193/*
13194 * BIOS auto configuration
13195 */
13196static int alc269_parse_auto_config(struct hda_codec *codec)
13197{
13198 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010013199 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010013200 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
13201
13202 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13203 alc269_ignore);
13204 if (err < 0)
13205 return err;
13206
13207 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
13208 if (err < 0)
13209 return err;
13210 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
13211 if (err < 0)
13212 return err;
13213
13214 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13215
Takashi Iwai0852d7a2009-02-11 11:35:15 +010013216 if (spec->autocfg.dig_outs)
Kailang Yangf6a92242007-12-13 16:52:54 +010013217 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
13218
Takashi Iwai603c4012008-07-30 15:01:44 +020013219 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013220 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010013221
Takashi Iwaid88897e2008-10-31 15:01:37 +010013222 add_verb(spec, alc269_init_verbs);
Kailang Yangf6a92242007-12-13 16:52:54 +010013223 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013224 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie01bf502008-08-21 16:25:07 +020013225 /* set default input source */
13226 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
13227 0, AC_VERB_SET_CONNECT_SEL,
13228 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010013229
13230 err = alc_auto_add_mic_boost(codec);
13231 if (err < 0)
13232 return err;
13233
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013234 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020013235 set_capture_mixer(codec);
Kailang Yangf53281e2008-07-18 12:36:43 +020013236
Takashi Iwai1d955eb2009-06-29 11:33:53 +020013237 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
13238
Kailang Yangf6a92242007-12-13 16:52:54 +010013239 return 1;
13240}
13241
13242#define alc269_auto_init_multi_out alc882_auto_init_multi_out
13243#define alc269_auto_init_hp_out alc882_auto_init_hp_out
13244#define alc269_auto_init_analog_input alc882_auto_init_analog_input
13245
13246
13247/* init callback for auto-configuration model -- overriding the default init */
13248static void alc269_auto_init(struct hda_codec *codec)
13249{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013250 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010013251 alc269_auto_init_multi_out(codec);
13252 alc269_auto_init_hp_out(codec);
13253 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013254 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013255 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010013256}
13257
13258/*
13259 * configuration and preset
13260 */
13261static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013262 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020013263 [ALC269_QUANTA_FL1] = "quanta",
13264 [ALC269_ASUS_EEEPC_P703] = "eeepc-p703",
Takashi Iwai26f5df22008-11-03 17:39:46 +010013265 [ALC269_ASUS_EEEPC_P901] = "eeepc-p901",
Tony Vroon64154832008-11-06 15:08:49 +000013266 [ALC269_FUJITSU] = "fujitsu",
13267 [ALC269_LIFEBOOK] = "lifebook"
Kailang Yangf6a92242007-12-13 16:52:54 +010013268};
13269
13270static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013271 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020013272 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
13273 ALC269_ASUS_EEEPC_P703),
Kailang Yang622e84c2009-04-21 07:39:04 +020013274 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_ASUS_EEEPC_P703),
13275 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_ASUS_EEEPC_P703),
13276 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_ASUS_EEEPC_P703),
13277 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_ASUS_EEEPC_P703),
13278 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_ASUS_EEEPC_P703),
13279 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_ASUS_EEEPC_P703),
Kailang Yangf53281e2008-07-18 12:36:43 +020013280 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
13281 ALC269_ASUS_EEEPC_P901),
Kailang Yang60db6b52008-08-26 13:13:00 +020013282 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
13283 ALC269_ASUS_EEEPC_P901),
Kailang Yang622e84c2009-04-21 07:39:04 +020013284 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_ASUS_EEEPC_P901),
Takashi Iwai26f5df22008-11-03 17:39:46 +010013285 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
Tony Vroon64154832008-11-06 15:08:49 +000013286 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yangf6a92242007-12-13 16:52:54 +010013287 {}
13288};
13289
13290static struct alc_config_preset alc269_presets[] = {
13291 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013292 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010013293 .init_verbs = { alc269_init_verbs },
13294 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13295 .dac_nids = alc269_dac_nids,
13296 .hp_nid = 0x03,
13297 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13298 .channel_mode = alc269_modes,
13299 .input_mux = &alc269_capture_source,
13300 },
Kailang Yang60db6b52008-08-26 13:13:00 +020013301 [ALC269_QUANTA_FL1] = {
13302 .mixers = { alc269_quanta_fl1_mixer },
13303 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
13304 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13305 .dac_nids = alc269_dac_nids,
13306 .hp_nid = 0x03,
13307 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13308 .channel_mode = alc269_modes,
13309 .input_mux = &alc269_capture_source,
13310 .unsol_event = alc269_quanta_fl1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013311 .setup = alc269_quanta_fl1_setup,
Kailang Yang60db6b52008-08-26 13:13:00 +020013312 .init_hook = alc269_quanta_fl1_init_hook,
13313 },
Kailang Yangf53281e2008-07-18 12:36:43 +020013314 [ALC269_ASUS_EEEPC_P703] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013315 .mixers = { alc269_eeepc_mixer },
13316 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013317 .init_verbs = { alc269_init_verbs,
13318 alc269_eeepc_amic_init_verbs },
13319 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13320 .dac_nids = alc269_dac_nids,
13321 .hp_nid = 0x03,
13322 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13323 .channel_mode = alc269_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013324 .unsol_event = alc269_eeepc_unsol_event,
13325 .setup = alc269_eeepc_amic_setup,
13326 .init_hook = alc269_eeepc_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020013327 },
13328 [ALC269_ASUS_EEEPC_P901] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013329 .mixers = { alc269_eeepc_mixer },
13330 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013331 .init_verbs = { alc269_init_verbs,
13332 alc269_eeepc_dmic_init_verbs },
13333 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13334 .dac_nids = alc269_dac_nids,
13335 .hp_nid = 0x03,
13336 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13337 .channel_mode = alc269_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013338 .unsol_event = alc269_eeepc_unsol_event,
13339 .setup = alc269_eeepc_dmic_setup,
13340 .init_hook = alc269_eeepc_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020013341 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013342 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013343 .mixers = { alc269_fujitsu_mixer },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013344 .cap_mixer = alc269_epc_capture_mixer,
13345 .init_verbs = { alc269_init_verbs,
13346 alc269_eeepc_dmic_init_verbs },
13347 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13348 .dac_nids = alc269_dac_nids,
13349 .hp_nid = 0x03,
13350 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13351 .channel_mode = alc269_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013352 .unsol_event = alc269_eeepc_unsol_event,
13353 .setup = alc269_eeepc_dmic_setup,
13354 .init_hook = alc269_eeepc_inithook,
Takashi Iwai26f5df22008-11-03 17:39:46 +010013355 },
Tony Vroon64154832008-11-06 15:08:49 +000013356 [ALC269_LIFEBOOK] = {
13357 .mixers = { alc269_lifebook_mixer },
13358 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
13359 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13360 .dac_nids = alc269_dac_nids,
13361 .hp_nid = 0x03,
13362 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13363 .channel_mode = alc269_modes,
13364 .input_mux = &alc269_capture_source,
13365 .unsol_event = alc269_lifebook_unsol_event,
13366 .init_hook = alc269_lifebook_init_hook,
13367 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013368};
13369
13370static int patch_alc269(struct hda_codec *codec)
13371{
13372 struct alc_spec *spec;
13373 int board_config;
13374 int err;
13375
13376 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13377 if (spec == NULL)
13378 return -ENOMEM;
13379
13380 codec->spec = spec;
13381
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020013382 alc_fix_pll_init(codec, 0x20, 0x04, 15);
13383
Kailang Yangf6a92242007-12-13 16:52:54 +010013384 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
13385 alc269_models,
13386 alc269_cfg_tbl);
13387
13388 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020013389 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
13390 codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010013391 board_config = ALC269_AUTO;
13392 }
13393
13394 if (board_config == ALC269_AUTO) {
13395 /* automatic parse from the BIOS config */
13396 err = alc269_parse_auto_config(codec);
13397 if (err < 0) {
13398 alc_free(codec);
13399 return err;
13400 } else if (!err) {
13401 printk(KERN_INFO
13402 "hda_codec: Cannot set up configuration "
13403 "from BIOS. Using base mode...\n");
13404 board_config = ALC269_BASIC;
13405 }
13406 }
13407
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090013408 err = snd_hda_attach_beep_device(codec, 0x1);
13409 if (err < 0) {
13410 alc_free(codec);
13411 return err;
13412 }
13413
Kailang Yangf6a92242007-12-13 16:52:54 +010013414 if (board_config != ALC269_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020013415 setup_preset(codec, &alc269_presets[board_config]);
Kailang Yangf6a92242007-12-13 16:52:54 +010013416
Takashi Iwaif03d3112009-03-05 14:18:16 +010013417 if (codec->subsystem_id == 0x17aa3bf8) {
13418 /* Due to a hardware problem on Lenovo Ideadpad, we need to
13419 * fix the sample rate of analog I/O to 44.1kHz
13420 */
13421 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
13422 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
13423 } else {
13424 spec->stream_analog_playback = &alc269_pcm_analog_playback;
13425 spec->stream_analog_capture = &alc269_pcm_analog_capture;
13426 }
Kailang Yangf6a92242007-12-13 16:52:54 +010013427 spec->stream_digital_playback = &alc269_pcm_digital_playback;
13428 spec->stream_digital_capture = &alc269_pcm_digital_capture;
13429
13430 spec->adc_nids = alc269_adc_nids;
13431 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
Takashi Iwaie01bf502008-08-21 16:25:07 +020013432 spec->capsrc_nids = alc269_capsrc_nids;
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013433 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020013434 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013435 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010013436
Takashi Iwai100d5eb2009-08-10 11:55:51 +020013437 spec->vmaster_nid = 0x02;
13438
Kailang Yangf6a92242007-12-13 16:52:54 +010013439 codec->patch_ops = alc_patch_ops;
13440 if (board_config == ALC269_AUTO)
13441 spec->init_hook = alc269_auto_init;
13442#ifdef CONFIG_SND_HDA_POWER_SAVE
13443 if (!spec->loopback.amplist)
13444 spec->loopback.amplist = alc269_loopbacks;
13445#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010013446 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010013447
13448 return 0;
13449}
13450
13451/*
Kailang Yangdf694da2005-12-05 19:42:22 +010013452 * ALC861 channel source setting (2/6 channel selection for 3-stack)
13453 */
13454
13455/*
13456 * set the path ways for 2 channel output
13457 * need to set the codec line out and mic 1 pin widgets to inputs
13458 */
13459static struct hda_verb alc861_threestack_ch2_init[] = {
13460 /* set pin widget 1Ah (line in) for input */
13461 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013462 /* set pin widget 18h (mic1/2) for input, for mic also enable
13463 * the vref
13464 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013465 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13466
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013467 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13468#if 0
13469 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13470 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13471#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013472 { } /* end */
13473};
13474/*
13475 * 6ch mode
13476 * need to set the codec line out and mic 1 pin widgets to outputs
13477 */
13478static struct hda_verb alc861_threestack_ch6_init[] = {
13479 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13480 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13481 /* set pin widget 18h (mic1) for output (CLFE)*/
13482 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13483
13484 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013485 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013486
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013487 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13488#if 0
13489 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13490 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13491#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013492 { } /* end */
13493};
13494
13495static struct hda_channel_mode alc861_threestack_modes[2] = {
13496 { 2, alc861_threestack_ch2_init },
13497 { 6, alc861_threestack_ch6_init },
13498};
Takashi Iwai22309c32006-08-09 16:57:28 +020013499/* Set mic1 as input and unmute the mixer */
13500static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
13501 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13502 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13503 { } /* end */
13504};
13505/* Set mic1 as output and mute mixer */
13506static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
13507 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13508 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13509 { } /* end */
13510};
13511
13512static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
13513 { 2, alc861_uniwill_m31_ch2_init },
13514 { 4, alc861_uniwill_m31_ch4_init },
13515};
Kailang Yangdf694da2005-12-05 19:42:22 +010013516
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013517/* Set mic1 and line-in as input and unmute the mixer */
13518static struct hda_verb alc861_asus_ch2_init[] = {
13519 /* set pin widget 1Ah (line in) for input */
13520 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013521 /* set pin widget 18h (mic1/2) for input, for mic also enable
13522 * the vref
13523 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013524 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13525
13526 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13527#if 0
13528 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13529 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13530#endif
13531 { } /* end */
13532};
13533/* Set mic1 nad line-in as output and mute mixer */
13534static struct hda_verb alc861_asus_ch6_init[] = {
13535 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13536 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13537 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13538 /* set pin widget 18h (mic1) for output (CLFE)*/
13539 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13540 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13541 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
13542 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
13543
13544 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13545#if 0
13546 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13547 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13548#endif
13549 { } /* end */
13550};
13551
13552static struct hda_channel_mode alc861_asus_modes[2] = {
13553 { 2, alc861_asus_ch2_init },
13554 { 6, alc861_asus_ch6_init },
13555};
13556
Kailang Yangdf694da2005-12-05 19:42:22 +010013557/* patch-ALC861 */
13558
13559static struct snd_kcontrol_new alc861_base_mixer[] = {
13560 /* output mixer control */
13561 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13562 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13563 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13564 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13565 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13566
13567 /*Input mixer control */
13568 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13569 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13570 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13571 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13572 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13573 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13574 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13575 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13576 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13577 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013578
Kailang Yangdf694da2005-12-05 19:42:22 +010013579 { } /* end */
13580};
13581
13582static struct snd_kcontrol_new alc861_3ST_mixer[] = {
13583 /* output mixer control */
13584 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13585 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13586 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13587 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13588 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13589
13590 /* Input mixer control */
13591 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13592 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13593 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13594 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13595 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13596 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13597 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13598 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13599 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13600 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013601
Kailang Yangdf694da2005-12-05 19:42:22 +010013602 {
13603 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13604 .name = "Channel Mode",
13605 .info = alc_ch_mode_info,
13606 .get = alc_ch_mode_get,
13607 .put = alc_ch_mode_put,
13608 .private_value = ARRAY_SIZE(alc861_threestack_modes),
13609 },
13610 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013611};
13612
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013613static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013614 /* output mixer control */
13615 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13616 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13617 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020013618
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013619 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013620};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013621
Takashi Iwai22309c32006-08-09 16:57:28 +020013622static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
13623 /* output mixer control */
13624 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13625 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13626 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13627 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13628 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13629
13630 /* Input mixer control */
13631 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13632 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13633 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13634 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13635 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13636 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13637 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13638 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13639 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13640 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013641
Takashi Iwai22309c32006-08-09 16:57:28 +020013642 {
13643 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13644 .name = "Channel Mode",
13645 .info = alc_ch_mode_info,
13646 .get = alc_ch_mode_get,
13647 .put = alc_ch_mode_put,
13648 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
13649 },
13650 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013651};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013652
13653static struct snd_kcontrol_new alc861_asus_mixer[] = {
13654 /* output mixer control */
13655 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13656 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13657 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13658 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13659 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13660
13661 /* Input mixer control */
13662 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13663 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13664 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13665 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13666 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13667 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13668 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13669 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13670 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013671 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
13672
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013673 {
13674 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13675 .name = "Channel Mode",
13676 .info = alc_ch_mode_info,
13677 .get = alc_ch_mode_get,
13678 .put = alc_ch_mode_put,
13679 .private_value = ARRAY_SIZE(alc861_asus_modes),
13680 },
13681 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013682};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013683
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013684/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013685static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013686 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13687 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013688 { }
13689};
13690
Kailang Yangdf694da2005-12-05 19:42:22 +010013691/*
13692 * generic initialization of ADC, input mixers and output mixers
13693 */
13694static struct hda_verb alc861_base_init_verbs[] = {
13695 /*
13696 * Unmute ADC0 and set the default input to mic-in
13697 */
13698 /* port-A for surround (rear panel) */
13699 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13700 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
13701 /* port-B for mic-in (rear panel) with vref */
13702 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13703 /* port-C for line-in (rear panel) */
13704 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13705 /* port-D for Front */
13706 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13707 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13708 /* port-E for HP out (front panel) */
13709 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13710 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013711 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013712 /* port-F for mic-in (front panel) with vref */
13713 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13714 /* port-G for CLFE (rear panel) */
13715 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13716 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13717 /* port-H for side (rear panel) */
13718 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13719 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
13720 /* CD-in */
13721 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13722 /* route front mic to ADC1*/
13723 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13724 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013725
Kailang Yangdf694da2005-12-05 19:42:22 +010013726 /* Unmute DAC0~3 & spdif out*/
13727 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13728 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13729 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13730 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13731 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013732
Kailang Yangdf694da2005-12-05 19:42:22 +010013733 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13734 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13735 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13736 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13737 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013738
Kailang Yangdf694da2005-12-05 19:42:22 +010013739 /* Unmute Stereo Mixer 15 */
13740 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13741 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13742 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013743 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013744
13745 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13746 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13747 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13748 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13749 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13750 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13751 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13752 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013753 /* hp used DAC 3 (Front) */
13754 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013755 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13756
13757 { }
13758};
13759
13760static struct hda_verb alc861_threestack_init_verbs[] = {
13761 /*
13762 * Unmute ADC0 and set the default input to mic-in
13763 */
13764 /* port-A for surround (rear panel) */
13765 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13766 /* port-B for mic-in (rear panel) with vref */
13767 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13768 /* port-C for line-in (rear panel) */
13769 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13770 /* port-D for Front */
13771 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13772 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13773 /* port-E for HP out (front panel) */
13774 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13775 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013776 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013777 /* port-F for mic-in (front panel) with vref */
13778 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13779 /* port-G for CLFE (rear panel) */
13780 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13781 /* port-H for side (rear panel) */
13782 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13783 /* CD-in */
13784 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13785 /* route front mic to ADC1*/
13786 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13787 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13788 /* Unmute DAC0~3 & spdif out*/
13789 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13790 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13791 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13792 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13793 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013794
Kailang Yangdf694da2005-12-05 19:42:22 +010013795 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13796 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13797 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13798 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13799 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013800
Kailang Yangdf694da2005-12-05 19:42:22 +010013801 /* Unmute Stereo Mixer 15 */
13802 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13803 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13804 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013805 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013806
13807 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13808 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13809 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13810 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13811 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13812 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13813 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13814 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013815 /* hp used DAC 3 (Front) */
13816 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013817 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13818 { }
13819};
Takashi Iwai22309c32006-08-09 16:57:28 +020013820
13821static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
13822 /*
13823 * Unmute ADC0 and set the default input to mic-in
13824 */
13825 /* port-A for surround (rear panel) */
13826 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13827 /* port-B for mic-in (rear panel) with vref */
13828 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13829 /* port-C for line-in (rear panel) */
13830 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13831 /* port-D for Front */
13832 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13833 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13834 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013835 /* this has to be set to VREF80 */
13836 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013837 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013838 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013839 /* port-F for mic-in (front panel) with vref */
13840 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13841 /* port-G for CLFE (rear panel) */
13842 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13843 /* port-H for side (rear panel) */
13844 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13845 /* CD-in */
13846 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13847 /* route front mic to ADC1*/
13848 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13849 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13850 /* Unmute DAC0~3 & spdif out*/
13851 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13852 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13853 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13854 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13855 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013856
Takashi Iwai22309c32006-08-09 16:57:28 +020013857 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13858 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13859 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13860 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13861 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013862
Takashi Iwai22309c32006-08-09 16:57:28 +020013863 /* Unmute Stereo Mixer 15 */
13864 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13865 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13866 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013867 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020013868
13869 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13870 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13871 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13872 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13873 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13874 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13875 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13876 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013877 /* hp used DAC 3 (Front) */
13878 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020013879 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13880 { }
13881};
13882
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013883static struct hda_verb alc861_asus_init_verbs[] = {
13884 /*
13885 * Unmute ADC0 and set the default input to mic-in
13886 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013887 /* port-A for surround (rear panel)
13888 * according to codec#0 this is the HP jack
13889 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013890 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
13891 /* route front PCM to HP */
13892 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
13893 /* port-B for mic-in (rear panel) with vref */
13894 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13895 /* port-C for line-in (rear panel) */
13896 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13897 /* port-D for Front */
13898 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13899 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13900 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013901 /* this has to be set to VREF80 */
13902 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013903 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013904 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013905 /* port-F for mic-in (front panel) with vref */
13906 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13907 /* port-G for CLFE (rear panel) */
13908 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13909 /* port-H for side (rear panel) */
13910 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13911 /* CD-in */
13912 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13913 /* route front mic to ADC1*/
13914 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13915 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13916 /* Unmute DAC0~3 & spdif out*/
13917 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13918 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13919 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13920 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13921 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13922 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13923 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13924 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13925 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13926 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013927
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013928 /* Unmute Stereo Mixer 15 */
13929 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13930 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13931 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013932 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013933
13934 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13935 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13936 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13937 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13938 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13939 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13940 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13941 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013942 /* hp used DAC 3 (Front) */
13943 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013944 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13945 { }
13946};
13947
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013948/* additional init verbs for ASUS laptops */
13949static struct hda_verb alc861_asus_laptop_init_verbs[] = {
13950 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
13951 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
13952 { }
13953};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013954
Kailang Yangdf694da2005-12-05 19:42:22 +010013955/*
13956 * generic initialization of ADC, input mixers and output mixers
13957 */
13958static struct hda_verb alc861_auto_init_verbs[] = {
13959 /*
13960 * Unmute ADC0 and set the default input to mic-in
13961 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013962 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010013963 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013964
Kailang Yangdf694da2005-12-05 19:42:22 +010013965 /* Unmute DAC0~3 & spdif out*/
13966 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13967 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13968 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13969 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13970 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013971
Kailang Yangdf694da2005-12-05 19:42:22 +010013972 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13973 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13974 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13975 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13976 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013977
Kailang Yangdf694da2005-12-05 19:42:22 +010013978 /* Unmute Stereo Mixer 15 */
13979 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13980 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13981 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13982 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
13983
Takashi Iwai1c209302009-07-22 15:17:45 +020013984 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13985 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13986 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13987 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13988 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13989 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13990 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13991 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013992
13993 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13994 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020013995 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13996 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013997 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13998 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020013999 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14000 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014001
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014002 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014003
14004 { }
14005};
14006
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014007static struct hda_verb alc861_toshiba_init_verbs[] = {
14008 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014009
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014010 { }
14011};
14012
14013/* toggle speaker-output according to the hp-jack state */
14014static void alc861_toshiba_automute(struct hda_codec *codec)
14015{
14016 unsigned int present;
14017
14018 present = snd_hda_codec_read(codec, 0x0f, 0,
14019 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014020 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
14021 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
14022 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
14023 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014024}
14025
14026static void alc861_toshiba_unsol_event(struct hda_codec *codec,
14027 unsigned int res)
14028{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014029 if ((res >> 26) == ALC880_HP_EVENT)
14030 alc861_toshiba_automute(codec);
14031}
14032
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014033/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014034#define alc861_pcm_analog_playback alc880_pcm_analog_playback
14035#define alc861_pcm_analog_capture alc880_pcm_analog_capture
14036#define alc861_pcm_digital_playback alc880_pcm_digital_playback
14037#define alc861_pcm_digital_capture alc880_pcm_digital_capture
14038
14039
14040#define ALC861_DIGOUT_NID 0x07
14041
14042static struct hda_channel_mode alc861_8ch_modes[1] = {
14043 { 8, NULL }
14044};
14045
14046static hda_nid_t alc861_dac_nids[4] = {
14047 /* front, surround, clfe, side */
14048 0x03, 0x06, 0x05, 0x04
14049};
14050
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014051static hda_nid_t alc660_dac_nids[3] = {
14052 /* front, clfe, surround */
14053 0x03, 0x05, 0x06
14054};
14055
Kailang Yangdf694da2005-12-05 19:42:22 +010014056static hda_nid_t alc861_adc_nids[1] = {
14057 /* ADC0-2 */
14058 0x08,
14059};
14060
14061static struct hda_input_mux alc861_capture_source = {
14062 .num_items = 5,
14063 .items = {
14064 { "Mic", 0x0 },
14065 { "Front Mic", 0x3 },
14066 { "Line", 0x1 },
14067 { "CD", 0x4 },
14068 { "Mixer", 0x5 },
14069 },
14070};
14071
Takashi Iwai1c209302009-07-22 15:17:45 +020014072static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
14073{
14074 struct alc_spec *spec = codec->spec;
14075 hda_nid_t mix, srcs[5];
14076 int i, j, num;
14077
14078 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
14079 return 0;
14080 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
14081 if (num < 0)
14082 return 0;
14083 for (i = 0; i < num; i++) {
14084 unsigned int type;
Takashi Iwaia22d5432009-07-27 12:54:26 +020014085 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
Takashi Iwai1c209302009-07-22 15:17:45 +020014086 if (type != AC_WID_AUD_OUT)
14087 continue;
14088 for (j = 0; j < spec->multiout.num_dacs; j++)
14089 if (spec->multiout.dac_nids[j] == srcs[i])
14090 break;
14091 if (j >= spec->multiout.num_dacs)
14092 return srcs[i];
14093 }
14094 return 0;
14095}
14096
Kailang Yangdf694da2005-12-05 19:42:22 +010014097/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwai1c209302009-07-22 15:17:45 +020014098static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014099 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014100{
Takashi Iwai1c209302009-07-22 15:17:45 +020014101 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014102 int i;
Takashi Iwai1c209302009-07-22 15:17:45 +020014103 hda_nid_t nid, dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010014104
14105 spec->multiout.dac_nids = spec->private_dac_nids;
14106 for (i = 0; i < cfg->line_outs; i++) {
14107 nid = cfg->line_out_pins[i];
Takashi Iwai1c209302009-07-22 15:17:45 +020014108 dac = alc861_look_for_dac(codec, nid);
14109 if (!dac)
14110 continue;
14111 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010014112 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014113 return 0;
14114}
14115
Takashi Iwai1c209302009-07-22 15:17:45 +020014116static int alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
14117 hda_nid_t nid, unsigned int chs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014118{
14119 char name[32];
Takashi Iwai1c209302009-07-22 15:17:45 +020014120 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
14121 return add_control(codec->spec, ALC_CTL_WIDGET_MUTE, name,
14122 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
14123}
14124
14125/* add playback controls from the parsed DAC table */
14126static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
14127 const struct auto_pin_cfg *cfg)
14128{
14129 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014130 static const char *chname[4] = {
14131 "Front", "Surround", NULL /*CLFE*/, "Side"
14132 };
Kailang Yangdf694da2005-12-05 19:42:22 +010014133 hda_nid_t nid;
Takashi Iwai1c209302009-07-22 15:17:45 +020014134 int i, err;
14135
14136 if (cfg->line_outs == 1) {
14137 const char *pfx = NULL;
14138 if (!cfg->hp_outs)
14139 pfx = "Master";
14140 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
14141 pfx = "Speaker";
14142 if (pfx) {
14143 nid = spec->multiout.dac_nids[0];
14144 return alc861_create_out_sw(codec, pfx, nid, 3);
14145 }
14146 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014147
14148 for (i = 0; i < cfg->line_outs; i++) {
14149 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014150 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010014151 continue;
Takashi Iwai1c209302009-07-22 15:17:45 +020014152 if (i == 2) {
Kailang Yangdf694da2005-12-05 19:42:22 +010014153 /* Center/LFE */
Takashi Iwai1c209302009-07-22 15:17:45 +020014154 err = alc861_create_out_sw(codec, "Center", nid, 1);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014155 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014156 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014157 err = alc861_create_out_sw(codec, "LFE", nid, 2);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014158 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014159 return err;
14160 } else {
Takashi Iwai1c209302009-07-22 15:17:45 +020014161 err = alc861_create_out_sw(codec, chname[i], nid, 3);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014162 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014163 return err;
14164 }
14165 }
14166 return 0;
14167}
14168
Takashi Iwai1c209302009-07-22 15:17:45 +020014169static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010014170{
Takashi Iwai1c209302009-07-22 15:17:45 +020014171 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014172 int err;
14173 hda_nid_t nid;
14174
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014175 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010014176 return 0;
14177
14178 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
Takashi Iwai1c209302009-07-22 15:17:45 +020014179 nid = alc861_look_for_dac(codec, pin);
14180 if (nid) {
14181 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
14182 if (err < 0)
14183 return err;
14184 spec->multiout.hp_nid = nid;
14185 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014186 }
14187 return 0;
14188}
14189
14190/* create playback/capture controls for input pins */
Takashi Iwai1c209302009-07-22 15:17:45 +020014191static int alc861_auto_create_analog_input_ctls(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014192 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014193{
Takashi Iwai1c209302009-07-22 15:17:45 +020014194 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014195 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010014196 int i, err, idx, idx1;
14197
14198 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014199 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010014200 case 0x0c:
14201 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014202 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010014203 break;
14204 case 0x0f:
14205 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014206 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010014207 break;
14208 case 0x0d:
14209 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014210 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010014211 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014212 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010014213 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014214 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010014215 break;
14216 case 0x11:
14217 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014218 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010014219 break;
14220 default:
14221 continue;
14222 }
14223
Takashi Iwai4a471b72005-12-07 13:56:29 +010014224 err = new_analog_input(spec, cfg->input_pins[i],
14225 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010014226 if (err < 0)
14227 return err;
14228
Takashi Iwai4a471b72005-12-07 13:56:29 +010014229 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010014230 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014231 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010014232 }
14233 return 0;
14234}
14235
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014236static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
14237 hda_nid_t nid,
Takashi Iwai1c209302009-07-22 15:17:45 +020014238 int pin_type, hda_nid_t dac)
Kailang Yangdf694da2005-12-05 19:42:22 +010014239{
Takashi Iwai1c209302009-07-22 15:17:45 +020014240 hda_nid_t mix, srcs[5];
14241 int i, num;
14242
Jacek Luczak564c5be2008-05-03 18:41:23 +020014243 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
14244 pin_type);
Takashi Iwai1c209302009-07-22 15:17:45 +020014245 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Jacek Luczak564c5be2008-05-03 18:41:23 +020014246 AMP_OUT_UNMUTE);
Takashi Iwai1c209302009-07-22 15:17:45 +020014247 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
14248 return;
14249 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
14250 if (num < 0)
14251 return;
14252 for (i = 0; i < num; i++) {
14253 unsigned int mute;
14254 if (srcs[i] == dac || srcs[i] == 0x15)
14255 mute = AMP_IN_UNMUTE(i);
14256 else
14257 mute = AMP_IN_MUTE(i);
14258 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14259 mute);
14260 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014261}
14262
14263static void alc861_auto_init_multi_out(struct hda_codec *codec)
14264{
14265 struct alc_spec *spec = codec->spec;
14266 int i;
14267
14268 for (i = 0; i < spec->autocfg.line_outs; i++) {
14269 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014270 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010014271 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014272 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014273 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014274 }
14275}
14276
14277static void alc861_auto_init_hp_out(struct hda_codec *codec)
14278{
14279 struct alc_spec *spec = codec->spec;
14280 hda_nid_t pin;
14281
Takashi Iwaieb06ed82006-09-20 17:10:27 +020014282 pin = spec->autocfg.hp_pins[0];
Takashi Iwai1c209302009-07-22 15:17:45 +020014283 if (pin)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014284 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
Takashi Iwai1c209302009-07-22 15:17:45 +020014285 spec->multiout.hp_nid);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014286 pin = spec->autocfg.speaker_pins[0];
14287 if (pin)
Takashi Iwai1c209302009-07-22 15:17:45 +020014288 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT,
14289 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014290}
14291
14292static void alc861_auto_init_analog_input(struct hda_codec *codec)
14293{
14294 struct alc_spec *spec = codec->spec;
14295 int i;
14296
14297 for (i = 0; i < AUTO_PIN_LAST; i++) {
14298 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai23f0c042009-02-26 13:03:58 +010014299 if (nid >= 0x0c && nid <= 0x11)
14300 alc_set_input_pin(codec, nid, i);
Kailang Yangdf694da2005-12-05 19:42:22 +010014301 }
14302}
14303
14304/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014305/* return 1 if successful, 0 if the proper config is not found,
14306 * or a negative error code
14307 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014308static int alc861_parse_auto_config(struct hda_codec *codec)
14309{
14310 struct alc_spec *spec = codec->spec;
14311 int err;
14312 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
14313
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014314 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14315 alc861_ignore);
14316 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014317 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014318 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014319 return 0; /* can't find valid BIOS pin config */
14320
Takashi Iwai1c209302009-07-22 15:17:45 +020014321 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014322 if (err < 0)
14323 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014324 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014325 if (err < 0)
14326 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014327 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014328 if (err < 0)
14329 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014330 err = alc861_auto_create_analog_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014331 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014332 return err;
14333
14334 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14335
Takashi Iwai0852d7a2009-02-11 11:35:15 +010014336 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014337 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
14338
Takashi Iwai603c4012008-07-30 15:01:44 +020014339 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014340 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010014341
Takashi Iwaid88897e2008-10-31 15:01:37 +010014342 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010014343
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020014344 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014345 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010014346
14347 spec->adc_nids = alc861_adc_nids;
14348 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014349 set_capture_mixer(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014350
Takashi Iwai4a79ba32009-04-22 16:31:35 +020014351 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b);
14352
Kailang Yangdf694da2005-12-05 19:42:22 +010014353 return 1;
14354}
14355
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014356/* additional initialization for auto-configuration model */
14357static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010014358{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014359 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014360 alc861_auto_init_multi_out(codec);
14361 alc861_auto_init_hp_out(codec);
14362 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014363 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014364 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014365}
14366
Takashi Iwaicb53c622007-08-10 17:21:45 +020014367#ifdef CONFIG_SND_HDA_POWER_SAVE
14368static struct hda_amp_list alc861_loopbacks[] = {
14369 { 0x15, HDA_INPUT, 0 },
14370 { 0x15, HDA_INPUT, 1 },
14371 { 0x15, HDA_INPUT, 2 },
14372 { 0x15, HDA_INPUT, 3 },
14373 { } /* end */
14374};
14375#endif
14376
Kailang Yangdf694da2005-12-05 19:42:22 +010014377
14378/*
14379 * configuration and preset
14380 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014381static const char *alc861_models[ALC861_MODEL_LAST] = {
14382 [ALC861_3ST] = "3stack",
14383 [ALC660_3ST] = "3stack-660",
14384 [ALC861_3ST_DIG] = "3stack-dig",
14385 [ALC861_6ST_DIG] = "6stack-dig",
14386 [ALC861_UNIWILL_M31] = "uniwill-m31",
14387 [ALC861_TOSHIBA] = "toshiba",
14388 [ALC861_ASUS] = "asus",
14389 [ALC861_ASUS_LAPTOP] = "asus-laptop",
14390 [ALC861_AUTO] = "auto",
14391};
14392
14393static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010014394 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014395 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14396 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14397 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014398 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020014399 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010014400 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020014401 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
14402 * Any other models that need this preset?
14403 */
14404 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020014405 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
14406 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014407 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
14408 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
14409 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
14410 /* FIXME: the below seems conflict */
14411 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
14412 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
14413 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010014414 {}
14415};
14416
14417static struct alc_config_preset alc861_presets[] = {
14418 [ALC861_3ST] = {
14419 .mixers = { alc861_3ST_mixer },
14420 .init_verbs = { alc861_threestack_init_verbs },
14421 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14422 .dac_nids = alc861_dac_nids,
14423 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14424 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014425 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014426 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14427 .adc_nids = alc861_adc_nids,
14428 .input_mux = &alc861_capture_source,
14429 },
14430 [ALC861_3ST_DIG] = {
14431 .mixers = { alc861_base_mixer },
14432 .init_verbs = { alc861_threestack_init_verbs },
14433 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14434 .dac_nids = alc861_dac_nids,
14435 .dig_out_nid = ALC861_DIGOUT_NID,
14436 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14437 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014438 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014439 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14440 .adc_nids = alc861_adc_nids,
14441 .input_mux = &alc861_capture_source,
14442 },
14443 [ALC861_6ST_DIG] = {
14444 .mixers = { alc861_base_mixer },
14445 .init_verbs = { alc861_base_init_verbs },
14446 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14447 .dac_nids = alc861_dac_nids,
14448 .dig_out_nid = ALC861_DIGOUT_NID,
14449 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
14450 .channel_mode = alc861_8ch_modes,
14451 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14452 .adc_nids = alc861_adc_nids,
14453 .input_mux = &alc861_capture_source,
14454 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014455 [ALC660_3ST] = {
14456 .mixers = { alc861_3ST_mixer },
14457 .init_verbs = { alc861_threestack_init_verbs },
14458 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
14459 .dac_nids = alc660_dac_nids,
14460 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14461 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014462 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014463 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14464 .adc_nids = alc861_adc_nids,
14465 .input_mux = &alc861_capture_source,
14466 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014467 [ALC861_UNIWILL_M31] = {
14468 .mixers = { alc861_uniwill_m31_mixer },
14469 .init_verbs = { alc861_uniwill_m31_init_verbs },
14470 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14471 .dac_nids = alc861_dac_nids,
14472 .dig_out_nid = ALC861_DIGOUT_NID,
14473 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
14474 .channel_mode = alc861_uniwill_m31_modes,
14475 .need_dac_fix = 1,
14476 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14477 .adc_nids = alc861_adc_nids,
14478 .input_mux = &alc861_capture_source,
14479 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014480 [ALC861_TOSHIBA] = {
14481 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014482 .init_verbs = { alc861_base_init_verbs,
14483 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014484 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14485 .dac_nids = alc861_dac_nids,
14486 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14487 .channel_mode = alc883_3ST_2ch_modes,
14488 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14489 .adc_nids = alc861_adc_nids,
14490 .input_mux = &alc861_capture_source,
14491 .unsol_event = alc861_toshiba_unsol_event,
14492 .init_hook = alc861_toshiba_automute,
14493 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014494 [ALC861_ASUS] = {
14495 .mixers = { alc861_asus_mixer },
14496 .init_verbs = { alc861_asus_init_verbs },
14497 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14498 .dac_nids = alc861_dac_nids,
14499 .dig_out_nid = ALC861_DIGOUT_NID,
14500 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
14501 .channel_mode = alc861_asus_modes,
14502 .need_dac_fix = 1,
14503 .hp_nid = 0x06,
14504 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14505 .adc_nids = alc861_adc_nids,
14506 .input_mux = &alc861_capture_source,
14507 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014508 [ALC861_ASUS_LAPTOP] = {
14509 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
14510 .init_verbs = { alc861_asus_init_verbs,
14511 alc861_asus_laptop_init_verbs },
14512 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14513 .dac_nids = alc861_dac_nids,
14514 .dig_out_nid = ALC861_DIGOUT_NID,
14515 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14516 .channel_mode = alc883_3ST_2ch_modes,
14517 .need_dac_fix = 1,
14518 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14519 .adc_nids = alc861_adc_nids,
14520 .input_mux = &alc861_capture_source,
14521 },
14522};
Kailang Yangdf694da2005-12-05 19:42:22 +010014523
14524
14525static int patch_alc861(struct hda_codec *codec)
14526{
14527 struct alc_spec *spec;
14528 int board_config;
14529 int err;
14530
Robert P. J. Daydc041e02006-12-19 14:44:15 +010014531 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010014532 if (spec == NULL)
14533 return -ENOMEM;
14534
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014535 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014536
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014537 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
14538 alc861_models,
14539 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014540
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014541 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020014542 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
14543 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010014544 board_config = ALC861_AUTO;
14545 }
14546
14547 if (board_config == ALC861_AUTO) {
14548 /* automatic parse from the BIOS config */
14549 err = alc861_parse_auto_config(codec);
14550 if (err < 0) {
14551 alc_free(codec);
14552 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014553 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014554 printk(KERN_INFO
14555 "hda_codec: Cannot set up configuration "
14556 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010014557 board_config = ALC861_3ST_DIG;
14558 }
14559 }
14560
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014561 err = snd_hda_attach_beep_device(codec, 0x23);
14562 if (err < 0) {
14563 alc_free(codec);
14564 return err;
14565 }
14566
Kailang Yangdf694da2005-12-05 19:42:22 +010014567 if (board_config != ALC861_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020014568 setup_preset(codec, &alc861_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014569
Kailang Yangdf694da2005-12-05 19:42:22 +010014570 spec->stream_analog_playback = &alc861_pcm_analog_playback;
14571 spec->stream_analog_capture = &alc861_pcm_analog_capture;
14572
Kailang Yangdf694da2005-12-05 19:42:22 +010014573 spec->stream_digital_playback = &alc861_pcm_digital_playback;
14574 spec->stream_digital_capture = &alc861_pcm_digital_capture;
14575
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014576 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
14577
Takashi Iwai2134ea42008-01-10 16:53:55 +010014578 spec->vmaster_nid = 0x03;
14579
Kailang Yangdf694da2005-12-05 19:42:22 +010014580 codec->patch_ops = alc_patch_ops;
14581 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014582 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014583#ifdef CONFIG_SND_HDA_POWER_SAVE
14584 if (!spec->loopback.amplist)
14585 spec->loopback.amplist = alc861_loopbacks;
14586#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010014587 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020014588
Kailang Yangdf694da2005-12-05 19:42:22 +010014589 return 0;
14590}
14591
14592/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014593 * ALC861-VD support
14594 *
14595 * Based on ALC882
14596 *
14597 * In addition, an independent DAC
14598 */
14599#define ALC861VD_DIGOUT_NID 0x06
14600
14601static hda_nid_t alc861vd_dac_nids[4] = {
14602 /* front, surr, clfe, side surr */
14603 0x02, 0x03, 0x04, 0x05
14604};
14605
14606/* dac_nids for ALC660vd are in a different order - according to
14607 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014608 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014609 * of ALC660vd codecs, but for now there is only 3stack mixer
14610 * - and it is the same as in 861vd.
14611 * adc_nids in ALC660vd are (is) the same as in 861vd
14612 */
14613static hda_nid_t alc660vd_dac_nids[3] = {
14614 /* front, rear, clfe, rear_surr */
14615 0x02, 0x04, 0x03
14616};
14617
14618static hda_nid_t alc861vd_adc_nids[1] = {
14619 /* ADC0 */
14620 0x09,
14621};
14622
Takashi Iwaie1406342008-02-11 18:32:32 +010014623static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
14624
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014625/* input MUX */
14626/* FIXME: should be a matrix-type input source selection */
14627static struct hda_input_mux alc861vd_capture_source = {
14628 .num_items = 4,
14629 .items = {
14630 { "Mic", 0x0 },
14631 { "Front Mic", 0x1 },
14632 { "Line", 0x2 },
14633 { "CD", 0x4 },
14634 },
14635};
14636
Kailang Yang272a5272007-05-14 11:00:38 +020014637static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010014638 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020014639 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010014640 { "Ext Mic", 0x0 },
14641 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020014642 },
14643};
14644
Kailang Yangd1a991a2007-08-15 16:21:59 +020014645static struct hda_input_mux alc861vd_hp_capture_source = {
14646 .num_items = 2,
14647 .items = {
14648 { "Front Mic", 0x0 },
14649 { "ATAPI Mic", 0x1 },
14650 },
14651};
14652
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014653/*
14654 * 2ch mode
14655 */
14656static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
14657 { 2, NULL }
14658};
14659
14660/*
14661 * 6ch mode
14662 */
14663static struct hda_verb alc861vd_6stack_ch6_init[] = {
14664 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14665 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14666 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14667 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14668 { } /* end */
14669};
14670
14671/*
14672 * 8ch mode
14673 */
14674static struct hda_verb alc861vd_6stack_ch8_init[] = {
14675 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14676 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14677 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14678 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14679 { } /* end */
14680};
14681
14682static struct hda_channel_mode alc861vd_6stack_modes[2] = {
14683 { 6, alc861vd_6stack_ch6_init },
14684 { 8, alc861vd_6stack_ch8_init },
14685};
14686
14687static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
14688 {
14689 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14690 .name = "Channel Mode",
14691 .info = alc_ch_mode_info,
14692 .get = alc_ch_mode_get,
14693 .put = alc_ch_mode_put,
14694 },
14695 { } /* end */
14696};
14697
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014698/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
14699 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
14700 */
14701static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
14702 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14703 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14704
14705 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14706 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
14707
14708 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
14709 HDA_OUTPUT),
14710 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
14711 HDA_OUTPUT),
14712 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
14713 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
14714
14715 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
14716 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
14717
14718 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14719
14720 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14721 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14722 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14723
14724 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14725 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14726 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14727
14728 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14729 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14730
14731 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14732 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14733
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014734 { } /* end */
14735};
14736
14737static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
14738 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14739 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14740
14741 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14742
14743 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14744 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14745 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14746
14747 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14748 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14749 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14750
14751 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14752 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14753
14754 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14755 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14756
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014757 { } /* end */
14758};
14759
Kailang Yangbdd148a2007-05-08 15:19:08 +020014760static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
14761 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14762 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
14763 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14764
14765 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14766
14767 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14768 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14769 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14770
14771 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14772 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14773 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14774
14775 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14776 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14777
14778 { } /* end */
14779};
14780
Tobin Davisb419f342008-03-07 11:57:51 +010014781/* Pin assignment: Speaker=0x14, HP = 0x15,
14782 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020014783 */
14784static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010014785 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14786 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014787 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14788 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010014789 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
14790 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14791 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14792 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
14793 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14794 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014795 { } /* end */
14796};
14797
Kailang Yangd1a991a2007-08-15 16:21:59 +020014798/* Pin assignment: Speaker=0x14, Line-out = 0x15,
14799 * Front Mic=0x18, ATAPI Mic = 0x19,
14800 */
14801static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
14802 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14803 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14804 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14805 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
14806 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14807 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14808 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14809 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020014810
Kailang Yangd1a991a2007-08-15 16:21:59 +020014811 { } /* end */
14812};
14813
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014814/*
14815 * generic initialization of ADC, input mixers and output mixers
14816 */
14817static struct hda_verb alc861vd_volume_init_verbs[] = {
14818 /*
14819 * Unmute ADC0 and set the default input to mic-in
14820 */
14821 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14822 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14823
14824 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
14825 * the analog-loopback mixer widget
14826 */
14827 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020014828 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14829 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14830 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14831 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14832 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014833
14834 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020014835 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14836 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14837 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014838 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014839
14840 /*
14841 * Set up output mixers (0x02 - 0x05)
14842 */
14843 /* set vol=0 to output mixers */
14844 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14845 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14846 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14847 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14848
14849 /* set up input amps for analog loopback */
14850 /* Amp Indices: DAC = 0, mixer = 1 */
14851 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14852 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14853 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14854 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14855 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14856 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14857 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14858 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14859
14860 { }
14861};
14862
14863/*
14864 * 3-stack pin configuration:
14865 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
14866 */
14867static struct hda_verb alc861vd_3stack_init_verbs[] = {
14868 /*
14869 * Set pin mode and muting
14870 */
14871 /* set front pin widgets 0x14 for output */
14872 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14873 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14874 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14875
14876 /* Mic (rear) pin: input vref at 80% */
14877 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14878 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14879 /* Front Mic pin: input vref at 80% */
14880 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14881 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14882 /* Line In pin: input */
14883 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14884 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14885 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14886 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14887 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14888 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14889 /* CD pin widget for input */
14890 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14891
14892 { }
14893};
14894
14895/*
14896 * 6-stack pin configuration:
14897 */
14898static struct hda_verb alc861vd_6stack_init_verbs[] = {
14899 /*
14900 * Set pin mode and muting
14901 */
14902 /* set front pin widgets 0x14 for output */
14903 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14904 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14905 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14906
14907 /* Rear Pin: output 1 (0x0d) */
14908 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14909 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14910 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14911 /* CLFE Pin: output 2 (0x0e) */
14912 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14913 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14914 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
14915 /* Side Pin: output 3 (0x0f) */
14916 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14917 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14918 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
14919
14920 /* Mic (rear) pin: input vref at 80% */
14921 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14922 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14923 /* Front Mic pin: input vref at 80% */
14924 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14925 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14926 /* Line In pin: input */
14927 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14928 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14929 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14930 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14931 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14932 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14933 /* CD pin widget for input */
14934 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14935
14936 { }
14937};
14938
Kailang Yangbdd148a2007-05-08 15:19:08 +020014939static struct hda_verb alc861vd_eapd_verbs[] = {
14940 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14941 { }
14942};
14943
Kailang Yangf9423e72008-05-27 12:32:25 +020014944static struct hda_verb alc660vd_eapd_verbs[] = {
14945 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14946 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
14947 { }
14948};
14949
Kailang Yangbdd148a2007-05-08 15:19:08 +020014950static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
14951 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14952 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14953 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
14954 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020014955 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020014956 {}
14957};
14958
Kailang Yangbdd148a2007-05-08 15:19:08 +020014959static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
14960{
14961 unsigned int present;
14962 unsigned char bits;
14963
14964 present = snd_hda_codec_read(codec, 0x18, 0,
14965 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014966 bits = present ? HDA_AMP_MUTE : 0;
14967 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
14968 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014969}
14970
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014971static void alc861vd_lenovo_setup(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020014972{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014973 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014974 spec->autocfg.hp_pins[0] = 0x1b;
14975 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014976}
14977
14978static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
14979{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014980 alc_automute_amp(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014981 alc861vd_lenovo_mic_automute(codec);
14982}
14983
14984static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
14985 unsigned int res)
14986{
14987 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020014988 case ALC880_MIC_EVENT:
14989 alc861vd_lenovo_mic_automute(codec);
14990 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014991 default:
14992 alc_automute_amp_unsol_event(codec, res);
14993 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020014994 }
14995}
14996
Kailang Yang272a5272007-05-14 11:00:38 +020014997static struct hda_verb alc861vd_dallas_verbs[] = {
14998 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14999 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15000 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15001 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15002
15003 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15004 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15005 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15006 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15007 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15008 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15009 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15010 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015011
Kailang Yang272a5272007-05-14 11:00:38 +020015012 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15013 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15014 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15015 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15016 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15017 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15018 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15019 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15020
15021 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15022 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15023 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15024 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15025 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15026 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15027 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15028 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15029
15030 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15031 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15032 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15033 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
15034
15035 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015036 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020015037 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15038
15039 { } /* end */
15040};
15041
15042/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015043static void alc861vd_dallas_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020015044{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015045 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020015046
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015047 spec->autocfg.hp_pins[0] = 0x15;
15048 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang272a5272007-05-14 11:00:38 +020015049}
15050
Takashi Iwaicb53c622007-08-10 17:21:45 +020015051#ifdef CONFIG_SND_HDA_POWER_SAVE
15052#define alc861vd_loopbacks alc880_loopbacks
15053#endif
15054
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015055/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015056#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
15057#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
15058#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
15059#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
15060
15061/*
15062 * configuration and preset
15063 */
15064static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
15065 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015066 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010015067 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015068 [ALC861VD_3ST] = "3stack",
15069 [ALC861VD_3ST_DIG] = "3stack-digout",
15070 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020015071 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020015072 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015073 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015074 [ALC861VD_AUTO] = "auto",
15075};
15076
15077static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015078 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
15079 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010015080 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015081 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Takashi Iwai13c94742008-11-05 08:06:08 +010015082 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020015083 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015084 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015085 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020015086 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Takashi Iwaice577e82009-08-03 08:23:52 +020015087 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai542d7c62007-08-16 18:57:30 +020015088 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010015089 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020015090 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010015091 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020015092 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015093 {}
15094};
15095
15096static struct alc_config_preset alc861vd_presets[] = {
15097 [ALC660VD_3ST] = {
15098 .mixers = { alc861vd_3st_mixer },
15099 .init_verbs = { alc861vd_volume_init_verbs,
15100 alc861vd_3stack_init_verbs },
15101 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15102 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015103 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15104 .channel_mode = alc861vd_3stack_2ch_modes,
15105 .input_mux = &alc861vd_capture_source,
15106 },
Mike Crash6963f842007-06-25 12:12:51 +020015107 [ALC660VD_3ST_DIG] = {
15108 .mixers = { alc861vd_3st_mixer },
15109 .init_verbs = { alc861vd_volume_init_verbs,
15110 alc861vd_3stack_init_verbs },
15111 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15112 .dac_nids = alc660vd_dac_nids,
15113 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020015114 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15115 .channel_mode = alc861vd_3stack_2ch_modes,
15116 .input_mux = &alc861vd_capture_source,
15117 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015118 [ALC861VD_3ST] = {
15119 .mixers = { alc861vd_3st_mixer },
15120 .init_verbs = { alc861vd_volume_init_verbs,
15121 alc861vd_3stack_init_verbs },
15122 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15123 .dac_nids = alc861vd_dac_nids,
15124 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15125 .channel_mode = alc861vd_3stack_2ch_modes,
15126 .input_mux = &alc861vd_capture_source,
15127 },
15128 [ALC861VD_3ST_DIG] = {
15129 .mixers = { alc861vd_3st_mixer },
15130 .init_verbs = { alc861vd_volume_init_verbs,
15131 alc861vd_3stack_init_verbs },
15132 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15133 .dac_nids = alc861vd_dac_nids,
15134 .dig_out_nid = ALC861VD_DIGOUT_NID,
15135 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15136 .channel_mode = alc861vd_3stack_2ch_modes,
15137 .input_mux = &alc861vd_capture_source,
15138 },
15139 [ALC861VD_6ST_DIG] = {
15140 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
15141 .init_verbs = { alc861vd_volume_init_verbs,
15142 alc861vd_6stack_init_verbs },
15143 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15144 .dac_nids = alc861vd_dac_nids,
15145 .dig_out_nid = ALC861VD_DIGOUT_NID,
15146 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
15147 .channel_mode = alc861vd_6stack_modes,
15148 .input_mux = &alc861vd_capture_source,
15149 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020015150 [ALC861VD_LENOVO] = {
15151 .mixers = { alc861vd_lenovo_mixer },
15152 .init_verbs = { alc861vd_volume_init_verbs,
15153 alc861vd_3stack_init_verbs,
15154 alc861vd_eapd_verbs,
15155 alc861vd_lenovo_unsol_verbs },
15156 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15157 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015158 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15159 .channel_mode = alc861vd_3stack_2ch_modes,
15160 .input_mux = &alc861vd_capture_source,
15161 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015162 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015163 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015164 },
Kailang Yang272a5272007-05-14 11:00:38 +020015165 [ALC861VD_DALLAS] = {
15166 .mixers = { alc861vd_dallas_mixer },
15167 .init_verbs = { alc861vd_dallas_verbs },
15168 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15169 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020015170 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15171 .channel_mode = alc861vd_3stack_2ch_modes,
15172 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015173 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015174 .setup = alc861vd_dallas_setup,
15175 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015176 },
15177 [ALC861VD_HP] = {
15178 .mixers = { alc861vd_hp_mixer },
15179 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
15180 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15181 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015182 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015183 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15184 .channel_mode = alc861vd_3stack_2ch_modes,
15185 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015186 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015187 .setup = alc861vd_dallas_setup,
15188 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +020015189 },
Takashi Iwai13c94742008-11-05 08:06:08 +010015190 [ALC660VD_ASUS_V1S] = {
15191 .mixers = { alc861vd_lenovo_mixer },
15192 .init_verbs = { alc861vd_volume_init_verbs,
15193 alc861vd_3stack_init_verbs,
15194 alc861vd_eapd_verbs,
15195 alc861vd_lenovo_unsol_verbs },
15196 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15197 .dac_nids = alc660vd_dac_nids,
15198 .dig_out_nid = ALC861VD_DIGOUT_NID,
15199 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15200 .channel_mode = alc861vd_3stack_2ch_modes,
15201 .input_mux = &alc861vd_capture_source,
15202 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015203 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015204 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010015205 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015206};
15207
15208/*
15209 * BIOS auto configuration
15210 */
15211static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
15212 hda_nid_t nid, int pin_type, int dac_idx)
15213{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015214 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015215}
15216
15217static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
15218{
15219 struct alc_spec *spec = codec->spec;
15220 int i;
15221
15222 for (i = 0; i <= HDA_SIDE; i++) {
15223 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015224 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015225 if (nid)
15226 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015227 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015228 }
15229}
15230
15231
15232static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
15233{
15234 struct alc_spec *spec = codec->spec;
15235 hda_nid_t pin;
15236
15237 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015238 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015239 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015240 pin = spec->autocfg.speaker_pins[0];
15241 if (pin)
15242 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015243}
15244
15245#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
15246#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
15247
15248static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
15249{
15250 struct alc_spec *spec = codec->spec;
15251 int i;
15252
15253 for (i = 0; i < AUTO_PIN_LAST; i++) {
15254 hda_nid_t nid = spec->autocfg.input_pins[i];
15255 if (alc861vd_is_input_pin(nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010015256 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +010015257 if (nid != ALC861VD_PIN_CD_NID &&
15258 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015259 snd_hda_codec_write(codec, nid, 0,
15260 AC_VERB_SET_AMP_GAIN_MUTE,
15261 AMP_OUT_MUTE);
15262 }
15263 }
15264}
15265
Takashi Iwaif511b012008-08-15 16:46:42 +020015266#define alc861vd_auto_init_input_src alc882_auto_init_input_src
15267
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015268#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
15269#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
15270
15271/* add playback controls from the parsed DAC table */
15272/* Based on ALC880 version. But ALC861VD has separate,
15273 * different NIDs for mute/unmute switch and volume control */
15274static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
15275 const struct auto_pin_cfg *cfg)
15276{
15277 char name[32];
15278 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
15279 hda_nid_t nid_v, nid_s;
15280 int i, err;
15281
15282 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015283 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015284 continue;
15285 nid_v = alc861vd_idx_to_mixer_vol(
15286 alc880_dac_to_idx(
15287 spec->multiout.dac_nids[i]));
15288 nid_s = alc861vd_idx_to_mixer_switch(
15289 alc880_dac_to_idx(
15290 spec->multiout.dac_nids[i]));
15291
15292 if (i == 2) {
15293 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015294 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15295 "Center Playback Volume",
15296 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
15297 HDA_OUTPUT));
15298 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015299 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015300 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15301 "LFE Playback Volume",
15302 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
15303 HDA_OUTPUT));
15304 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015305 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015306 err = add_control(spec, ALC_CTL_BIND_MUTE,
15307 "Center Playback Switch",
15308 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
15309 HDA_INPUT));
15310 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015311 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015312 err = add_control(spec, ALC_CTL_BIND_MUTE,
15313 "LFE Playback Switch",
15314 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
15315 HDA_INPUT));
15316 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015317 return err;
15318 } else {
15319 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015320 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
15321 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
15322 HDA_OUTPUT));
15323 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015324 return err;
15325 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015326 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015327 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015328 HDA_INPUT));
15329 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015330 return err;
15331 }
15332 }
15333 return 0;
15334}
15335
15336/* add playback controls for speaker and HP outputs */
15337/* Based on ALC880 version. But ALC861VD has separate,
15338 * different NIDs for mute/unmute switch and volume control */
15339static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
15340 hda_nid_t pin, const char *pfx)
15341{
15342 hda_nid_t nid_v, nid_s;
15343 int err;
15344 char name[32];
15345
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015346 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015347 return 0;
15348
15349 if (alc880_is_fixed_pin(pin)) {
15350 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
15351 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015352 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015353 spec->multiout.hp_nid = nid_v;
15354 else
15355 spec->multiout.extra_out_nid[0] = nid_v;
15356 /* control HP volume/switch on the output mixer amp */
15357 nid_v = alc861vd_idx_to_mixer_vol(
15358 alc880_fixed_pin_idx(pin));
15359 nid_s = alc861vd_idx_to_mixer_switch(
15360 alc880_fixed_pin_idx(pin));
15361
15362 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015363 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
15364 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
15365 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015366 return err;
15367 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015368 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
15369 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
15370 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015371 return err;
15372 } else if (alc880_is_multi_pin(pin)) {
15373 /* set manual connection */
15374 /* we have only a switch on HP-out PIN */
15375 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015376 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
15377 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
15378 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015379 return err;
15380 }
15381 return 0;
15382}
15383
15384/* parse the BIOS configuration and set up the alc_spec
15385 * return 1 if successful, 0 if the proper config is not found,
15386 * or a negative error code
15387 * Based on ALC880 version - had to change it to override
15388 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
15389static int alc861vd_parse_auto_config(struct hda_codec *codec)
15390{
15391 struct alc_spec *spec = codec->spec;
15392 int err;
15393 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
15394
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015395 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15396 alc861vd_ignore);
15397 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015398 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015399 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015400 return 0; /* can't find valid BIOS pin config */
15401
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015402 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
15403 if (err < 0)
15404 return err;
15405 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
15406 if (err < 0)
15407 return err;
15408 err = alc861vd_auto_create_extra_out(spec,
15409 spec->autocfg.speaker_pins[0],
15410 "Speaker");
15411 if (err < 0)
15412 return err;
15413 err = alc861vd_auto_create_extra_out(spec,
15414 spec->autocfg.hp_pins[0],
15415 "Headphone");
15416 if (err < 0)
15417 return err;
15418 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
15419 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015420 return err;
15421
15422 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15423
Takashi Iwai0852d7a2009-02-11 11:35:15 +010015424 if (spec->autocfg.dig_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015425 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
15426
Takashi Iwai603c4012008-07-30 15:01:44 +020015427 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010015428 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015429
Takashi Iwaid88897e2008-10-31 15:01:37 +010015430 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015431
15432 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015433 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015434
Takashi Iwai776e1842007-08-29 15:07:11 +020015435 err = alc_auto_add_mic_boost(codec);
15436 if (err < 0)
15437 return err;
15438
Takashi Iwai4a79ba32009-04-22 16:31:35 +020015439 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
15440
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015441 return 1;
15442}
15443
15444/* additional initialization for auto-configuration model */
15445static void alc861vd_auto_init(struct hda_codec *codec)
15446{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015447 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015448 alc861vd_auto_init_multi_out(codec);
15449 alc861vd_auto_init_hp_out(codec);
15450 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020015451 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015452 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020015453 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015454}
15455
15456static int patch_alc861vd(struct hda_codec *codec)
15457{
15458 struct alc_spec *spec;
15459 int err, board_config;
15460
15461 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15462 if (spec == NULL)
15463 return -ENOMEM;
15464
15465 codec->spec = spec;
15466
15467 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
15468 alc861vd_models,
15469 alc861vd_cfg_tbl);
15470
15471 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020015472 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
15473 codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015474 board_config = ALC861VD_AUTO;
15475 }
15476
15477 if (board_config == ALC861VD_AUTO) {
15478 /* automatic parse from the BIOS config */
15479 err = alc861vd_parse_auto_config(codec);
15480 if (err < 0) {
15481 alc_free(codec);
15482 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015483 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015484 printk(KERN_INFO
15485 "hda_codec: Cannot set up configuration "
15486 "from BIOS. Using base mode...\n");
15487 board_config = ALC861VD_3ST;
15488 }
15489 }
15490
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015491 err = snd_hda_attach_beep_device(codec, 0x23);
15492 if (err < 0) {
15493 alc_free(codec);
15494 return err;
15495 }
15496
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015497 if (board_config != ALC861VD_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020015498 setup_preset(codec, &alc861vd_presets[board_config]);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015499
Kailang Yang2f893282008-05-27 12:14:47 +020015500 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020015501 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010015502 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020015503 }
15504
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015505 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
15506 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
15507
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015508 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
15509 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
15510
Takashi Iwaidd704692009-08-11 08:45:11 +020015511 if (!spec->adc_nids) {
15512 spec->adc_nids = alc861vd_adc_nids;
15513 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
15514 }
15515 if (!spec->capsrc_nids)
15516 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015517
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015518 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015519 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015520
Takashi Iwai2134ea42008-01-10 16:53:55 +010015521 spec->vmaster_nid = 0x02;
15522
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015523 codec->patch_ops = alc_patch_ops;
15524
15525 if (board_config == ALC861VD_AUTO)
15526 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015527#ifdef CONFIG_SND_HDA_POWER_SAVE
15528 if (!spec->loopback.amplist)
15529 spec->loopback.amplist = alc861vd_loopbacks;
15530#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010015531 codec->proc_widget_hook = print_realtek_coef;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015532
15533 return 0;
15534}
15535
15536/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015537 * ALC662 support
15538 *
15539 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
15540 * configuration. Each pin widget can choose any input DACs and a mixer.
15541 * Each ADC is connected from a mixer of all inputs. This makes possible
15542 * 6-channel independent captures.
15543 *
15544 * In addition, an independent DAC for the multi-playback (not used in this
15545 * driver yet).
15546 */
15547#define ALC662_DIGOUT_NID 0x06
15548#define ALC662_DIGIN_NID 0x0a
15549
15550static hda_nid_t alc662_dac_nids[4] = {
15551 /* front, rear, clfe, rear_surr */
15552 0x02, 0x03, 0x04
15553};
15554
Kailang Yang622e84c2009-04-21 07:39:04 +020015555static hda_nid_t alc272_dac_nids[2] = {
15556 0x02, 0x03
15557};
15558
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015559static hda_nid_t alc662_adc_nids[2] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015560 /* ADC1-2 */
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015561 0x09, 0x08
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015562};
Takashi Iwaie1406342008-02-11 18:32:32 +010015563
Kailang Yang622e84c2009-04-21 07:39:04 +020015564static hda_nid_t alc272_adc_nids[1] = {
15565 /* ADC1-2 */
15566 0x08,
15567};
15568
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015569static hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
Kailang Yang622e84c2009-04-21 07:39:04 +020015570static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
15571
Takashi Iwaie1406342008-02-11 18:32:32 +010015572
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015573/* input MUX */
15574/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015575static struct hda_input_mux alc662_capture_source = {
15576 .num_items = 4,
15577 .items = {
15578 { "Mic", 0x0 },
15579 { "Front Mic", 0x1 },
15580 { "Line", 0x2 },
15581 { "CD", 0x4 },
15582 },
15583};
15584
15585static struct hda_input_mux alc662_lenovo_101e_capture_source = {
15586 .num_items = 2,
15587 .items = {
15588 { "Mic", 0x1 },
15589 { "Line", 0x2 },
15590 },
15591};
Kailang Yang291702f2007-10-16 14:28:03 +020015592
Kailang Yang6dda9f42008-05-27 12:05:31 +020015593static struct hda_input_mux alc663_capture_source = {
15594 .num_items = 3,
15595 .items = {
15596 { "Mic", 0x0 },
15597 { "Front Mic", 0x1 },
15598 { "Line", 0x2 },
15599 },
15600};
15601
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015602#if 0 /* set to 1 for testing other input sources below */
Chris Pockelé9541ba12009-05-12 08:08:53 +020015603static struct hda_input_mux alc272_nc10_capture_source = {
15604 .num_items = 16,
15605 .items = {
15606 { "Autoselect Mic", 0x0 },
15607 { "Internal Mic", 0x1 },
15608 { "In-0x02", 0x2 },
15609 { "In-0x03", 0x3 },
15610 { "In-0x04", 0x4 },
15611 { "In-0x05", 0x5 },
15612 { "In-0x06", 0x6 },
15613 { "In-0x07", 0x7 },
15614 { "In-0x08", 0x8 },
15615 { "In-0x09", 0x9 },
15616 { "In-0x0a", 0x0a },
15617 { "In-0x0b", 0x0b },
15618 { "In-0x0c", 0x0c },
15619 { "In-0x0d", 0x0d },
15620 { "In-0x0e", 0x0e },
15621 { "In-0x0f", 0x0f },
15622 },
15623};
15624#endif
15625
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015626/*
15627 * 2ch mode
15628 */
15629static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
15630 { 2, NULL }
15631};
15632
15633/*
15634 * 2ch mode
15635 */
15636static struct hda_verb alc662_3ST_ch2_init[] = {
15637 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
15638 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15639 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
15640 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15641 { } /* end */
15642};
15643
15644/*
15645 * 6ch mode
15646 */
15647static struct hda_verb alc662_3ST_ch6_init[] = {
15648 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15649 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15650 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
15651 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15652 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15653 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
15654 { } /* end */
15655};
15656
15657static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
15658 { 2, alc662_3ST_ch2_init },
15659 { 6, alc662_3ST_ch6_init },
15660};
15661
15662/*
15663 * 2ch mode
15664 */
15665static struct hda_verb alc662_sixstack_ch6_init[] = {
15666 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15667 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15668 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15669 { } /* end */
15670};
15671
15672/*
15673 * 6ch mode
15674 */
15675static struct hda_verb alc662_sixstack_ch8_init[] = {
15676 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15677 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15678 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15679 { } /* end */
15680};
15681
15682static struct hda_channel_mode alc662_5stack_modes[2] = {
15683 { 2, alc662_sixstack_ch6_init },
15684 { 6, alc662_sixstack_ch8_init },
15685};
15686
15687/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15688 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15689 */
15690
15691static struct snd_kcontrol_new alc662_base_mixer[] = {
15692 /* output mixer control */
15693 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015694 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015695 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015696 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015697 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15698 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015699 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15700 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015701 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15702
15703 /*Input mixer control */
15704 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
15705 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
15706 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
15707 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
15708 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
15709 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
15710 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
15711 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015712 { } /* end */
15713};
15714
15715static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
15716 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015717 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015718 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15719 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15720 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15721 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15722 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15723 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15724 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15725 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15726 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015727 { } /* end */
15728};
15729
15730static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
15731 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015732 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015733 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015734 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015735 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15736 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015737 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15738 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015739 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15740 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15741 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15742 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15743 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15744 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15745 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15746 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15747 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015748 { } /* end */
15749};
15750
15751static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
15752 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15753 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010015754 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15755 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015756 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15757 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15758 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15759 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15760 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015761 { } /* end */
15762};
15763
Kailang Yang291702f2007-10-16 14:28:03 +020015764static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020015765 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15766 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020015767
15768 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
15769 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15770 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15771
15772 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
15773 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15774 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15775 { } /* end */
15776};
15777
Kailang Yang8c427222008-01-10 13:03:59 +010015778static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020015779 ALC262_HIPPO_MASTER_SWITCH,
15780 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015781 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015782 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15783 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015784 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
15785 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15786 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15787 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15788 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15789 { } /* end */
15790};
15791
Kailang Yangf1d4e282008-08-26 14:03:29 +020015792static struct hda_bind_ctls alc663_asus_bind_master_vol = {
15793 .ops = &snd_hda_bind_vol,
15794 .values = {
15795 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15796 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
15797 0
15798 },
15799};
15800
15801static struct hda_bind_ctls alc663_asus_one_bind_switch = {
15802 .ops = &snd_hda_bind_sw,
15803 .values = {
15804 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15805 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15806 0
15807 },
15808};
15809
Kailang Yang6dda9f42008-05-27 12:05:31 +020015810static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015811 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15812 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
15813 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15814 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15815 { } /* end */
15816};
15817
15818static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
15819 .ops = &snd_hda_bind_sw,
15820 .values = {
15821 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15822 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15823 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15824 0
15825 },
15826};
15827
15828static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
15829 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15830 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
15831 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15832 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15833 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15834 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15835
15836 { } /* end */
15837};
15838
15839static struct hda_bind_ctls alc663_asus_four_bind_switch = {
15840 .ops = &snd_hda_bind_sw,
15841 .values = {
15842 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15843 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15844 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
15845 0
15846 },
15847};
15848
15849static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
15850 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15851 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
15852 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15853 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15854 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15855 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15856 { } /* end */
15857};
15858
15859static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020015860 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15861 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015862 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15863 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15864 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15865 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15866 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15867 { } /* end */
15868};
15869
15870static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
15871 .ops = &snd_hda_bind_vol,
15872 .values = {
15873 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15874 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
15875 0
15876 },
15877};
15878
15879static struct hda_bind_ctls alc663_asus_two_bind_switch = {
15880 .ops = &snd_hda_bind_sw,
15881 .values = {
15882 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15883 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
15884 0
15885 },
15886};
15887
15888static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
15889 HDA_BIND_VOL("Master Playback Volume",
15890 &alc663_asus_two_bind_master_vol),
15891 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15892 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015893 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15894 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15895 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015896 { } /* end */
15897};
15898
15899static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
15900 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15901 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15902 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15903 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15904 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15905 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015906 { } /* end */
15907};
15908
15909static struct snd_kcontrol_new alc663_g71v_mixer[] = {
15910 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15911 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15912 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15913 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15914 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15915
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("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15919 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15920 { } /* end */
15921};
15922
15923static struct snd_kcontrol_new alc663_g50v_mixer[] = {
15924 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15925 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15926 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15927
15928 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15929 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15930 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15931 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15932 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15933 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15934 { } /* end */
15935};
15936
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015937static struct snd_kcontrol_new alc662_chmode_mixer[] = {
15938 {
15939 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15940 .name = "Channel Mode",
15941 .info = alc_ch_mode_info,
15942 .get = alc_ch_mode_get,
15943 .put = alc_ch_mode_put,
15944 },
15945 { } /* end */
15946};
15947
15948static struct hda_verb alc662_init_verbs[] = {
15949 /* ADC: mute amp left and right */
15950 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15951 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15952 /* Front mixer: unmute input/output amp left and right (volume = 0) */
15953
Takashi Iwaicb53c622007-08-10 17:21:45 +020015954 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15955 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15956 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15957 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15958 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015959
Kailang Yangb60dd392007-09-20 12:50:29 +020015960 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15961 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15962 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15963 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15964 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15965 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015966
15967 /* Front Pin: output 0 (0x0c) */
15968 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15969 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15970
15971 /* Rear Pin: output 1 (0x0d) */
15972 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15973 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15974
15975 /* CLFE Pin: output 2 (0x0e) */
15976 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15977 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15978
15979 /* Mic (rear) pin: input vref at 80% */
15980 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15981 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15982 /* Front Mic pin: input vref at 80% */
15983 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15984 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15985 /* Line In pin: input */
15986 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15987 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15988 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15989 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15990 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15991 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15992 /* CD pin widget for input */
15993 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15994
15995 /* FIXME: use matrix-type input source selection */
15996 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15997 /* Input mixer */
15998 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020015999 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016000
16001 /* always trun on EAPD */
16002 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16003 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
16004
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016005 { }
16006};
16007
16008static struct hda_verb alc662_sue_init_verbs[] = {
16009 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16010 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020016011 {}
16012};
16013
16014static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
16015 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16016 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16017 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016018};
16019
Kailang Yang8c427222008-01-10 13:03:59 +010016020/* Set Unsolicited Event*/
16021static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
16022 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16023 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16024 {}
16025};
16026
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016027/*
16028 * generic initialization of ADC, input mixers and output mixers
16029 */
16030static struct hda_verb alc662_auto_init_verbs[] = {
16031 /*
16032 * Unmute ADC and set the default input to mic-in
16033 */
16034 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16035 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16036
16037 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
16038 * mixer widget
16039 * Note: PASD motherboards uses the Line In 2 as the input for front
16040 * panel mic (mic 2)
16041 */
16042 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020016043 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16044 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16045 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16046 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16047 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016048
16049 /*
16050 * Set up output mixers (0x0c - 0x0f)
16051 */
16052 /* set vol=0 to output mixers */
16053 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16054 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16055 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16056
16057 /* set up input amps for analog loopback */
16058 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020016059 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16060 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16061 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16062 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16063 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16064 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016065
16066
16067 /* FIXME: use matrix-type input source selection */
16068 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
16069 /* Input mixer */
16070 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020016071 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016072 { }
16073};
16074
Takashi Iwai24fb9172008-09-02 14:48:20 +020016075/* additional verbs for ALC663 */
16076static struct hda_verb alc663_auto_init_verbs[] = {
16077 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16078 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16079 { }
16080};
16081
Kailang Yang6dda9f42008-05-27 12:05:31 +020016082static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020016083 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16084 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016085 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16086 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020016087 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16088 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16089 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016090 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16091 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16092 {}
16093};
16094
Kailang Yangf1d4e282008-08-26 14:03:29 +020016095static struct hda_verb alc663_21jd_amic_init_verbs[] = {
16096 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16097 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16098 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16099 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16100 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16101 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16102 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16103 {}
16104};
16105
16106static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
16107 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16108 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16109 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16110 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16111 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16112 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16113 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16114 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16115 {}
16116};
16117
16118static struct hda_verb alc663_15jd_amic_init_verbs[] = {
16119 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16120 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16121 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16122 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16123 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16124 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16125 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16126 {}
16127};
16128
16129static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
16130 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16131 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16132 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16133 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16134 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16135 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16136 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16137 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16138 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16139 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16140 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16141 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16142 {}
16143};
16144
16145static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
16146 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16147 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16148 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16149 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16150 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16151 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16152 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16153 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16154 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16155 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16156 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16157 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16158 {}
16159};
16160
Kailang Yang6dda9f42008-05-27 12:05:31 +020016161static struct hda_verb alc663_g71v_init_verbs[] = {
16162 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16163 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
16164 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
16165
16166 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16167 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16168 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16169
16170 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16171 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
16172 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
16173 {}
16174};
16175
16176static struct hda_verb alc663_g50v_init_verbs[] = {
16177 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16178 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16179 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16180
16181 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16182 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16183 {}
16184};
16185
Kailang Yangf1d4e282008-08-26 14:03:29 +020016186static struct hda_verb alc662_ecs_init_verbs[] = {
16187 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
16188 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16189 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16190 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16191 {}
16192};
16193
Kailang Yang622e84c2009-04-21 07:39:04 +020016194static struct hda_verb alc272_dell_zm1_init_verbs[] = {
16195 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16196 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16197 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16198 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16199 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16200 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16201 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16202 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16203 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16204 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16205 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16206 {}
16207};
16208
16209static struct hda_verb alc272_dell_init_verbs[] = {
16210 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16211 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16212 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16213 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16214 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16215 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16216 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16217 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16218 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16219 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16220 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16221 {}
16222};
16223
Kailang Yangf1d4e282008-08-26 14:03:29 +020016224static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
16225 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
16226 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
16227 { } /* end */
16228};
16229
Kailang Yang622e84c2009-04-21 07:39:04 +020016230static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
16231 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
16232 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
16233 { } /* end */
16234};
16235
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016236static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
16237{
16238 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016239 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016240
16241 present = snd_hda_codec_read(codec, 0x14, 0,
16242 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020016243 bits = present ? HDA_AMP_MUTE : 0;
16244 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16245 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016246}
16247
16248static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
16249{
16250 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016251 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016252
16253 present = snd_hda_codec_read(codec, 0x1b, 0,
16254 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020016255 bits = present ? HDA_AMP_MUTE : 0;
16256 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16257 HDA_AMP_MUTE, bits);
16258 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16259 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016260}
16261
16262static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
16263 unsigned int res)
16264{
16265 if ((res >> 26) == ALC880_HP_EVENT)
16266 alc662_lenovo_101e_all_automute(codec);
16267 if ((res >> 26) == ALC880_FRONT_EVENT)
16268 alc662_lenovo_101e_ispeaker_automute(codec);
16269}
16270
Kailang Yang291702f2007-10-16 14:28:03 +020016271/* unsolicited event for HP jack sensing */
16272static void alc662_eeepc_unsol_event(struct hda_codec *codec,
16273 unsigned int res)
16274{
Kailang Yang291702f2007-10-16 14:28:03 +020016275 if ((res >> 26) == ALC880_MIC_EVENT)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016276 alc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020016277 else
16278 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020016279}
16280
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016281static void alc662_eeepc_setup(struct hda_codec *codec)
Kailang Yang291702f2007-10-16 14:28:03 +020016282{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016283 struct alc_spec *spec = codec->spec;
16284
16285 alc262_hippo1_setup(codec);
16286 spec->ext_mic.pin = 0x18;
16287 spec->ext_mic.mux_idx = 0;
16288 spec->int_mic.pin = 0x19;
16289 spec->int_mic.mux_idx = 1;
16290 spec->auto_mic = 1;
Kailang Yang291702f2007-10-16 14:28:03 +020016291}
16292
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016293static void alc662_eeepc_inithook(struct hda_codec *codec)
16294{
16295 alc262_hippo_automute(codec);
16296 alc_mic_automute(codec);
16297}
16298
16299static void alc662_eeepc_ep20_setup(struct hda_codec *codec)
Kailang Yang8c427222008-01-10 13:03:59 +010016300{
Takashi Iwai42171c12009-05-08 14:11:43 +020016301 struct alc_spec *spec = codec->spec;
16302
16303 spec->autocfg.hp_pins[0] = 0x14;
16304 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang8c427222008-01-10 13:03:59 +010016305}
16306
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016307#define alc662_eeepc_ep20_inithook alc262_hippo_master_update
16308
Kailang Yang6dda9f42008-05-27 12:05:31 +020016309static void alc663_m51va_speaker_automute(struct hda_codec *codec)
16310{
16311 unsigned int present;
16312 unsigned char bits;
16313
16314 present = snd_hda_codec_read(codec, 0x21, 0,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016315 AC_VERB_GET_PIN_SENSE, 0)
16316 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020016317 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020016318 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16319 AMP_IN_MUTE(0), bits);
16320 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16321 AMP_IN_MUTE(0), bits);
16322}
16323
16324static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
16325{
16326 unsigned int present;
16327 unsigned char bits;
16328
16329 present = snd_hda_codec_read(codec, 0x21, 0,
16330 AC_VERB_GET_PIN_SENSE, 0)
16331 & AC_PINSENSE_PRESENCE;
16332 bits = present ? HDA_AMP_MUTE : 0;
16333 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16334 AMP_IN_MUTE(0), bits);
16335 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16336 AMP_IN_MUTE(0), bits);
16337 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16338 AMP_IN_MUTE(0), bits);
16339 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16340 AMP_IN_MUTE(0), bits);
16341}
16342
16343static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
16344{
16345 unsigned int present;
16346 unsigned char bits;
16347
16348 present = snd_hda_codec_read(codec, 0x15, 0,
16349 AC_VERB_GET_PIN_SENSE, 0)
16350 & AC_PINSENSE_PRESENCE;
16351 bits = present ? HDA_AMP_MUTE : 0;
16352 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16353 AMP_IN_MUTE(0), bits);
16354 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16355 AMP_IN_MUTE(0), bits);
16356 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16357 AMP_IN_MUTE(0), bits);
16358 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16359 AMP_IN_MUTE(0), bits);
16360}
16361
16362static void alc662_f5z_speaker_automute(struct hda_codec *codec)
16363{
16364 unsigned int present;
16365 unsigned char bits;
16366
16367 present = snd_hda_codec_read(codec, 0x1b, 0,
16368 AC_VERB_GET_PIN_SENSE, 0)
16369 & AC_PINSENSE_PRESENCE;
16370 bits = present ? 0 : PIN_OUT;
16371 snd_hda_codec_write(codec, 0x14, 0,
16372 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
16373}
16374
16375static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
16376{
16377 unsigned int present1, present2;
16378
16379 present1 = snd_hda_codec_read(codec, 0x21, 0,
16380 AC_VERB_GET_PIN_SENSE, 0)
16381 & AC_PINSENSE_PRESENCE;
16382 present2 = snd_hda_codec_read(codec, 0x15, 0,
16383 AC_VERB_GET_PIN_SENSE, 0)
16384 & AC_PINSENSE_PRESENCE;
16385
16386 if (present1 || present2) {
16387 snd_hda_codec_write_cache(codec, 0x14, 0,
16388 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16389 } else {
16390 snd_hda_codec_write_cache(codec, 0x14, 0,
16391 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16392 }
16393}
16394
16395static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
16396{
16397 unsigned int present1, present2;
16398
16399 present1 = snd_hda_codec_read(codec, 0x1b, 0,
16400 AC_VERB_GET_PIN_SENSE, 0)
16401 & AC_PINSENSE_PRESENCE;
16402 present2 = snd_hda_codec_read(codec, 0x15, 0,
16403 AC_VERB_GET_PIN_SENSE, 0)
16404 & AC_PINSENSE_PRESENCE;
16405
16406 if (present1 || present2) {
16407 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16408 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16409 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16410 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16411 } else {
16412 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16413 AMP_IN_MUTE(0), 0);
16414 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16415 AMP_IN_MUTE(0), 0);
16416 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020016417}
16418
Kailang Yang6dda9f42008-05-27 12:05:31 +020016419static void alc663_m51va_unsol_event(struct hda_codec *codec,
16420 unsigned int res)
16421{
16422 switch (res >> 26) {
16423 case ALC880_HP_EVENT:
16424 alc663_m51va_speaker_automute(codec);
16425 break;
16426 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016427 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016428 break;
16429 }
16430}
16431
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016432static void alc663_m51va_setup(struct hda_codec *codec)
16433{
16434 struct alc_spec *spec = codec->spec;
16435 spec->ext_mic.pin = 0x18;
16436 spec->ext_mic.mux_idx = 0;
16437 spec->int_mic.pin = 0x12;
16438 spec->int_mic.mux_idx = 1;
16439 spec->auto_mic = 1;
16440}
16441
Kailang Yang6dda9f42008-05-27 12:05:31 +020016442static void alc663_m51va_inithook(struct hda_codec *codec)
16443{
16444 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016445 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016446}
16447
Kailang Yangf1d4e282008-08-26 14:03:29 +020016448/* ***************** Mode1 ******************************/
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016449#define alc663_mode1_unsol_event alc663_m51va_unsol_event
16450#define alc663_mode1_setup alc663_m51va_setup
16451#define alc663_mode1_inithook alc663_m51va_inithook
Kailang Yangf1d4e282008-08-26 14:03:29 +020016452
Kailang Yangf1d4e282008-08-26 14:03:29 +020016453/* ***************** Mode2 ******************************/
16454static void alc662_mode2_unsol_event(struct hda_codec *codec,
16455 unsigned int res)
16456{
16457 switch (res >> 26) {
16458 case ALC880_HP_EVENT:
16459 alc662_f5z_speaker_automute(codec);
16460 break;
16461 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016462 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016463 break;
16464 }
16465}
16466
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016467#define alc662_mode2_setup alc663_m51va_setup
16468
Kailang Yangf1d4e282008-08-26 14:03:29 +020016469static void alc662_mode2_inithook(struct hda_codec *codec)
16470{
16471 alc662_f5z_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016472 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016473}
16474/* ***************** Mode3 ******************************/
16475static void alc663_mode3_unsol_event(struct hda_codec *codec,
16476 unsigned int res)
16477{
16478 switch (res >> 26) {
16479 case ALC880_HP_EVENT:
16480 alc663_two_hp_m1_speaker_automute(codec);
16481 break;
16482 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016483 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016484 break;
16485 }
16486}
16487
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016488#define alc663_mode3_setup alc663_m51va_setup
16489
Kailang Yangf1d4e282008-08-26 14:03:29 +020016490static void alc663_mode3_inithook(struct hda_codec *codec)
16491{
16492 alc663_two_hp_m1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016493 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016494}
16495/* ***************** Mode4 ******************************/
16496static void alc663_mode4_unsol_event(struct hda_codec *codec,
16497 unsigned int res)
16498{
16499 switch (res >> 26) {
16500 case ALC880_HP_EVENT:
16501 alc663_21jd_two_speaker_automute(codec);
16502 break;
16503 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016504 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016505 break;
16506 }
16507}
16508
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016509#define alc663_mode4_setup alc663_m51va_setup
16510
Kailang Yangf1d4e282008-08-26 14:03:29 +020016511static void alc663_mode4_inithook(struct hda_codec *codec)
16512{
16513 alc663_21jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016514 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016515}
16516/* ***************** Mode5 ******************************/
16517static void alc663_mode5_unsol_event(struct hda_codec *codec,
16518 unsigned int res)
16519{
16520 switch (res >> 26) {
16521 case ALC880_HP_EVENT:
16522 alc663_15jd_two_speaker_automute(codec);
16523 break;
16524 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016525 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016526 break;
16527 }
16528}
16529
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016530#define alc663_mode5_setup alc663_m51va_setup
16531
Kailang Yangf1d4e282008-08-26 14:03:29 +020016532static void alc663_mode5_inithook(struct hda_codec *codec)
16533{
16534 alc663_15jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016535 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016536}
16537/* ***************** Mode6 ******************************/
16538static void alc663_mode6_unsol_event(struct hda_codec *codec,
16539 unsigned int res)
16540{
16541 switch (res >> 26) {
16542 case ALC880_HP_EVENT:
16543 alc663_two_hp_m2_speaker_automute(codec);
16544 break;
16545 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016546 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016547 break;
16548 }
16549}
16550
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016551#define alc663_mode6_setup alc663_m51va_setup
16552
Kailang Yangf1d4e282008-08-26 14:03:29 +020016553static void alc663_mode6_inithook(struct hda_codec *codec)
16554{
16555 alc663_two_hp_m2_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016556 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016557}
16558
Kailang Yang6dda9f42008-05-27 12:05:31 +020016559static void alc663_g71v_hp_automute(struct hda_codec *codec)
16560{
16561 unsigned int present;
16562 unsigned char bits;
16563
16564 present = snd_hda_codec_read(codec, 0x21, 0,
16565 AC_VERB_GET_PIN_SENSE, 0)
16566 & AC_PINSENSE_PRESENCE;
16567 bits = present ? HDA_AMP_MUTE : 0;
16568 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16569 HDA_AMP_MUTE, bits);
16570 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16571 HDA_AMP_MUTE, bits);
16572}
16573
16574static void alc663_g71v_front_automute(struct hda_codec *codec)
16575{
16576 unsigned int present;
16577 unsigned char bits;
16578
16579 present = snd_hda_codec_read(codec, 0x15, 0,
16580 AC_VERB_GET_PIN_SENSE, 0)
16581 & AC_PINSENSE_PRESENCE;
16582 bits = present ? HDA_AMP_MUTE : 0;
16583 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16584 HDA_AMP_MUTE, bits);
16585}
16586
16587static void alc663_g71v_unsol_event(struct hda_codec *codec,
16588 unsigned int res)
16589{
16590 switch (res >> 26) {
16591 case ALC880_HP_EVENT:
16592 alc663_g71v_hp_automute(codec);
16593 break;
16594 case ALC880_FRONT_EVENT:
16595 alc663_g71v_front_automute(codec);
16596 break;
16597 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016598 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016599 break;
16600 }
16601}
16602
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016603#define alc663_g71v_setup alc663_m51va_setup
16604
Kailang Yang6dda9f42008-05-27 12:05:31 +020016605static void alc663_g71v_inithook(struct hda_codec *codec)
16606{
16607 alc663_g71v_front_automute(codec);
16608 alc663_g71v_hp_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016609 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016610}
16611
16612static void alc663_g50v_unsol_event(struct hda_codec *codec,
16613 unsigned int res)
16614{
16615 switch (res >> 26) {
16616 case ALC880_HP_EVENT:
16617 alc663_m51va_speaker_automute(codec);
16618 break;
16619 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016620 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016621 break;
16622 }
16623}
16624
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016625#define alc663_g50v_setup alc663_m51va_setup
16626
Kailang Yang6dda9f42008-05-27 12:05:31 +020016627static void alc663_g50v_inithook(struct hda_codec *codec)
16628{
16629 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016630 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016631}
16632
Kailang Yangf1d4e282008-08-26 14:03:29 +020016633static struct snd_kcontrol_new alc662_ecs_mixer[] = {
16634 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020016635 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016636
16637 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
16638 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
16639 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
16640
16641 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16642 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16643 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16644 { } /* end */
16645};
16646
Chris Pockelé9541ba12009-05-12 08:08:53 +020016647static struct snd_kcontrol_new alc272_nc10_mixer[] = {
16648 /* Master Playback automatically created from Speaker and Headphone */
16649 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16650 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16651 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16652 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16653
16654 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16655 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16656 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
16657
16658 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16659 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16660 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
16661 { } /* end */
16662};
16663
Takashi Iwaicb53c622007-08-10 17:21:45 +020016664#ifdef CONFIG_SND_HDA_POWER_SAVE
16665#define alc662_loopbacks alc880_loopbacks
16666#endif
16667
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016668
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016669/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016670#define alc662_pcm_analog_playback alc880_pcm_analog_playback
16671#define alc662_pcm_analog_capture alc880_pcm_analog_capture
16672#define alc662_pcm_digital_playback alc880_pcm_digital_playback
16673#define alc662_pcm_digital_capture alc880_pcm_digital_capture
16674
16675/*
16676 * configuration and preset
16677 */
16678static const char *alc662_models[ALC662_MODEL_LAST] = {
16679 [ALC662_3ST_2ch_DIG] = "3stack-dig",
16680 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
16681 [ALC662_3ST_6ch] = "3stack-6ch",
16682 [ALC662_5ST_DIG] = "6stack-dig",
16683 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020016684 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010016685 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016686 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020016687 [ALC663_ASUS_M51VA] = "m51va",
16688 [ALC663_ASUS_G71V] = "g71v",
16689 [ALC663_ASUS_H13] = "h13",
16690 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016691 [ALC663_ASUS_MODE1] = "asus-mode1",
16692 [ALC662_ASUS_MODE2] = "asus-mode2",
16693 [ALC663_ASUS_MODE3] = "asus-mode3",
16694 [ALC663_ASUS_MODE4] = "asus-mode4",
16695 [ALC663_ASUS_MODE5] = "asus-mode5",
16696 [ALC663_ASUS_MODE6] = "asus-mode6",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020016697 [ALC272_DELL] = "dell",
16698 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020016699 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016700 [ALC662_AUTO] = "auto",
16701};
16702
16703static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010016704 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020016705 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
16706 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016707 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
16708 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
16709 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
16710 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
16711 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
16712 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
16713 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
16714 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
16715 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
16716 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
16717 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
16718 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016719 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
16720 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
16721 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016722 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
16723 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
16724 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
16725 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016726 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016727 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
16728 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016729 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016730 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
16731 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
16732 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020016733 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
16734 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
16735 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016736 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
16737 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
16738 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016739 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016740 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
16741 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020016742 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016743 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020016744 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016745 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
16746 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
16747 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016748 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016749 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
16750 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010016751 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020016752 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010016753 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016754 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030016755 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
16756 ALC662_3ST_6ch_DIG),
Chris Pockelé9541ba12009-05-12 08:08:53 +020016757 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030016758 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
16759 ALC662_3ST_6ch_DIG),
Vedran Miletic19c009a2008-09-29 20:29:25 +020016760 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020016761 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016762 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020016763 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020016764 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016765 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
16766 ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016767 {}
16768};
16769
16770static struct alc_config_preset alc662_presets[] = {
16771 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016772 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016773 .init_verbs = { alc662_init_verbs },
16774 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16775 .dac_nids = alc662_dac_nids,
16776 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016777 .dig_in_nid = ALC662_DIGIN_NID,
16778 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16779 .channel_mode = alc662_3ST_2ch_modes,
16780 .input_mux = &alc662_capture_source,
16781 },
16782 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016783 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016784 .init_verbs = { alc662_init_verbs },
16785 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16786 .dac_nids = alc662_dac_nids,
16787 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016788 .dig_in_nid = ALC662_DIGIN_NID,
16789 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16790 .channel_mode = alc662_3ST_6ch_modes,
16791 .need_dac_fix = 1,
16792 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016793 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016794 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016795 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016796 .init_verbs = { alc662_init_verbs },
16797 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16798 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016799 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16800 .channel_mode = alc662_3ST_6ch_modes,
16801 .need_dac_fix = 1,
16802 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016803 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016804 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016805 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016806 .init_verbs = { alc662_init_verbs },
16807 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16808 .dac_nids = alc662_dac_nids,
16809 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016810 .dig_in_nid = ALC662_DIGIN_NID,
16811 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
16812 .channel_mode = alc662_5stack_modes,
16813 .input_mux = &alc662_capture_source,
16814 },
16815 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016816 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016817 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
16818 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16819 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016820 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16821 .channel_mode = alc662_3ST_2ch_modes,
16822 .input_mux = &alc662_lenovo_101e_capture_source,
16823 .unsol_event = alc662_lenovo_101e_unsol_event,
16824 .init_hook = alc662_lenovo_101e_all_automute,
16825 },
Kailang Yang291702f2007-10-16 14:28:03 +020016826 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016827 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020016828 .init_verbs = { alc662_init_verbs,
16829 alc662_eeepc_sue_init_verbs },
16830 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16831 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020016832 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16833 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang291702f2007-10-16 14:28:03 +020016834 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016835 .setup = alc662_eeepc_setup,
Kailang Yang291702f2007-10-16 14:28:03 +020016836 .init_hook = alc662_eeepc_inithook,
16837 },
Kailang Yang8c427222008-01-10 13:03:59 +010016838 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016839 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010016840 alc662_chmode_mixer },
16841 .init_verbs = { alc662_init_verbs,
16842 alc662_eeepc_ep20_sue_init_verbs },
16843 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16844 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010016845 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16846 .channel_mode = alc662_3ST_6ch_modes,
16847 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020016848 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016849 .setup = alc662_eeepc_ep20_setup,
Kailang Yang8c427222008-01-10 13:03:59 +010016850 .init_hook = alc662_eeepc_ep20_inithook,
16851 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016852 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016853 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016854 .init_verbs = { alc662_init_verbs,
16855 alc662_ecs_init_verbs },
16856 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16857 .dac_nids = alc662_dac_nids,
16858 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16859 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016860 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016861 .setup = alc662_eeepc_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016862 .init_hook = alc662_eeepc_inithook,
16863 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016864 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016865 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016866 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16867 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16868 .dac_nids = alc662_dac_nids,
16869 .dig_out_nid = ALC662_DIGOUT_NID,
16870 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16871 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020016872 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016873 .setup = alc663_m51va_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020016874 .init_hook = alc663_m51va_inithook,
16875 },
16876 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016877 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016878 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
16879 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16880 .dac_nids = alc662_dac_nids,
16881 .dig_out_nid = ALC662_DIGOUT_NID,
16882 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16883 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020016884 .unsol_event = alc663_g71v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016885 .setup = alc663_g71v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020016886 .init_hook = alc663_g71v_inithook,
16887 },
16888 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016889 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016890 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16891 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16892 .dac_nids = alc662_dac_nids,
16893 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16894 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020016895 .unsol_event = alc663_m51va_unsol_event,
16896 .init_hook = alc663_m51va_inithook,
16897 },
16898 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016899 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016900 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
16901 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16902 .dac_nids = alc662_dac_nids,
16903 .dig_out_nid = ALC662_DIGOUT_NID,
16904 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16905 .channel_mode = alc662_3ST_6ch_modes,
16906 .input_mux = &alc663_capture_source,
16907 .unsol_event = alc663_g50v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016908 .setup = alc663_g50v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020016909 .init_hook = alc663_g50v_inithook,
16910 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016911 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016912 .mixers = { alc663_m51va_mixer },
16913 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016914 .init_verbs = { alc662_init_verbs,
16915 alc663_21jd_amic_init_verbs },
16916 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16917 .hp_nid = 0x03,
16918 .dac_nids = alc662_dac_nids,
16919 .dig_out_nid = ALC662_DIGOUT_NID,
16920 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16921 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016922 .unsol_event = alc663_mode1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016923 .setup = alc663_mode1_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016924 .init_hook = alc663_mode1_inithook,
16925 },
16926 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016927 .mixers = { alc662_1bjd_mixer },
16928 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016929 .init_verbs = { alc662_init_verbs,
16930 alc662_1bjd_amic_init_verbs },
16931 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16932 .dac_nids = alc662_dac_nids,
16933 .dig_out_nid = ALC662_DIGOUT_NID,
16934 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16935 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016936 .unsol_event = alc662_mode2_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016937 .setup = alc662_mode2_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016938 .init_hook = alc662_mode2_inithook,
16939 },
16940 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016941 .mixers = { alc663_two_hp_m1_mixer },
16942 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016943 .init_verbs = { alc662_init_verbs,
16944 alc663_two_hp_amic_m1_init_verbs },
16945 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16946 .hp_nid = 0x03,
16947 .dac_nids = alc662_dac_nids,
16948 .dig_out_nid = ALC662_DIGOUT_NID,
16949 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16950 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016951 .unsol_event = alc663_mode3_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016952 .setup = alc663_mode3_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016953 .init_hook = alc663_mode3_inithook,
16954 },
16955 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016956 .mixers = { alc663_asus_21jd_clfe_mixer },
16957 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016958 .init_verbs = { alc662_init_verbs,
16959 alc663_21jd_amic_init_verbs},
16960 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16961 .hp_nid = 0x03,
16962 .dac_nids = alc662_dac_nids,
16963 .dig_out_nid = ALC662_DIGOUT_NID,
16964 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16965 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016966 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016967 .setup = alc663_mode4_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016968 .init_hook = alc663_mode4_inithook,
16969 },
16970 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016971 .mixers = { alc663_asus_15jd_clfe_mixer },
16972 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016973 .init_verbs = { alc662_init_verbs,
16974 alc663_15jd_amic_init_verbs },
16975 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16976 .hp_nid = 0x03,
16977 .dac_nids = alc662_dac_nids,
16978 .dig_out_nid = ALC662_DIGOUT_NID,
16979 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16980 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016981 .unsol_event = alc663_mode5_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016982 .setup = alc663_mode5_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016983 .init_hook = alc663_mode5_inithook,
16984 },
16985 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016986 .mixers = { alc663_two_hp_m2_mixer },
16987 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016988 .init_verbs = { alc662_init_verbs,
16989 alc663_two_hp_amic_m2_init_verbs },
16990 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16991 .hp_nid = 0x03,
16992 .dac_nids = alc662_dac_nids,
16993 .dig_out_nid = ALC662_DIGOUT_NID,
16994 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16995 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016996 .unsol_event = alc663_mode6_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016997 .setup = alc663_mode6_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016998 .init_hook = alc663_mode6_inithook,
16999 },
Kailang Yang622e84c2009-04-21 07:39:04 +020017000 [ALC272_DELL] = {
17001 .mixers = { alc663_m51va_mixer },
17002 .cap_mixer = alc272_auto_capture_mixer,
17003 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
17004 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17005 .dac_nids = alc662_dac_nids,
17006 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17007 .adc_nids = alc272_adc_nids,
17008 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
17009 .capsrc_nids = alc272_capsrc_nids,
17010 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020017011 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017012 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020017013 .init_hook = alc663_m51va_inithook,
17014 },
17015 [ALC272_DELL_ZM1] = {
17016 .mixers = { alc663_m51va_mixer },
17017 .cap_mixer = alc662_auto_capture_mixer,
17018 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
17019 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17020 .dac_nids = alc662_dac_nids,
17021 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17022 .adc_nids = alc662_adc_nids,
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017023 .num_adc_nids = 1,
Kailang Yang622e84c2009-04-21 07:39:04 +020017024 .capsrc_nids = alc662_capsrc_nids,
17025 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020017026 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017027 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020017028 .init_hook = alc663_m51va_inithook,
17029 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020017030 [ALC272_SAMSUNG_NC10] = {
17031 .mixers = { alc272_nc10_mixer },
17032 .init_verbs = { alc662_init_verbs,
17033 alc663_21jd_amic_init_verbs },
17034 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17035 .dac_nids = alc272_dac_nids,
17036 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17037 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017038 /*.input_mux = &alc272_nc10_capture_source,*/
Chris Pockelé9541ba12009-05-12 08:08:53 +020017039 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017040 .setup = alc663_mode4_setup,
Chris Pockelé9541ba12009-05-12 08:08:53 +020017041 .init_hook = alc663_mode4_inithook,
17042 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017043};
17044
17045
17046/*
17047 * BIOS auto configuration
17048 */
17049
17050/* add playback controls from the parsed DAC table */
17051static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
17052 const struct auto_pin_cfg *cfg)
17053{
17054 char name[32];
17055 static const char *chname[4] = {
17056 "Front", "Surround", NULL /*CLFE*/, "Side"
17057 };
17058 hda_nid_t nid;
17059 int i, err;
17060
17061 for (i = 0; i < cfg->line_outs; i++) {
17062 if (!spec->multiout.dac_nids[i])
17063 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020017064 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017065 if (i == 2) {
17066 /* Center/LFE */
17067 err = add_control(spec, ALC_CTL_WIDGET_VOL,
17068 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017069 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
17070 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017071 if (err < 0)
17072 return err;
17073 err = add_control(spec, ALC_CTL_WIDGET_VOL,
17074 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017075 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
17076 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017077 if (err < 0)
17078 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017079 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017080 "Center Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017081 HDA_COMPOSE_AMP_VAL(0x0e, 1, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017082 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017083 if (err < 0)
17084 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017085 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017086 "LFE Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017087 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017088 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017089 if (err < 0)
17090 return err;
17091 } else {
17092 sprintf(name, "%s Playback Volume", chname[i]);
17093 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017094 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
17095 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017096 if (err < 0)
17097 return err;
17098 sprintf(name, "%s Playback Switch", chname[i]);
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017099 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
17100 HDA_COMPOSE_AMP_VAL(alc880_idx_to_mixer(i),
17101 3, 0, HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017102 if (err < 0)
17103 return err;
17104 }
17105 }
17106 return 0;
17107}
17108
17109/* add playback controls for speaker and HP outputs */
17110static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
17111 const char *pfx)
17112{
17113 hda_nid_t nid;
17114 int err;
17115 char name[32];
17116
17117 if (!pin)
17118 return 0;
17119
Takashi Iwai24fb9172008-09-02 14:48:20 +020017120 if (pin == 0x17) {
17121 /* ALC663 has a mono output pin on 0x17 */
17122 sprintf(name, "%s Playback Switch", pfx);
17123 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
17124 HDA_COMPOSE_AMP_VAL(pin, 2, 0, HDA_OUTPUT));
17125 return err;
17126 }
17127
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017128 if (alc880_is_fixed_pin(pin)) {
17129 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai939778a2009-02-05 15:57:55 +010017130 /* printk(KERN_DEBUG "DAC nid=%x\n",nid); */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017131 /* specify the DAC as the extra output */
17132 if (!spec->multiout.hp_nid)
17133 spec->multiout.hp_nid = nid;
17134 else
17135 spec->multiout.extra_out_nid[0] = nid;
17136 /* control HP volume/switch on the output mixer amp */
17137 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
17138 sprintf(name, "%s Playback Volume", pfx);
17139 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
17140 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
17141 if (err < 0)
17142 return err;
17143 sprintf(name, "%s Playback Switch", pfx);
17144 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
17145 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
17146 if (err < 0)
17147 return err;
17148 } else if (alc880_is_multi_pin(pin)) {
17149 /* set manual connection */
17150 /* we have only a switch on HP-out PIN */
17151 sprintf(name, "%s Playback Switch", pfx);
17152 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
17153 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
17154 if (err < 0)
17155 return err;
17156 }
17157 return 0;
17158}
17159
Takashi Iwai2d864c42009-03-20 12:52:47 +010017160static int alc662_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
17161{
Takashi Iwai1327a322009-03-23 13:07:47 +010017162 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai2d864c42009-03-20 12:52:47 +010017163 return (pincap & AC_PINCAP_IN) != 0;
17164}
17165
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017166/* create playback/capture controls for input pins */
Takashi Iwai2d864c42009-03-20 12:52:47 +010017167static int alc662_auto_create_analog_input_ctls(struct hda_codec *codec,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017168 const struct auto_pin_cfg *cfg)
17169{
Takashi Iwai2d864c42009-03-20 12:52:47 +010017170 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017171 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017172 int i, err, idx;
17173
17174 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai2d864c42009-03-20 12:52:47 +010017175 if (alc662_is_input_pin(codec, cfg->input_pins[i])) {
Takashi Iwai6c819492009-08-10 18:47:44 +020017176 idx = get_connection_index(codec, 0x0b,
Takashi Iwai2d864c42009-03-20 12:52:47 +010017177 cfg->input_pins[i]);
17178 if (idx >= 0) {
17179 err = new_analog_input(spec, cfg->input_pins[i],
17180 auto_pin_cfg_labels[i],
17181 idx, 0x0b);
17182 if (err < 0)
17183 return err;
17184 }
Takashi Iwai6c819492009-08-10 18:47:44 +020017185 idx = get_connection_index(codec, 0x22,
Takashi Iwai2d864c42009-03-20 12:52:47 +010017186 cfg->input_pins[i]);
17187 if (idx >= 0) {
17188 imux->items[imux->num_items].label =
17189 auto_pin_cfg_labels[i];
17190 imux->items[imux->num_items].index = idx;
17191 imux->num_items++;
17192 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017193 }
17194 }
17195 return 0;
17196}
17197
17198static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
17199 hda_nid_t nid, int pin_type,
17200 int dac_idx)
17201{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017202 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017203 /* need the manual connection? */
17204 if (alc880_is_multi_pin(nid)) {
17205 struct alc_spec *spec = codec->spec;
17206 int idx = alc880_multi_pin_idx(nid);
17207 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
17208 AC_VERB_SET_CONNECT_SEL,
17209 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
17210 }
17211}
17212
17213static void alc662_auto_init_multi_out(struct hda_codec *codec)
17214{
17215 struct alc_spec *spec = codec->spec;
17216 int i;
17217
17218 for (i = 0; i <= HDA_SIDE; i++) {
17219 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017220 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017221 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017222 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017223 i);
17224 }
17225}
17226
17227static void alc662_auto_init_hp_out(struct hda_codec *codec)
17228{
17229 struct alc_spec *spec = codec->spec;
17230 hda_nid_t pin;
17231
17232 pin = spec->autocfg.hp_pins[0];
17233 if (pin) /* connect to front */
17234 /* use dac 0 */
17235 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017236 pin = spec->autocfg.speaker_pins[0];
17237 if (pin)
17238 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017239}
17240
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017241#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
17242
17243static void alc662_auto_init_analog_input(struct hda_codec *codec)
17244{
17245 struct alc_spec *spec = codec->spec;
17246 int i;
17247
17248 for (i = 0; i < AUTO_PIN_LAST; i++) {
17249 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai2d864c42009-03-20 12:52:47 +010017250 if (alc662_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010017251 alc_set_input_pin(codec, nid, i);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010017252 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010017253 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017254 snd_hda_codec_write(codec, nid, 0,
17255 AC_VERB_SET_AMP_GAIN_MUTE,
17256 AMP_OUT_MUTE);
17257 }
17258 }
17259}
17260
Takashi Iwaif511b012008-08-15 16:46:42 +020017261#define alc662_auto_init_input_src alc882_auto_init_input_src
17262
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017263static int alc662_parse_auto_config(struct hda_codec *codec)
17264{
17265 struct alc_spec *spec = codec->spec;
17266 int err;
17267 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
17268
17269 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
17270 alc662_ignore);
17271 if (err < 0)
17272 return err;
17273 if (!spec->autocfg.line_outs)
17274 return 0; /* can't find valid BIOS pin config */
17275
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017276 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
17277 if (err < 0)
17278 return err;
17279 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
17280 if (err < 0)
17281 return err;
17282 err = alc662_auto_create_extra_out(spec,
17283 spec->autocfg.speaker_pins[0],
17284 "Speaker");
17285 if (err < 0)
17286 return err;
17287 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
17288 "Headphone");
17289 if (err < 0)
17290 return err;
Takashi Iwai2d864c42009-03-20 12:52:47 +010017291 err = alc662_auto_create_analog_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017292 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017293 return err;
17294
17295 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
17296
Takashi Iwai0852d7a2009-02-11 11:35:15 +010017297 if (spec->autocfg.dig_outs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017298 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
17299
Takashi Iwai603c4012008-07-30 15:01:44 +020017300 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017301 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017302
17303 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017304 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020017305
Takashi Iwaid88897e2008-10-31 15:01:37 +010017306 add_verb(spec, alc662_auto_init_verbs);
Takashi Iwai24fb9172008-09-02 14:48:20 +020017307 if (codec->vendor_id == 0x10ec0663)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017308 add_verb(spec, alc663_auto_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020017309
17310 err = alc_auto_add_mic_boost(codec);
17311 if (err < 0)
17312 return err;
17313
Takashi Iwai4a79ba32009-04-22 16:31:35 +020017314 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
17315
Takashi Iwai8c87286f2007-06-19 12:11:16 +020017316 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017317}
17318
17319/* additional initialization for auto-configuration model */
17320static void alc662_auto_init(struct hda_codec *codec)
17321{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017322 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017323 alc662_auto_init_multi_out(codec);
17324 alc662_auto_init_hp_out(codec);
17325 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020017326 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017327 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020017328 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017329}
17330
17331static int patch_alc662(struct hda_codec *codec)
17332{
17333 struct alc_spec *spec;
17334 int err, board_config;
17335
17336 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
17337 if (!spec)
17338 return -ENOMEM;
17339
17340 codec->spec = spec;
17341
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020017342 alc_fix_pll_init(codec, 0x20, 0x04, 15);
17343
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017344 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
17345 alc662_models,
17346 alc662_cfg_tbl);
17347 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020017348 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
17349 codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017350 board_config = ALC662_AUTO;
17351 }
17352
17353 if (board_config == ALC662_AUTO) {
17354 /* automatic parse from the BIOS config */
17355 err = alc662_parse_auto_config(codec);
17356 if (err < 0) {
17357 alc_free(codec);
17358 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020017359 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017360 printk(KERN_INFO
17361 "hda_codec: Cannot set up configuration "
17362 "from BIOS. Using base mode...\n");
17363 board_config = ALC662_3ST_2ch_DIG;
17364 }
17365 }
17366
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090017367 err = snd_hda_attach_beep_device(codec, 0x1);
17368 if (err < 0) {
17369 alc_free(codec);
17370 return err;
17371 }
17372
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017373 if (board_config != ALC662_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020017374 setup_preset(codec, &alc662_presets[board_config]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017375
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017376 spec->stream_analog_playback = &alc662_pcm_analog_playback;
17377 spec->stream_analog_capture = &alc662_pcm_analog_capture;
17378
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017379 spec->stream_digital_playback = &alc662_pcm_digital_playback;
17380 spec->stream_digital_capture = &alc662_pcm_digital_capture;
17381
Takashi Iwaidd704692009-08-11 08:45:11 +020017382 if (!spec->adc_nids) {
17383 spec->adc_nids = alc662_adc_nids;
17384 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
17385 }
17386 if (!spec->capsrc_nids)
17387 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017388
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017389 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017390 set_capture_mixer(codec);
Takashi Iwaib9591442009-03-16 15:25:00 +010017391 if (codec->vendor_id == 0x10ec0662)
17392 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
17393 else
17394 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017395
Takashi Iwai2134ea42008-01-10 16:53:55 +010017396 spec->vmaster_nid = 0x02;
17397
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017398 codec->patch_ops = alc_patch_ops;
17399 if (board_config == ALC662_AUTO)
17400 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020017401#ifdef CONFIG_SND_HDA_POWER_SAVE
17402 if (!spec->loopback.amplist)
17403 spec->loopback.amplist = alc662_loopbacks;
17404#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010017405 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017406
17407 return 0;
17408}
17409
17410/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070017411 * patch entries
17412 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017413static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070017414 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010017415 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017416 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020017417 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017418 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020017419 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017420 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017421 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017422 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
17423 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
17424 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017425 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017426 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017427 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
17428 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017429 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017430 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017431 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020017432 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +020017433 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017434 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020017435 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017436 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +010017437 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020017438 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 },
Kailang Yang44426082008-10-15 11:18:05 +020017439 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017440 .patch = patch_alc882 },
17441 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc882 },
17442 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017443 {} /* terminator */
17444};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017445
17446MODULE_ALIAS("snd-hda-codec-id:10ec*");
17447
17448MODULE_LICENSE("GPL");
17449MODULE_DESCRIPTION("Realtek HD-audio codec");
17450
17451static struct hda_codec_preset_list realtek_list = {
17452 .preset = snd_hda_preset_realtek,
17453 .owner = THIS_MODULE,
17454};
17455
17456static int __init patch_realtek_init(void)
17457{
17458 return snd_hda_add_codec_preset(&realtek_list);
17459}
17460
17461static void __exit patch_realtek_exit(void)
17462{
17463 snd_hda_delete_codec_preset(&realtek_list);
17464}
17465
17466module_init(patch_realtek_init)
17467module_exit(patch_realtek_exit)