blob: dd25db93677363f5e33d0217ee54867ae3f921dc [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),
Tony Vroon378bd6a2008-06-04 12:08:30 +020012410 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020012411 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012412 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012413 SND_PCI_QUIRK(0x1854, 0x1775, "LG R510", ALC268_DELL),
Kailang Yanga361d842007-06-05 12:30:55 +020012414 {}
12415};
12416
Takashi Iwai3abf2f32009-08-19 20:05:02 +020012417/* Toshiba laptops have no unique PCI SSID but only codec SSID */
12418static struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
12419 SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO),
12420 SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO),
12421 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
12422 ALC268_TOSHIBA),
12423 {}
12424};
12425
Kailang Yanga361d842007-06-05 12:30:55 +020012426static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012427 [ALC267_QUANTA_IL1] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012428 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer,
12429 alc268_capture_nosrc_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012430 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12431 alc267_quanta_il1_verbs },
12432 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12433 .dac_nids = alc268_dac_nids,
12434 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12435 .adc_nids = alc268_adc_nids_alt,
12436 .hp_nid = 0x03,
12437 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12438 .channel_mode = alc268_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012439 .unsol_event = alc_sku_unsol_event,
12440 .setup = alc267_quanta_il1_setup,
12441 .init_hook = alc_inithook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012442 },
Kailang Yanga361d842007-06-05 12:30:55 +020012443 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012444 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12445 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020012446 .init_verbs = { alc268_base_init_verbs },
12447 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12448 .dac_nids = alc268_dac_nids,
12449 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12450 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012451 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020012452 .hp_nid = 0x03,
12453 .dig_out_nid = ALC268_DIGOUT_NID,
12454 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12455 .channel_mode = alc268_modes,
12456 .input_mux = &alc268_capture_source,
12457 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012458 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012459 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012460 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012461 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12462 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012463 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12464 .dac_nids = alc268_dac_nids,
12465 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12466 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012467 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012468 .hp_nid = 0x03,
12469 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12470 .channel_mode = alc268_modes,
12471 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012472 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012473 .setup = alc268_toshiba_setup,
12474 .init_hook = alc268_toshiba_automute,
Takashi Iwaid2738092007-08-16 14:59:45 +020012475 },
12476 [ALC268_ACER] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012477 .mixers = { alc268_acer_mixer, alc268_capture_nosrc_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012478 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012479 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12480 alc268_acer_verbs },
12481 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12482 .dac_nids = alc268_dac_nids,
12483 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12484 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012485 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020012486 .hp_nid = 0x02,
12487 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12488 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012489 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012490 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020012491 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012492 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012493 [ALC268_ACER_DMIC] = {
12494 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
12495 alc268_beep_mixer },
12496 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12497 alc268_acer_verbs },
12498 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12499 .dac_nids = alc268_dac_nids,
12500 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12501 .adc_nids = alc268_adc_nids_alt,
12502 .capsrc_nids = alc268_capsrc_nids,
12503 .hp_nid = 0x02,
12504 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12505 .channel_mode = alc268_modes,
12506 .input_mux = &alc268_acer_dmic_capture_source,
12507 .unsol_event = alc268_acer_unsol_event,
12508 .init_hook = alc268_acer_init_hook,
12509 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012510 [ALC268_ACER_ASPIRE_ONE] = {
12511 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010012512 alc268_beep_mixer,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012513 alc268_capture_nosrc_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012514 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12515 alc268_acer_aspire_one_verbs },
12516 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12517 .dac_nids = alc268_dac_nids,
12518 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12519 .adc_nids = alc268_adc_nids_alt,
12520 .capsrc_nids = alc268_capsrc_nids,
12521 .hp_nid = 0x03,
12522 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12523 .channel_mode = alc268_modes,
Kailang Yang8ef355d2008-08-26 13:10:22 +020012524 .unsol_event = alc268_acer_lc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012525 .setup = alc268_acer_lc_setup,
Kailang Yang8ef355d2008-08-26 13:10:22 +020012526 .init_hook = alc268_acer_lc_init_hook,
12527 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012528 [ALC268_DELL] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012529 .mixers = { alc268_dell_mixer, alc268_beep_mixer,
12530 alc268_capture_nosrc_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012531 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12532 alc268_dell_verbs },
12533 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12534 .dac_nids = alc268_dac_nids,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012535 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12536 .adc_nids = alc268_adc_nids_alt,
12537 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012538 .hp_nid = 0x02,
12539 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12540 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012541 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012542 .setup = alc268_dell_setup,
12543 .init_hook = alc_inithook,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012544 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012545 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012546 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12547 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012548 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12549 alc268_toshiba_verbs },
12550 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12551 .dac_nids = alc268_dac_nids,
12552 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12553 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012554 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012555 .hp_nid = 0x03,
12556 .dig_out_nid = ALC268_DIGOUT_NID,
12557 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12558 .channel_mode = alc268_modes,
12559 .input_mux = &alc268_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012560 .setup = alc268_toshiba_setup,
12561 .init_hook = alc268_toshiba_automute,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012562 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012563#ifdef CONFIG_SND_DEBUG
12564 [ALC268_TEST] = {
12565 .mixers = { alc268_test_mixer, alc268_capture_mixer },
12566 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12567 alc268_volume_init_verbs },
12568 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12569 .dac_nids = alc268_dac_nids,
12570 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12571 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012572 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012573 .hp_nid = 0x03,
12574 .dig_out_nid = ALC268_DIGOUT_NID,
12575 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12576 .channel_mode = alc268_modes,
12577 .input_mux = &alc268_capture_source,
12578 },
12579#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012580};
12581
12582static int patch_alc268(struct hda_codec *codec)
12583{
12584 struct alc_spec *spec;
12585 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010012586 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020012587
12588 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
12589 if (spec == NULL)
12590 return -ENOMEM;
12591
12592 codec->spec = spec;
12593
12594 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
12595 alc268_models,
12596 alc268_cfg_tbl);
12597
Takashi Iwai3abf2f32009-08-19 20:05:02 +020012598 if (board_config < 0 || board_config >= ALC268_MODEL_LAST)
12599 board_config = snd_hda_check_board_codec_sid_config(codec,
12600 ALC882_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
12601
Kailang Yanga361d842007-06-05 12:30:55 +020012602 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020012603 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
12604 codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020012605 board_config = ALC268_AUTO;
12606 }
12607
12608 if (board_config == ALC268_AUTO) {
12609 /* automatic parse from the BIOS config */
12610 err = alc268_parse_auto_config(codec);
12611 if (err < 0) {
12612 alc_free(codec);
12613 return err;
12614 } else if (!err) {
12615 printk(KERN_INFO
12616 "hda_codec: Cannot set up configuration "
12617 "from BIOS. Using base mode...\n");
12618 board_config = ALC268_3ST;
12619 }
12620 }
12621
12622 if (board_config != ALC268_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020012623 setup_preset(codec, &alc268_presets[board_config]);
Kailang Yanga361d842007-06-05 12:30:55 +020012624
Kailang Yanga361d842007-06-05 12:30:55 +020012625 spec->stream_analog_playback = &alc268_pcm_analog_playback;
12626 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010012627 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020012628
Kailang Yanga361d842007-06-05 12:30:55 +020012629 spec->stream_digital_playback = &alc268_pcm_digital_playback;
12630
Takashi Iwai22971e32009-02-10 11:56:44 +010012631 has_beep = 0;
12632 for (i = 0; i < spec->num_mixers; i++) {
12633 if (spec->mixers[i] == alc268_beep_mixer) {
12634 has_beep = 1;
12635 break;
12636 }
12637 }
12638
12639 if (has_beep) {
12640 err = snd_hda_attach_beep_device(codec, 0x1);
12641 if (err < 0) {
12642 alc_free(codec);
12643 return err;
12644 }
12645 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
12646 /* override the amp caps for beep generator */
12647 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012648 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
12649 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
12650 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
12651 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010012652 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012653
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012654 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012655 /* check whether NID 0x07 is valid */
12656 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010012657 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020012658
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012659 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020012660 wcap = get_wcaps_type(wcap);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012661 if (spec->auto_mic ||
12662 wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012663 spec->adc_nids = alc268_adc_nids_alt;
12664 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012665 if (spec->auto_mic || spec->input_mux->num_items == 1)
12666 add_mixer(spec, alc268_capture_nosrc_mixer);
12667 else
12668 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012669 } else {
12670 spec->adc_nids = alc268_adc_nids;
12671 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012672 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020012673 }
Takashi Iwaie1406342008-02-11 18:32:32 +010012674 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai85860c02008-02-19 15:00:15 +010012675 /* set default input source */
12676 for (i = 0; i < spec->num_adc_nids; i++)
12677 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
12678 0, AC_VERB_SET_CONNECT_SEL,
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030012679 i < spec->num_mux_defs ?
12680 spec->input_mux[i].items[0].index :
Takashi Iwai85860c02008-02-19 15:00:15 +010012681 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020012682 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010012683
12684 spec->vmaster_nid = 0x02;
12685
Kailang Yanga361d842007-06-05 12:30:55 +020012686 codec->patch_ops = alc_patch_ops;
12687 if (board_config == ALC268_AUTO)
12688 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020012689
Takashi Iwaidaead532008-11-28 12:55:36 +010012690 codec->proc_widget_hook = print_realtek_coef;
12691
Kailang Yanga361d842007-06-05 12:30:55 +020012692 return 0;
12693}
12694
12695/*
Kailang Yangf6a92242007-12-13 16:52:54 +010012696 * ALC269 channel source setting (2 channel)
12697 */
12698#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
12699
12700#define alc269_dac_nids alc260_dac_nids
12701
12702static hda_nid_t alc269_adc_nids[1] = {
12703 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020012704 0x08,
12705};
12706
Takashi Iwaie01bf502008-08-21 16:25:07 +020012707static hda_nid_t alc269_capsrc_nids[1] = {
12708 0x23,
12709};
12710
12711/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
12712 * not a mux!
12713 */
12714
Kailang Yangf6a92242007-12-13 16:52:54 +010012715#define alc269_modes alc260_modes
12716#define alc269_capture_source alc880_lg_lw_capture_source
12717
12718static struct snd_kcontrol_new alc269_base_mixer[] = {
12719 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12720 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12721 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12722 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12723 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12724 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12725 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12726 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12727 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12728 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12729 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12730 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
12731 { } /* end */
12732};
12733
Kailang Yang60db6b52008-08-26 13:13:00 +020012734static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
12735 /* output mixer control */
12736 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12737 {
12738 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12739 .name = "Master Playback Switch",
12740 .info = snd_hda_mixer_amp_switch_info,
12741 .get = snd_hda_mixer_amp_switch_get,
12742 .put = alc268_acer_master_sw_put,
12743 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12744 },
12745 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12746 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12747 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12748 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12749 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12750 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020012751 { }
12752};
12753
Tony Vroon64154832008-11-06 15:08:49 +000012754static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
12755 /* output mixer control */
12756 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12757 {
12758 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12759 .name = "Master Playback Switch",
12760 .info = snd_hda_mixer_amp_switch_info,
12761 .get = snd_hda_mixer_amp_switch_get,
12762 .put = alc268_acer_master_sw_put,
12763 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12764 },
12765 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12766 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12767 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12768 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12769 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12770 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12771 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
12772 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
12773 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000012774 { }
12775};
12776
Kailang Yangf53281e2008-07-18 12:36:43 +020012777static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
Takashi Iwaiaa202452009-07-03 15:00:54 +020012778 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010012779 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwaiaa202452009-07-03 15:00:54 +020012780 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010012781 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yangf53281e2008-07-18 12:36:43 +020012782 { } /* end */
12783};
12784
Kailang Yangf6a92242007-12-13 16:52:54 +010012785/* capture mixer elements */
Kailang Yangf53281e2008-07-18 12:36:43 +020012786static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
12787 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12788 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012789 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12790 { } /* end */
12791};
12792
12793/* FSC amilo */
Takashi Iwaiaa202452009-07-03 15:00:54 +020012794#define alc269_fujitsu_mixer alc269_eeepc_mixer
Kailang Yangf53281e2008-07-18 12:36:43 +020012795
Kailang Yang60db6b52008-08-26 13:13:00 +020012796static struct hda_verb alc269_quanta_fl1_verbs[] = {
12797 {0x15, 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 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12802 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12803 { }
12804};
12805
Tony Vroon64154832008-11-06 15:08:49 +000012806static struct hda_verb alc269_lifebook_verbs[] = {
12807 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12808 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
12809 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12810 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12811 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12812 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12813 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12814 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12815 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12816 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12817 { }
12818};
12819
Kailang Yang60db6b52008-08-26 13:13:00 +020012820/* toggle speaker-output according to the hp-jack state */
12821static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
12822{
12823 unsigned int present;
12824 unsigned char bits;
12825
12826 present = snd_hda_codec_read(codec, 0x15, 0,
12827 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12828 bits = present ? AMP_IN_MUTE(0) : 0;
12829 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12830 AMP_IN_MUTE(0), bits);
12831 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12832 AMP_IN_MUTE(0), bits);
12833
12834 snd_hda_codec_write(codec, 0x20, 0,
12835 AC_VERB_SET_COEF_INDEX, 0x0c);
12836 snd_hda_codec_write(codec, 0x20, 0,
12837 AC_VERB_SET_PROC_COEF, 0x680);
12838
12839 snd_hda_codec_write(codec, 0x20, 0,
12840 AC_VERB_SET_COEF_INDEX, 0x0c);
12841 snd_hda_codec_write(codec, 0x20, 0,
12842 AC_VERB_SET_PROC_COEF, 0x480);
12843}
12844
Tony Vroon64154832008-11-06 15:08:49 +000012845/* toggle speaker-output according to the hp-jacks state */
12846static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
12847{
12848 unsigned int present;
12849 unsigned char bits;
12850
12851 /* Check laptop headphone socket */
12852 present = snd_hda_codec_read(codec, 0x15, 0,
12853 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12854
12855 /* Check port replicator headphone socket */
12856 present |= snd_hda_codec_read(codec, 0x1a, 0,
12857 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12858
12859 bits = present ? AMP_IN_MUTE(0) : 0;
12860 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12861 AMP_IN_MUTE(0), bits);
12862 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12863 AMP_IN_MUTE(0), bits);
12864
12865 snd_hda_codec_write(codec, 0x20, 0,
12866 AC_VERB_SET_COEF_INDEX, 0x0c);
12867 snd_hda_codec_write(codec, 0x20, 0,
12868 AC_VERB_SET_PROC_COEF, 0x680);
12869
12870 snd_hda_codec_write(codec, 0x20, 0,
12871 AC_VERB_SET_COEF_INDEX, 0x0c);
12872 snd_hda_codec_write(codec, 0x20, 0,
12873 AC_VERB_SET_PROC_COEF, 0x480);
12874}
12875
Tony Vroon64154832008-11-06 15:08:49 +000012876static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
12877{
12878 unsigned int present_laptop;
12879 unsigned int present_dock;
12880
12881 present_laptop = snd_hda_codec_read(codec, 0x18, 0,
12882 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12883
12884 present_dock = snd_hda_codec_read(codec, 0x1b, 0,
12885 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12886
12887 /* Laptop mic port overrides dock mic port, design decision */
12888 if (present_dock)
12889 snd_hda_codec_write(codec, 0x23, 0,
12890 AC_VERB_SET_CONNECT_SEL, 0x3);
12891 if (present_laptop)
12892 snd_hda_codec_write(codec, 0x23, 0,
12893 AC_VERB_SET_CONNECT_SEL, 0x0);
12894 if (!present_dock && !present_laptop)
12895 snd_hda_codec_write(codec, 0x23, 0,
12896 AC_VERB_SET_CONNECT_SEL, 0x1);
12897}
12898
Kailang Yang60db6b52008-08-26 13:13:00 +020012899static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
12900 unsigned int res)
12901{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012902 switch (res >> 26) {
12903 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020012904 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012905 break;
12906 case ALC880_MIC_EVENT:
12907 alc_mic_automute(codec);
12908 break;
12909 }
Kailang Yang60db6b52008-08-26 13:13:00 +020012910}
12911
Tony Vroon64154832008-11-06 15:08:49 +000012912static void alc269_lifebook_unsol_event(struct hda_codec *codec,
12913 unsigned int res)
12914{
12915 if ((res >> 26) == ALC880_HP_EVENT)
12916 alc269_lifebook_speaker_automute(codec);
12917 if ((res >> 26) == ALC880_MIC_EVENT)
12918 alc269_lifebook_mic_autoswitch(codec);
12919}
12920
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012921static void alc269_quanta_fl1_setup(struct hda_codec *codec)
12922{
12923 struct alc_spec *spec = codec->spec;
12924 spec->ext_mic.pin = 0x18;
12925 spec->ext_mic.mux_idx = 0;
12926 spec->int_mic.pin = 0x19;
12927 spec->int_mic.mux_idx = 1;
12928 spec->auto_mic = 1;
12929}
12930
Kailang Yang60db6b52008-08-26 13:13:00 +020012931static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
12932{
12933 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012934 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020012935}
12936
Tony Vroon64154832008-11-06 15:08:49 +000012937static void alc269_lifebook_init_hook(struct hda_codec *codec)
12938{
12939 alc269_lifebook_speaker_automute(codec);
12940 alc269_lifebook_mic_autoswitch(codec);
12941}
12942
Kailang Yang60db6b52008-08-26 13:13:00 +020012943static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
12944 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12945 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
12946 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12947 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
12948 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12949 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12950 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12951 {}
12952};
12953
12954static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
12955 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12956 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
12957 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12958 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
12959 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12960 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12961 {}
12962};
12963
12964/* toggle speaker-output according to the hp-jack state */
12965static void alc269_speaker_automute(struct hda_codec *codec)
12966{
12967 unsigned int present;
12968 unsigned char bits;
12969
12970 present = snd_hda_codec_read(codec, 0x15, 0,
12971 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12972 bits = present ? AMP_IN_MUTE(0) : 0;
12973 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12974 AMP_IN_MUTE(0), bits);
12975 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12976 AMP_IN_MUTE(0), bits);
12977}
12978
Kailang Yang60db6b52008-08-26 13:13:00 +020012979/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012980static void alc269_eeepc_unsol_event(struct hda_codec *codec,
Kailang Yang60db6b52008-08-26 13:13:00 +020012981 unsigned int res)
12982{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012983 switch (res >> 26) {
12984 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020012985 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012986 break;
12987 case ALC880_MIC_EVENT:
12988 alc_mic_automute(codec);
12989 break;
12990 }
Kailang Yang60db6b52008-08-26 13:13:00 +020012991}
12992
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012993static void alc269_eeepc_dmic_setup(struct hda_codec *codec)
12994{
12995 struct alc_spec *spec = codec->spec;
12996 spec->ext_mic.pin = 0x18;
12997 spec->ext_mic.mux_idx = 0;
12998 spec->int_mic.pin = 0x12;
12999 spec->int_mic.mux_idx = 5;
13000 spec->auto_mic = 1;
13001}
13002
13003static void alc269_eeepc_amic_setup(struct hda_codec *codec)
13004{
13005 struct alc_spec *spec = codec->spec;
13006 spec->ext_mic.pin = 0x18;
13007 spec->ext_mic.mux_idx = 0;
13008 spec->int_mic.pin = 0x19;
13009 spec->int_mic.mux_idx = 1;
13010 spec->auto_mic = 1;
13011}
13012
13013static void alc269_eeepc_inithook(struct hda_codec *codec)
Kailang Yang60db6b52008-08-26 13:13:00 +020013014{
13015 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013016 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020013017}
13018
Kailang Yangf6a92242007-12-13 16:52:54 +010013019/*
13020 * generic initialization of ADC, input mixers and output mixers
13021 */
13022static struct hda_verb alc269_init_verbs[] = {
13023 /*
13024 * Unmute ADC0 and set the default input to mic-in
13025 */
Kailang Yang60db6b52008-08-26 13:13:00 +020013026 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010013027
13028 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
13029 * analog-loopback mixer widget
13030 * Note: PASD motherboards uses the Line In 2 as the input for
13031 * front panel mic (mic 2)
13032 */
13033 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
13034 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13035 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13036 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13037 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13038 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
13039
13040 /*
13041 * Set up output mixers (0x0c - 0x0e)
13042 */
13043 /* set vol=0 to output mixers */
13044 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13045 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13046
13047 /* set up input amps for analog loopback */
13048 /* Amp Indices: DAC = 0, mixer = 1 */
13049 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13050 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13051 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13052 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13053 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13054 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13055
13056 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13057 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13058 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13059 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13060 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13061 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13062 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13063
13064 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13065 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13066 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13067 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13068 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13069 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13070 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13071
13072 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
13073 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
13074
13075 /* FIXME: use matrix-type input source selection */
13076 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
13077 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang60db6b52008-08-26 13:13:00 +020013078 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13079 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangf6a92242007-12-13 16:52:54 +010013080 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13081 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13082
13083 /* set EAPD */
13084 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13085 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
13086 { }
13087};
13088
Takashi Iwai9d0b71b2009-08-24 14:10:30 +020013089#define alc269_auto_create_multi_out_ctls \
13090 alc268_auto_create_multi_out_ctls
Takashi Iwai8c927b42009-06-22 10:56:54 +020013091#define alc269_auto_create_analog_input_ctls \
13092 alc262_auto_create_analog_input_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010013093
13094#ifdef CONFIG_SND_HDA_POWER_SAVE
13095#define alc269_loopbacks alc880_loopbacks
13096#endif
13097
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013098/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010013099#define alc269_pcm_analog_playback alc880_pcm_analog_playback
13100#define alc269_pcm_analog_capture alc880_pcm_analog_capture
13101#define alc269_pcm_digital_playback alc880_pcm_digital_playback
13102#define alc269_pcm_digital_capture alc880_pcm_digital_capture
13103
Takashi Iwaif03d3112009-03-05 14:18:16 +010013104static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
13105 .substreams = 1,
13106 .channels_min = 2,
13107 .channels_max = 8,
13108 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13109 /* NID is set in alc_build_pcms */
13110 .ops = {
13111 .open = alc880_playback_pcm_open,
13112 .prepare = alc880_playback_pcm_prepare,
13113 .cleanup = alc880_playback_pcm_cleanup
13114 },
13115};
13116
13117static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
13118 .substreams = 1,
13119 .channels_min = 2,
13120 .channels_max = 2,
13121 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13122 /* NID is set in alc_build_pcms */
13123};
13124
Kailang Yangf6a92242007-12-13 16:52:54 +010013125/*
13126 * BIOS auto configuration
13127 */
13128static int alc269_parse_auto_config(struct hda_codec *codec)
13129{
13130 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010013131 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010013132 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
13133
13134 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13135 alc269_ignore);
13136 if (err < 0)
13137 return err;
13138
13139 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
13140 if (err < 0)
13141 return err;
13142 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
13143 if (err < 0)
13144 return err;
13145
13146 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13147
Takashi Iwai0852d7a2009-02-11 11:35:15 +010013148 if (spec->autocfg.dig_outs)
Kailang Yangf6a92242007-12-13 16:52:54 +010013149 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
13150
Takashi Iwai603c4012008-07-30 15:01:44 +020013151 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013152 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010013153
Takashi Iwaid88897e2008-10-31 15:01:37 +010013154 add_verb(spec, alc269_init_verbs);
Kailang Yangf6a92242007-12-13 16:52:54 +010013155 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013156 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie01bf502008-08-21 16:25:07 +020013157 /* set default input source */
13158 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
13159 0, AC_VERB_SET_CONNECT_SEL,
13160 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010013161
13162 err = alc_auto_add_mic_boost(codec);
13163 if (err < 0)
13164 return err;
13165
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013166 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020013167 set_capture_mixer(codec);
Kailang Yangf53281e2008-07-18 12:36:43 +020013168
Takashi Iwai1d955eb2009-06-29 11:33:53 +020013169 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
13170
Kailang Yangf6a92242007-12-13 16:52:54 +010013171 return 1;
13172}
13173
13174#define alc269_auto_init_multi_out alc882_auto_init_multi_out
13175#define alc269_auto_init_hp_out alc882_auto_init_hp_out
13176#define alc269_auto_init_analog_input alc882_auto_init_analog_input
13177
13178
13179/* init callback for auto-configuration model -- overriding the default init */
13180static void alc269_auto_init(struct hda_codec *codec)
13181{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013182 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010013183 alc269_auto_init_multi_out(codec);
13184 alc269_auto_init_hp_out(codec);
13185 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013186 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013187 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010013188}
13189
13190/*
13191 * configuration and preset
13192 */
13193static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013194 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020013195 [ALC269_QUANTA_FL1] = "quanta",
13196 [ALC269_ASUS_EEEPC_P703] = "eeepc-p703",
Takashi Iwai26f5df22008-11-03 17:39:46 +010013197 [ALC269_ASUS_EEEPC_P901] = "eeepc-p901",
Tony Vroon64154832008-11-06 15:08:49 +000013198 [ALC269_FUJITSU] = "fujitsu",
13199 [ALC269_LIFEBOOK] = "lifebook"
Kailang Yangf6a92242007-12-13 16:52:54 +010013200};
13201
13202static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013203 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020013204 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
13205 ALC269_ASUS_EEEPC_P703),
Kailang Yang622e84c2009-04-21 07:39:04 +020013206 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_ASUS_EEEPC_P703),
13207 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_ASUS_EEEPC_P703),
13208 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_ASUS_EEEPC_P703),
13209 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_ASUS_EEEPC_P703),
13210 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_ASUS_EEEPC_P703),
13211 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_ASUS_EEEPC_P703),
Kailang Yangf53281e2008-07-18 12:36:43 +020013212 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
13213 ALC269_ASUS_EEEPC_P901),
Kailang Yang60db6b52008-08-26 13:13:00 +020013214 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
13215 ALC269_ASUS_EEEPC_P901),
Kailang Yang622e84c2009-04-21 07:39:04 +020013216 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_ASUS_EEEPC_P901),
Takashi Iwai26f5df22008-11-03 17:39:46 +010013217 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
Tony Vroon64154832008-11-06 15:08:49 +000013218 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yangf6a92242007-12-13 16:52:54 +010013219 {}
13220};
13221
13222static struct alc_config_preset alc269_presets[] = {
13223 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013224 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010013225 .init_verbs = { alc269_init_verbs },
13226 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13227 .dac_nids = alc269_dac_nids,
13228 .hp_nid = 0x03,
13229 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13230 .channel_mode = alc269_modes,
13231 .input_mux = &alc269_capture_source,
13232 },
Kailang Yang60db6b52008-08-26 13:13:00 +020013233 [ALC269_QUANTA_FL1] = {
13234 .mixers = { alc269_quanta_fl1_mixer },
13235 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
13236 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13237 .dac_nids = alc269_dac_nids,
13238 .hp_nid = 0x03,
13239 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13240 .channel_mode = alc269_modes,
13241 .input_mux = &alc269_capture_source,
13242 .unsol_event = alc269_quanta_fl1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013243 .setup = alc269_quanta_fl1_setup,
Kailang Yang60db6b52008-08-26 13:13:00 +020013244 .init_hook = alc269_quanta_fl1_init_hook,
13245 },
Kailang Yangf53281e2008-07-18 12:36:43 +020013246 [ALC269_ASUS_EEEPC_P703] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013247 .mixers = { alc269_eeepc_mixer },
13248 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013249 .init_verbs = { alc269_init_verbs,
13250 alc269_eeepc_amic_init_verbs },
13251 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13252 .dac_nids = alc269_dac_nids,
13253 .hp_nid = 0x03,
13254 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13255 .channel_mode = alc269_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013256 .unsol_event = alc269_eeepc_unsol_event,
13257 .setup = alc269_eeepc_amic_setup,
13258 .init_hook = alc269_eeepc_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020013259 },
13260 [ALC269_ASUS_EEEPC_P901] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013261 .mixers = { alc269_eeepc_mixer },
13262 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013263 .init_verbs = { alc269_init_verbs,
13264 alc269_eeepc_dmic_init_verbs },
13265 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13266 .dac_nids = alc269_dac_nids,
13267 .hp_nid = 0x03,
13268 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13269 .channel_mode = alc269_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013270 .unsol_event = alc269_eeepc_unsol_event,
13271 .setup = alc269_eeepc_dmic_setup,
13272 .init_hook = alc269_eeepc_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020013273 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013274 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013275 .mixers = { alc269_fujitsu_mixer },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013276 .cap_mixer = alc269_epc_capture_mixer,
13277 .init_verbs = { alc269_init_verbs,
13278 alc269_eeepc_dmic_init_verbs },
13279 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13280 .dac_nids = alc269_dac_nids,
13281 .hp_nid = 0x03,
13282 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13283 .channel_mode = alc269_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013284 .unsol_event = alc269_eeepc_unsol_event,
13285 .setup = alc269_eeepc_dmic_setup,
13286 .init_hook = alc269_eeepc_inithook,
Takashi Iwai26f5df22008-11-03 17:39:46 +010013287 },
Tony Vroon64154832008-11-06 15:08:49 +000013288 [ALC269_LIFEBOOK] = {
13289 .mixers = { alc269_lifebook_mixer },
13290 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
13291 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13292 .dac_nids = alc269_dac_nids,
13293 .hp_nid = 0x03,
13294 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13295 .channel_mode = alc269_modes,
13296 .input_mux = &alc269_capture_source,
13297 .unsol_event = alc269_lifebook_unsol_event,
13298 .init_hook = alc269_lifebook_init_hook,
13299 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013300};
13301
13302static int patch_alc269(struct hda_codec *codec)
13303{
13304 struct alc_spec *spec;
13305 int board_config;
13306 int err;
13307
13308 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13309 if (spec == NULL)
13310 return -ENOMEM;
13311
13312 codec->spec = spec;
13313
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020013314 alc_fix_pll_init(codec, 0x20, 0x04, 15);
13315
Kailang Yangf6a92242007-12-13 16:52:54 +010013316 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
13317 alc269_models,
13318 alc269_cfg_tbl);
13319
13320 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020013321 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
13322 codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010013323 board_config = ALC269_AUTO;
13324 }
13325
13326 if (board_config == ALC269_AUTO) {
13327 /* automatic parse from the BIOS config */
13328 err = alc269_parse_auto_config(codec);
13329 if (err < 0) {
13330 alc_free(codec);
13331 return err;
13332 } else if (!err) {
13333 printk(KERN_INFO
13334 "hda_codec: Cannot set up configuration "
13335 "from BIOS. Using base mode...\n");
13336 board_config = ALC269_BASIC;
13337 }
13338 }
13339
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090013340 err = snd_hda_attach_beep_device(codec, 0x1);
13341 if (err < 0) {
13342 alc_free(codec);
13343 return err;
13344 }
13345
Kailang Yangf6a92242007-12-13 16:52:54 +010013346 if (board_config != ALC269_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020013347 setup_preset(codec, &alc269_presets[board_config]);
Kailang Yangf6a92242007-12-13 16:52:54 +010013348
Takashi Iwaif03d3112009-03-05 14:18:16 +010013349 if (codec->subsystem_id == 0x17aa3bf8) {
13350 /* Due to a hardware problem on Lenovo Ideadpad, we need to
13351 * fix the sample rate of analog I/O to 44.1kHz
13352 */
13353 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
13354 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
13355 } else {
13356 spec->stream_analog_playback = &alc269_pcm_analog_playback;
13357 spec->stream_analog_capture = &alc269_pcm_analog_capture;
13358 }
Kailang Yangf6a92242007-12-13 16:52:54 +010013359 spec->stream_digital_playback = &alc269_pcm_digital_playback;
13360 spec->stream_digital_capture = &alc269_pcm_digital_capture;
13361
13362 spec->adc_nids = alc269_adc_nids;
13363 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
Takashi Iwaie01bf502008-08-21 16:25:07 +020013364 spec->capsrc_nids = alc269_capsrc_nids;
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013365 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020013366 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013367 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010013368
Takashi Iwai100d5eb2009-08-10 11:55:51 +020013369 spec->vmaster_nid = 0x02;
13370
Kailang Yangf6a92242007-12-13 16:52:54 +010013371 codec->patch_ops = alc_patch_ops;
13372 if (board_config == ALC269_AUTO)
13373 spec->init_hook = alc269_auto_init;
13374#ifdef CONFIG_SND_HDA_POWER_SAVE
13375 if (!spec->loopback.amplist)
13376 spec->loopback.amplist = alc269_loopbacks;
13377#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010013378 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010013379
13380 return 0;
13381}
13382
13383/*
Kailang Yangdf694da2005-12-05 19:42:22 +010013384 * ALC861 channel source setting (2/6 channel selection for 3-stack)
13385 */
13386
13387/*
13388 * set the path ways for 2 channel output
13389 * need to set the codec line out and mic 1 pin widgets to inputs
13390 */
13391static struct hda_verb alc861_threestack_ch2_init[] = {
13392 /* set pin widget 1Ah (line in) for input */
13393 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013394 /* set pin widget 18h (mic1/2) for input, for mic also enable
13395 * the vref
13396 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013397 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13398
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013399 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13400#if 0
13401 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13402 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13403#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013404 { } /* end */
13405};
13406/*
13407 * 6ch mode
13408 * need to set the codec line out and mic 1 pin widgets to outputs
13409 */
13410static struct hda_verb alc861_threestack_ch6_init[] = {
13411 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13412 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13413 /* set pin widget 18h (mic1) for output (CLFE)*/
13414 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13415
13416 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013417 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013418
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013419 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13420#if 0
13421 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13422 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13423#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013424 { } /* end */
13425};
13426
13427static struct hda_channel_mode alc861_threestack_modes[2] = {
13428 { 2, alc861_threestack_ch2_init },
13429 { 6, alc861_threestack_ch6_init },
13430};
Takashi Iwai22309c32006-08-09 16:57:28 +020013431/* Set mic1 as input and unmute the mixer */
13432static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
13433 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13434 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13435 { } /* end */
13436};
13437/* Set mic1 as output and mute mixer */
13438static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
13439 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13440 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13441 { } /* end */
13442};
13443
13444static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
13445 { 2, alc861_uniwill_m31_ch2_init },
13446 { 4, alc861_uniwill_m31_ch4_init },
13447};
Kailang Yangdf694da2005-12-05 19:42:22 +010013448
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013449/* Set mic1 and line-in as input and unmute the mixer */
13450static struct hda_verb alc861_asus_ch2_init[] = {
13451 /* set pin widget 1Ah (line in) for input */
13452 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013453 /* set pin widget 18h (mic1/2) for input, for mic also enable
13454 * the vref
13455 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013456 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13457
13458 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13459#if 0
13460 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13461 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13462#endif
13463 { } /* end */
13464};
13465/* Set mic1 nad line-in as output and mute mixer */
13466static struct hda_verb alc861_asus_ch6_init[] = {
13467 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13468 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13469 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13470 /* set pin widget 18h (mic1) for output (CLFE)*/
13471 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13472 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13473 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
13474 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
13475
13476 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13477#if 0
13478 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13479 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13480#endif
13481 { } /* end */
13482};
13483
13484static struct hda_channel_mode alc861_asus_modes[2] = {
13485 { 2, alc861_asus_ch2_init },
13486 { 6, alc861_asus_ch6_init },
13487};
13488
Kailang Yangdf694da2005-12-05 19:42:22 +010013489/* patch-ALC861 */
13490
13491static struct snd_kcontrol_new alc861_base_mixer[] = {
13492 /* output mixer control */
13493 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13494 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13495 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13496 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13497 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13498
13499 /*Input mixer control */
13500 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13501 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13502 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13503 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13504 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13505 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13506 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13507 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13508 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13509 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013510
Kailang Yangdf694da2005-12-05 19:42:22 +010013511 { } /* end */
13512};
13513
13514static struct snd_kcontrol_new alc861_3ST_mixer[] = {
13515 /* output mixer control */
13516 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13517 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13518 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13519 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13520 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13521
13522 /* Input mixer control */
13523 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13524 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13525 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13526 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13527 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13528 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13529 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13530 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13531 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13532 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013533
Kailang Yangdf694da2005-12-05 19:42:22 +010013534 {
13535 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13536 .name = "Channel Mode",
13537 .info = alc_ch_mode_info,
13538 .get = alc_ch_mode_get,
13539 .put = alc_ch_mode_put,
13540 .private_value = ARRAY_SIZE(alc861_threestack_modes),
13541 },
13542 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013543};
13544
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013545static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013546 /* output mixer control */
13547 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13548 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13549 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020013550
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013551 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013552};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013553
Takashi Iwai22309c32006-08-09 16:57:28 +020013554static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
13555 /* output mixer control */
13556 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13557 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13558 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13559 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13560 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13561
13562 /* Input mixer control */
13563 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13564 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13565 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13566 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13567 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13568 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13569 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13570 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13571 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13572 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013573
Takashi Iwai22309c32006-08-09 16:57:28 +020013574 {
13575 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13576 .name = "Channel Mode",
13577 .info = alc_ch_mode_info,
13578 .get = alc_ch_mode_get,
13579 .put = alc_ch_mode_put,
13580 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
13581 },
13582 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013583};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013584
13585static struct snd_kcontrol_new alc861_asus_mixer[] = {
13586 /* output mixer control */
13587 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13588 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13589 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13590 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13591 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13592
13593 /* Input mixer control */
13594 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13595 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13596 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13597 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13598 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13599 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13600 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13601 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13602 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013603 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
13604
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013605 {
13606 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13607 .name = "Channel Mode",
13608 .info = alc_ch_mode_info,
13609 .get = alc_ch_mode_get,
13610 .put = alc_ch_mode_put,
13611 .private_value = ARRAY_SIZE(alc861_asus_modes),
13612 },
13613 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013614};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013615
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013616/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013617static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013618 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13619 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013620 { }
13621};
13622
Kailang Yangdf694da2005-12-05 19:42:22 +010013623/*
13624 * generic initialization of ADC, input mixers and output mixers
13625 */
13626static struct hda_verb alc861_base_init_verbs[] = {
13627 /*
13628 * Unmute ADC0 and set the default input to mic-in
13629 */
13630 /* port-A for surround (rear panel) */
13631 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13632 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
13633 /* port-B for mic-in (rear panel) with vref */
13634 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13635 /* port-C for line-in (rear panel) */
13636 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13637 /* port-D for Front */
13638 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13639 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13640 /* port-E for HP out (front panel) */
13641 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13642 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013643 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013644 /* port-F for mic-in (front panel) with vref */
13645 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13646 /* port-G for CLFE (rear panel) */
13647 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13648 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13649 /* port-H for side (rear panel) */
13650 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13651 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
13652 /* CD-in */
13653 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13654 /* route front mic to ADC1*/
13655 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13656 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013657
Kailang Yangdf694da2005-12-05 19:42:22 +010013658 /* Unmute DAC0~3 & spdif out*/
13659 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13660 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13661 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13662 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13663 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013664
Kailang Yangdf694da2005-12-05 19:42:22 +010013665 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13666 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13667 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13668 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13669 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013670
Kailang Yangdf694da2005-12-05 19:42:22 +010013671 /* Unmute Stereo Mixer 15 */
13672 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13673 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13674 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013675 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013676
13677 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13678 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13679 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13680 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13681 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13682 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13683 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13684 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013685 /* hp used DAC 3 (Front) */
13686 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013687 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13688
13689 { }
13690};
13691
13692static struct hda_verb alc861_threestack_init_verbs[] = {
13693 /*
13694 * Unmute ADC0 and set the default input to mic-in
13695 */
13696 /* port-A for surround (rear panel) */
13697 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13698 /* port-B for mic-in (rear panel) with vref */
13699 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13700 /* port-C for line-in (rear panel) */
13701 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13702 /* port-D for Front */
13703 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13704 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13705 /* port-E for HP out (front panel) */
13706 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13707 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013708 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013709 /* port-F for mic-in (front panel) with vref */
13710 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13711 /* port-G for CLFE (rear panel) */
13712 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13713 /* port-H for side (rear panel) */
13714 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13715 /* CD-in */
13716 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13717 /* route front mic to ADC1*/
13718 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13719 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13720 /* Unmute DAC0~3 & spdif out*/
13721 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13722 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13723 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13724 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13725 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013726
Kailang Yangdf694da2005-12-05 19:42:22 +010013727 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13728 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13729 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13730 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13731 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013732
Kailang Yangdf694da2005-12-05 19:42:22 +010013733 /* Unmute Stereo Mixer 15 */
13734 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13735 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13736 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013737 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013738
13739 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13740 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13741 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13742 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13743 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13744 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13745 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13746 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013747 /* hp used DAC 3 (Front) */
13748 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013749 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13750 { }
13751};
Takashi Iwai22309c32006-08-09 16:57:28 +020013752
13753static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
13754 /*
13755 * Unmute ADC0 and set the default input to mic-in
13756 */
13757 /* port-A for surround (rear panel) */
13758 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13759 /* port-B for mic-in (rear panel) with vref */
13760 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13761 /* port-C for line-in (rear panel) */
13762 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13763 /* port-D for Front */
13764 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13765 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13766 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013767 /* this has to be set to VREF80 */
13768 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013769 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013770 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013771 /* port-F for mic-in (front panel) with vref */
13772 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13773 /* port-G for CLFE (rear panel) */
13774 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13775 /* port-H for side (rear panel) */
13776 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13777 /* CD-in */
13778 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13779 /* route front mic to ADC1*/
13780 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13781 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13782 /* Unmute DAC0~3 & spdif out*/
13783 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13784 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13785 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13786 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13787 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013788
Takashi Iwai22309c32006-08-09 16:57:28 +020013789 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13790 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13791 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13792 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13793 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013794
Takashi Iwai22309c32006-08-09 16:57:28 +020013795 /* Unmute Stereo Mixer 15 */
13796 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13797 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13798 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013799 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020013800
13801 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13802 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13803 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13804 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13805 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13806 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13807 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13808 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013809 /* hp used DAC 3 (Front) */
13810 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020013811 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13812 { }
13813};
13814
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013815static struct hda_verb alc861_asus_init_verbs[] = {
13816 /*
13817 * Unmute ADC0 and set the default input to mic-in
13818 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013819 /* port-A for surround (rear panel)
13820 * according to codec#0 this is the HP jack
13821 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013822 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
13823 /* route front PCM to HP */
13824 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
13825 /* port-B for mic-in (rear panel) with vref */
13826 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13827 /* port-C for line-in (rear panel) */
13828 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13829 /* port-D for Front */
13830 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13831 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13832 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013833 /* this has to be set to VREF80 */
13834 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013835 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013836 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013837 /* port-F for mic-in (front panel) with vref */
13838 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13839 /* port-G for CLFE (rear panel) */
13840 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13841 /* port-H for side (rear panel) */
13842 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13843 /* CD-in */
13844 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13845 /* route front mic to ADC1*/
13846 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13847 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13848 /* Unmute DAC0~3 & spdif out*/
13849 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13850 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13851 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13852 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13853 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13854 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13855 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13856 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13857 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13858 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013859
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013860 /* Unmute Stereo Mixer 15 */
13861 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13862 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13863 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013864 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013865
13866 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13867 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13868 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13869 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13870 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13871 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13872 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13873 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013874 /* hp used DAC 3 (Front) */
13875 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013876 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13877 { }
13878};
13879
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013880/* additional init verbs for ASUS laptops */
13881static struct hda_verb alc861_asus_laptop_init_verbs[] = {
13882 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
13883 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
13884 { }
13885};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013886
Kailang Yangdf694da2005-12-05 19:42:22 +010013887/*
13888 * generic initialization of ADC, input mixers and output mixers
13889 */
13890static struct hda_verb alc861_auto_init_verbs[] = {
13891 /*
13892 * Unmute ADC0 and set the default input to mic-in
13893 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013894 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010013895 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013896
Kailang Yangdf694da2005-12-05 19:42:22 +010013897 /* Unmute DAC0~3 & spdif out*/
13898 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13899 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13900 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13901 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13902 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013903
Kailang Yangdf694da2005-12-05 19:42:22 +010013904 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13905 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13906 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13907 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13908 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013909
Kailang Yangdf694da2005-12-05 19:42:22 +010013910 /* Unmute Stereo Mixer 15 */
13911 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13912 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13913 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13914 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
13915
Takashi Iwai1c209302009-07-22 15:17:45 +020013916 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13917 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13918 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13919 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13920 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13921 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13922 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13923 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013924
13925 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13926 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020013927 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13928 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013929 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13930 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020013931 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13932 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013933
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013934 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013935
13936 { }
13937};
13938
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013939static struct hda_verb alc861_toshiba_init_verbs[] = {
13940 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013941
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013942 { }
13943};
13944
13945/* toggle speaker-output according to the hp-jack state */
13946static void alc861_toshiba_automute(struct hda_codec *codec)
13947{
13948 unsigned int present;
13949
13950 present = snd_hda_codec_read(codec, 0x0f, 0,
13951 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013952 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
13953 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
13954 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
13955 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013956}
13957
13958static void alc861_toshiba_unsol_event(struct hda_codec *codec,
13959 unsigned int res)
13960{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013961 if ((res >> 26) == ALC880_HP_EVENT)
13962 alc861_toshiba_automute(codec);
13963}
13964
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013965/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013966#define alc861_pcm_analog_playback alc880_pcm_analog_playback
13967#define alc861_pcm_analog_capture alc880_pcm_analog_capture
13968#define alc861_pcm_digital_playback alc880_pcm_digital_playback
13969#define alc861_pcm_digital_capture alc880_pcm_digital_capture
13970
13971
13972#define ALC861_DIGOUT_NID 0x07
13973
13974static struct hda_channel_mode alc861_8ch_modes[1] = {
13975 { 8, NULL }
13976};
13977
13978static hda_nid_t alc861_dac_nids[4] = {
13979 /* front, surround, clfe, side */
13980 0x03, 0x06, 0x05, 0x04
13981};
13982
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013983static hda_nid_t alc660_dac_nids[3] = {
13984 /* front, clfe, surround */
13985 0x03, 0x05, 0x06
13986};
13987
Kailang Yangdf694da2005-12-05 19:42:22 +010013988static hda_nid_t alc861_adc_nids[1] = {
13989 /* ADC0-2 */
13990 0x08,
13991};
13992
13993static struct hda_input_mux alc861_capture_source = {
13994 .num_items = 5,
13995 .items = {
13996 { "Mic", 0x0 },
13997 { "Front Mic", 0x3 },
13998 { "Line", 0x1 },
13999 { "CD", 0x4 },
14000 { "Mixer", 0x5 },
14001 },
14002};
14003
Takashi Iwai1c209302009-07-22 15:17:45 +020014004static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
14005{
14006 struct alc_spec *spec = codec->spec;
14007 hda_nid_t mix, srcs[5];
14008 int i, j, num;
14009
14010 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
14011 return 0;
14012 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
14013 if (num < 0)
14014 return 0;
14015 for (i = 0; i < num; i++) {
14016 unsigned int type;
Takashi Iwaia22d5432009-07-27 12:54:26 +020014017 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
Takashi Iwai1c209302009-07-22 15:17:45 +020014018 if (type != AC_WID_AUD_OUT)
14019 continue;
14020 for (j = 0; j < spec->multiout.num_dacs; j++)
14021 if (spec->multiout.dac_nids[j] == srcs[i])
14022 break;
14023 if (j >= spec->multiout.num_dacs)
14024 return srcs[i];
14025 }
14026 return 0;
14027}
14028
Kailang Yangdf694da2005-12-05 19:42:22 +010014029/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwai1c209302009-07-22 15:17:45 +020014030static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014031 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014032{
Takashi Iwai1c209302009-07-22 15:17:45 +020014033 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014034 int i;
Takashi Iwai1c209302009-07-22 15:17:45 +020014035 hda_nid_t nid, dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010014036
14037 spec->multiout.dac_nids = spec->private_dac_nids;
14038 for (i = 0; i < cfg->line_outs; i++) {
14039 nid = cfg->line_out_pins[i];
Takashi Iwai1c209302009-07-22 15:17:45 +020014040 dac = alc861_look_for_dac(codec, nid);
14041 if (!dac)
14042 continue;
14043 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010014044 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014045 return 0;
14046}
14047
Takashi Iwai1c209302009-07-22 15:17:45 +020014048static int alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
14049 hda_nid_t nid, unsigned int chs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014050{
14051 char name[32];
Takashi Iwai1c209302009-07-22 15:17:45 +020014052 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
14053 return add_control(codec->spec, ALC_CTL_WIDGET_MUTE, name,
14054 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
14055}
14056
14057/* add playback controls from the parsed DAC table */
14058static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
14059 const struct auto_pin_cfg *cfg)
14060{
14061 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014062 static const char *chname[4] = {
14063 "Front", "Surround", NULL /*CLFE*/, "Side"
14064 };
Kailang Yangdf694da2005-12-05 19:42:22 +010014065 hda_nid_t nid;
Takashi Iwai1c209302009-07-22 15:17:45 +020014066 int i, err;
14067
14068 if (cfg->line_outs == 1) {
14069 const char *pfx = NULL;
14070 if (!cfg->hp_outs)
14071 pfx = "Master";
14072 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
14073 pfx = "Speaker";
14074 if (pfx) {
14075 nid = spec->multiout.dac_nids[0];
14076 return alc861_create_out_sw(codec, pfx, nid, 3);
14077 }
14078 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014079
14080 for (i = 0; i < cfg->line_outs; i++) {
14081 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014082 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010014083 continue;
Takashi Iwai1c209302009-07-22 15:17:45 +020014084 if (i == 2) {
Kailang Yangdf694da2005-12-05 19:42:22 +010014085 /* Center/LFE */
Takashi Iwai1c209302009-07-22 15:17:45 +020014086 err = alc861_create_out_sw(codec, "Center", nid, 1);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014087 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014088 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014089 err = alc861_create_out_sw(codec, "LFE", nid, 2);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014090 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014091 return err;
14092 } else {
Takashi Iwai1c209302009-07-22 15:17:45 +020014093 err = alc861_create_out_sw(codec, chname[i], nid, 3);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014094 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014095 return err;
14096 }
14097 }
14098 return 0;
14099}
14100
Takashi Iwai1c209302009-07-22 15:17:45 +020014101static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010014102{
Takashi Iwai1c209302009-07-22 15:17:45 +020014103 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014104 int err;
14105 hda_nid_t nid;
14106
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014107 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010014108 return 0;
14109
14110 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
Takashi Iwai1c209302009-07-22 15:17:45 +020014111 nid = alc861_look_for_dac(codec, pin);
14112 if (nid) {
14113 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
14114 if (err < 0)
14115 return err;
14116 spec->multiout.hp_nid = nid;
14117 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014118 }
14119 return 0;
14120}
14121
14122/* create playback/capture controls for input pins */
Takashi Iwai1c209302009-07-22 15:17:45 +020014123static int alc861_auto_create_analog_input_ctls(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014124 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014125{
Takashi Iwai1c209302009-07-22 15:17:45 +020014126 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014127 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010014128 int i, err, idx, idx1;
14129
14130 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014131 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010014132 case 0x0c:
14133 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014134 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010014135 break;
14136 case 0x0f:
14137 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014138 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010014139 break;
14140 case 0x0d:
14141 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014142 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010014143 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014144 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010014145 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014146 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010014147 break;
14148 case 0x11:
14149 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014150 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010014151 break;
14152 default:
14153 continue;
14154 }
14155
Takashi Iwai4a471b72005-12-07 13:56:29 +010014156 err = new_analog_input(spec, cfg->input_pins[i],
14157 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010014158 if (err < 0)
14159 return err;
14160
Takashi Iwai4a471b72005-12-07 13:56:29 +010014161 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010014162 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014163 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010014164 }
14165 return 0;
14166}
14167
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014168static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
14169 hda_nid_t nid,
Takashi Iwai1c209302009-07-22 15:17:45 +020014170 int pin_type, hda_nid_t dac)
Kailang Yangdf694da2005-12-05 19:42:22 +010014171{
Takashi Iwai1c209302009-07-22 15:17:45 +020014172 hda_nid_t mix, srcs[5];
14173 int i, num;
14174
Jacek Luczak564c5be2008-05-03 18:41:23 +020014175 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
14176 pin_type);
Takashi Iwai1c209302009-07-22 15:17:45 +020014177 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Jacek Luczak564c5be2008-05-03 18:41:23 +020014178 AMP_OUT_UNMUTE);
Takashi Iwai1c209302009-07-22 15:17:45 +020014179 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
14180 return;
14181 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
14182 if (num < 0)
14183 return;
14184 for (i = 0; i < num; i++) {
14185 unsigned int mute;
14186 if (srcs[i] == dac || srcs[i] == 0x15)
14187 mute = AMP_IN_UNMUTE(i);
14188 else
14189 mute = AMP_IN_MUTE(i);
14190 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14191 mute);
14192 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014193}
14194
14195static void alc861_auto_init_multi_out(struct hda_codec *codec)
14196{
14197 struct alc_spec *spec = codec->spec;
14198 int i;
14199
14200 for (i = 0; i < spec->autocfg.line_outs; i++) {
14201 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014202 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010014203 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014204 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014205 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014206 }
14207}
14208
14209static void alc861_auto_init_hp_out(struct hda_codec *codec)
14210{
14211 struct alc_spec *spec = codec->spec;
14212 hda_nid_t pin;
14213
Takashi Iwaieb06ed82006-09-20 17:10:27 +020014214 pin = spec->autocfg.hp_pins[0];
Takashi Iwai1c209302009-07-22 15:17:45 +020014215 if (pin)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014216 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
Takashi Iwai1c209302009-07-22 15:17:45 +020014217 spec->multiout.hp_nid);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014218 pin = spec->autocfg.speaker_pins[0];
14219 if (pin)
Takashi Iwai1c209302009-07-22 15:17:45 +020014220 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT,
14221 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014222}
14223
14224static void alc861_auto_init_analog_input(struct hda_codec *codec)
14225{
14226 struct alc_spec *spec = codec->spec;
14227 int i;
14228
14229 for (i = 0; i < AUTO_PIN_LAST; i++) {
14230 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai23f0c042009-02-26 13:03:58 +010014231 if (nid >= 0x0c && nid <= 0x11)
14232 alc_set_input_pin(codec, nid, i);
Kailang Yangdf694da2005-12-05 19:42:22 +010014233 }
14234}
14235
14236/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014237/* return 1 if successful, 0 if the proper config is not found,
14238 * or a negative error code
14239 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014240static int alc861_parse_auto_config(struct hda_codec *codec)
14241{
14242 struct alc_spec *spec = codec->spec;
14243 int err;
14244 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
14245
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014246 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14247 alc861_ignore);
14248 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014249 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014250 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014251 return 0; /* can't find valid BIOS pin config */
14252
Takashi Iwai1c209302009-07-22 15:17:45 +020014253 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014254 if (err < 0)
14255 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014256 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014257 if (err < 0)
14258 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014259 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014260 if (err < 0)
14261 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014262 err = alc861_auto_create_analog_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014263 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014264 return err;
14265
14266 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14267
Takashi Iwai0852d7a2009-02-11 11:35:15 +010014268 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014269 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
14270
Takashi Iwai603c4012008-07-30 15:01:44 +020014271 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014272 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010014273
Takashi Iwaid88897e2008-10-31 15:01:37 +010014274 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010014275
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020014276 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014277 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010014278
14279 spec->adc_nids = alc861_adc_nids;
14280 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014281 set_capture_mixer(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014282
Takashi Iwai4a79ba32009-04-22 16:31:35 +020014283 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b);
14284
Kailang Yangdf694da2005-12-05 19:42:22 +010014285 return 1;
14286}
14287
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014288/* additional initialization for auto-configuration model */
14289static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010014290{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014291 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014292 alc861_auto_init_multi_out(codec);
14293 alc861_auto_init_hp_out(codec);
14294 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014295 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014296 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014297}
14298
Takashi Iwaicb53c622007-08-10 17:21:45 +020014299#ifdef CONFIG_SND_HDA_POWER_SAVE
14300static struct hda_amp_list alc861_loopbacks[] = {
14301 { 0x15, HDA_INPUT, 0 },
14302 { 0x15, HDA_INPUT, 1 },
14303 { 0x15, HDA_INPUT, 2 },
14304 { 0x15, HDA_INPUT, 3 },
14305 { } /* end */
14306};
14307#endif
14308
Kailang Yangdf694da2005-12-05 19:42:22 +010014309
14310/*
14311 * configuration and preset
14312 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014313static const char *alc861_models[ALC861_MODEL_LAST] = {
14314 [ALC861_3ST] = "3stack",
14315 [ALC660_3ST] = "3stack-660",
14316 [ALC861_3ST_DIG] = "3stack-dig",
14317 [ALC861_6ST_DIG] = "6stack-dig",
14318 [ALC861_UNIWILL_M31] = "uniwill-m31",
14319 [ALC861_TOSHIBA] = "toshiba",
14320 [ALC861_ASUS] = "asus",
14321 [ALC861_ASUS_LAPTOP] = "asus-laptop",
14322 [ALC861_AUTO] = "auto",
14323};
14324
14325static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010014326 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014327 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14328 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14329 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014330 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020014331 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010014332 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020014333 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
14334 * Any other models that need this preset?
14335 */
14336 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020014337 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
14338 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014339 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
14340 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
14341 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
14342 /* FIXME: the below seems conflict */
14343 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
14344 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
14345 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010014346 {}
14347};
14348
14349static struct alc_config_preset alc861_presets[] = {
14350 [ALC861_3ST] = {
14351 .mixers = { alc861_3ST_mixer },
14352 .init_verbs = { alc861_threestack_init_verbs },
14353 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14354 .dac_nids = alc861_dac_nids,
14355 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14356 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014357 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014358 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14359 .adc_nids = alc861_adc_nids,
14360 .input_mux = &alc861_capture_source,
14361 },
14362 [ALC861_3ST_DIG] = {
14363 .mixers = { alc861_base_mixer },
14364 .init_verbs = { alc861_threestack_init_verbs },
14365 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14366 .dac_nids = alc861_dac_nids,
14367 .dig_out_nid = ALC861_DIGOUT_NID,
14368 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14369 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014370 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014371 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14372 .adc_nids = alc861_adc_nids,
14373 .input_mux = &alc861_capture_source,
14374 },
14375 [ALC861_6ST_DIG] = {
14376 .mixers = { alc861_base_mixer },
14377 .init_verbs = { alc861_base_init_verbs },
14378 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14379 .dac_nids = alc861_dac_nids,
14380 .dig_out_nid = ALC861_DIGOUT_NID,
14381 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
14382 .channel_mode = alc861_8ch_modes,
14383 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14384 .adc_nids = alc861_adc_nids,
14385 .input_mux = &alc861_capture_source,
14386 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014387 [ALC660_3ST] = {
14388 .mixers = { alc861_3ST_mixer },
14389 .init_verbs = { alc861_threestack_init_verbs },
14390 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
14391 .dac_nids = alc660_dac_nids,
14392 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14393 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014394 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014395 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14396 .adc_nids = alc861_adc_nids,
14397 .input_mux = &alc861_capture_source,
14398 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014399 [ALC861_UNIWILL_M31] = {
14400 .mixers = { alc861_uniwill_m31_mixer },
14401 .init_verbs = { alc861_uniwill_m31_init_verbs },
14402 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14403 .dac_nids = alc861_dac_nids,
14404 .dig_out_nid = ALC861_DIGOUT_NID,
14405 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
14406 .channel_mode = alc861_uniwill_m31_modes,
14407 .need_dac_fix = 1,
14408 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14409 .adc_nids = alc861_adc_nids,
14410 .input_mux = &alc861_capture_source,
14411 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014412 [ALC861_TOSHIBA] = {
14413 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014414 .init_verbs = { alc861_base_init_verbs,
14415 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014416 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14417 .dac_nids = alc861_dac_nids,
14418 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14419 .channel_mode = alc883_3ST_2ch_modes,
14420 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14421 .adc_nids = alc861_adc_nids,
14422 .input_mux = &alc861_capture_source,
14423 .unsol_event = alc861_toshiba_unsol_event,
14424 .init_hook = alc861_toshiba_automute,
14425 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014426 [ALC861_ASUS] = {
14427 .mixers = { alc861_asus_mixer },
14428 .init_verbs = { alc861_asus_init_verbs },
14429 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14430 .dac_nids = alc861_dac_nids,
14431 .dig_out_nid = ALC861_DIGOUT_NID,
14432 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
14433 .channel_mode = alc861_asus_modes,
14434 .need_dac_fix = 1,
14435 .hp_nid = 0x06,
14436 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14437 .adc_nids = alc861_adc_nids,
14438 .input_mux = &alc861_capture_source,
14439 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014440 [ALC861_ASUS_LAPTOP] = {
14441 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
14442 .init_verbs = { alc861_asus_init_verbs,
14443 alc861_asus_laptop_init_verbs },
14444 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14445 .dac_nids = alc861_dac_nids,
14446 .dig_out_nid = ALC861_DIGOUT_NID,
14447 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14448 .channel_mode = alc883_3ST_2ch_modes,
14449 .need_dac_fix = 1,
14450 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14451 .adc_nids = alc861_adc_nids,
14452 .input_mux = &alc861_capture_source,
14453 },
14454};
Kailang Yangdf694da2005-12-05 19:42:22 +010014455
14456
14457static int patch_alc861(struct hda_codec *codec)
14458{
14459 struct alc_spec *spec;
14460 int board_config;
14461 int err;
14462
Robert P. J. Daydc041e02006-12-19 14:44:15 +010014463 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010014464 if (spec == NULL)
14465 return -ENOMEM;
14466
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014467 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014468
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014469 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
14470 alc861_models,
14471 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014472
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014473 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020014474 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
14475 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010014476 board_config = ALC861_AUTO;
14477 }
14478
14479 if (board_config == ALC861_AUTO) {
14480 /* automatic parse from the BIOS config */
14481 err = alc861_parse_auto_config(codec);
14482 if (err < 0) {
14483 alc_free(codec);
14484 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014485 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014486 printk(KERN_INFO
14487 "hda_codec: Cannot set up configuration "
14488 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010014489 board_config = ALC861_3ST_DIG;
14490 }
14491 }
14492
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014493 err = snd_hda_attach_beep_device(codec, 0x23);
14494 if (err < 0) {
14495 alc_free(codec);
14496 return err;
14497 }
14498
Kailang Yangdf694da2005-12-05 19:42:22 +010014499 if (board_config != ALC861_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020014500 setup_preset(codec, &alc861_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014501
Kailang Yangdf694da2005-12-05 19:42:22 +010014502 spec->stream_analog_playback = &alc861_pcm_analog_playback;
14503 spec->stream_analog_capture = &alc861_pcm_analog_capture;
14504
Kailang Yangdf694da2005-12-05 19:42:22 +010014505 spec->stream_digital_playback = &alc861_pcm_digital_playback;
14506 spec->stream_digital_capture = &alc861_pcm_digital_capture;
14507
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014508 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
14509
Takashi Iwai2134ea42008-01-10 16:53:55 +010014510 spec->vmaster_nid = 0x03;
14511
Kailang Yangdf694da2005-12-05 19:42:22 +010014512 codec->patch_ops = alc_patch_ops;
14513 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014514 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014515#ifdef CONFIG_SND_HDA_POWER_SAVE
14516 if (!spec->loopback.amplist)
14517 spec->loopback.amplist = alc861_loopbacks;
14518#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010014519 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020014520
Kailang Yangdf694da2005-12-05 19:42:22 +010014521 return 0;
14522}
14523
14524/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014525 * ALC861-VD support
14526 *
14527 * Based on ALC882
14528 *
14529 * In addition, an independent DAC
14530 */
14531#define ALC861VD_DIGOUT_NID 0x06
14532
14533static hda_nid_t alc861vd_dac_nids[4] = {
14534 /* front, surr, clfe, side surr */
14535 0x02, 0x03, 0x04, 0x05
14536};
14537
14538/* dac_nids for ALC660vd are in a different order - according to
14539 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014540 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014541 * of ALC660vd codecs, but for now there is only 3stack mixer
14542 * - and it is the same as in 861vd.
14543 * adc_nids in ALC660vd are (is) the same as in 861vd
14544 */
14545static hda_nid_t alc660vd_dac_nids[3] = {
14546 /* front, rear, clfe, rear_surr */
14547 0x02, 0x04, 0x03
14548};
14549
14550static hda_nid_t alc861vd_adc_nids[1] = {
14551 /* ADC0 */
14552 0x09,
14553};
14554
Takashi Iwaie1406342008-02-11 18:32:32 +010014555static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
14556
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014557/* input MUX */
14558/* FIXME: should be a matrix-type input source selection */
14559static struct hda_input_mux alc861vd_capture_source = {
14560 .num_items = 4,
14561 .items = {
14562 { "Mic", 0x0 },
14563 { "Front Mic", 0x1 },
14564 { "Line", 0x2 },
14565 { "CD", 0x4 },
14566 },
14567};
14568
Kailang Yang272a5272007-05-14 11:00:38 +020014569static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010014570 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020014571 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010014572 { "Ext Mic", 0x0 },
14573 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020014574 },
14575};
14576
Kailang Yangd1a991a2007-08-15 16:21:59 +020014577static struct hda_input_mux alc861vd_hp_capture_source = {
14578 .num_items = 2,
14579 .items = {
14580 { "Front Mic", 0x0 },
14581 { "ATAPI Mic", 0x1 },
14582 },
14583};
14584
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014585/*
14586 * 2ch mode
14587 */
14588static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
14589 { 2, NULL }
14590};
14591
14592/*
14593 * 6ch mode
14594 */
14595static struct hda_verb alc861vd_6stack_ch6_init[] = {
14596 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14597 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14598 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14599 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14600 { } /* end */
14601};
14602
14603/*
14604 * 8ch mode
14605 */
14606static struct hda_verb alc861vd_6stack_ch8_init[] = {
14607 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14608 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14609 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14610 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14611 { } /* end */
14612};
14613
14614static struct hda_channel_mode alc861vd_6stack_modes[2] = {
14615 { 6, alc861vd_6stack_ch6_init },
14616 { 8, alc861vd_6stack_ch8_init },
14617};
14618
14619static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
14620 {
14621 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14622 .name = "Channel Mode",
14623 .info = alc_ch_mode_info,
14624 .get = alc_ch_mode_get,
14625 .put = alc_ch_mode_put,
14626 },
14627 { } /* end */
14628};
14629
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014630/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
14631 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
14632 */
14633static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
14634 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14635 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14636
14637 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14638 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
14639
14640 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
14641 HDA_OUTPUT),
14642 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
14643 HDA_OUTPUT),
14644 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
14645 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
14646
14647 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
14648 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
14649
14650 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14651
14652 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14653 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14654 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14655
14656 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14657 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14658 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14659
14660 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14661 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14662
14663 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14664 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14665
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014666 { } /* end */
14667};
14668
14669static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
14670 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14671 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14672
14673 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14674
14675 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14676 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14677 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14678
14679 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14680 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14681 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14682
14683 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14684 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14685
14686 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14687 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14688
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014689 { } /* end */
14690};
14691
Kailang Yangbdd148a2007-05-08 15:19:08 +020014692static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
14693 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14694 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
14695 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14696
14697 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14698
14699 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14700 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14701 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14702
14703 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14704 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14705 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14706
14707 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14708 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14709
14710 { } /* end */
14711};
14712
Tobin Davisb419f342008-03-07 11:57:51 +010014713/* Pin assignment: Speaker=0x14, HP = 0x15,
14714 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020014715 */
14716static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010014717 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14718 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014719 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14720 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010014721 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
14722 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14723 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14724 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
14725 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14726 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014727 { } /* end */
14728};
14729
Kailang Yangd1a991a2007-08-15 16:21:59 +020014730/* Pin assignment: Speaker=0x14, Line-out = 0x15,
14731 * Front Mic=0x18, ATAPI Mic = 0x19,
14732 */
14733static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
14734 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14735 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14736 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14737 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
14738 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14739 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14740 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14741 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020014742
Kailang Yangd1a991a2007-08-15 16:21:59 +020014743 { } /* end */
14744};
14745
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014746/*
14747 * generic initialization of ADC, input mixers and output mixers
14748 */
14749static struct hda_verb alc861vd_volume_init_verbs[] = {
14750 /*
14751 * Unmute ADC0 and set the default input to mic-in
14752 */
14753 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14754 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14755
14756 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
14757 * the analog-loopback mixer widget
14758 */
14759 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020014760 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14761 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14762 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14763 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14764 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014765
14766 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020014767 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14768 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14769 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014770 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014771
14772 /*
14773 * Set up output mixers (0x02 - 0x05)
14774 */
14775 /* set vol=0 to output mixers */
14776 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14777 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14778 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14779 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14780
14781 /* set up input amps for analog loopback */
14782 /* Amp Indices: DAC = 0, mixer = 1 */
14783 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14784 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14785 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14786 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14787 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14788 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14789 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14790 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14791
14792 { }
14793};
14794
14795/*
14796 * 3-stack pin configuration:
14797 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
14798 */
14799static struct hda_verb alc861vd_3stack_init_verbs[] = {
14800 /*
14801 * Set pin mode and muting
14802 */
14803 /* set front pin widgets 0x14 for output */
14804 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14805 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14806 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14807
14808 /* Mic (rear) pin: input vref at 80% */
14809 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14810 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14811 /* Front Mic pin: input vref at 80% */
14812 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14813 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14814 /* Line In pin: input */
14815 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14816 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14817 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14818 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14819 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14820 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14821 /* CD pin widget for input */
14822 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14823
14824 { }
14825};
14826
14827/*
14828 * 6-stack pin configuration:
14829 */
14830static struct hda_verb alc861vd_6stack_init_verbs[] = {
14831 /*
14832 * Set pin mode and muting
14833 */
14834 /* set front pin widgets 0x14 for output */
14835 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14836 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14837 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14838
14839 /* Rear Pin: output 1 (0x0d) */
14840 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14841 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14842 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14843 /* CLFE Pin: output 2 (0x0e) */
14844 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14845 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14846 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
14847 /* Side Pin: output 3 (0x0f) */
14848 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14849 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14850 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
14851
14852 /* Mic (rear) pin: input vref at 80% */
14853 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14854 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14855 /* Front Mic pin: input vref at 80% */
14856 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14857 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14858 /* Line In pin: input */
14859 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14860 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14861 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14862 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14863 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14864 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14865 /* CD pin widget for input */
14866 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14867
14868 { }
14869};
14870
Kailang Yangbdd148a2007-05-08 15:19:08 +020014871static struct hda_verb alc861vd_eapd_verbs[] = {
14872 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14873 { }
14874};
14875
Kailang Yangf9423e72008-05-27 12:32:25 +020014876static struct hda_verb alc660vd_eapd_verbs[] = {
14877 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14878 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
14879 { }
14880};
14881
Kailang Yangbdd148a2007-05-08 15:19:08 +020014882static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
14883 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14884 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14885 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
14886 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020014887 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020014888 {}
14889};
14890
Kailang Yangbdd148a2007-05-08 15:19:08 +020014891static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
14892{
14893 unsigned int present;
14894 unsigned char bits;
14895
14896 present = snd_hda_codec_read(codec, 0x18, 0,
14897 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014898 bits = present ? HDA_AMP_MUTE : 0;
14899 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
14900 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014901}
14902
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014903static void alc861vd_lenovo_setup(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020014904{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014905 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014906 spec->autocfg.hp_pins[0] = 0x1b;
14907 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014908}
14909
14910static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
14911{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014912 alc_automute_amp(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014913 alc861vd_lenovo_mic_automute(codec);
14914}
14915
14916static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
14917 unsigned int res)
14918{
14919 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020014920 case ALC880_MIC_EVENT:
14921 alc861vd_lenovo_mic_automute(codec);
14922 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014923 default:
14924 alc_automute_amp_unsol_event(codec, res);
14925 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020014926 }
14927}
14928
Kailang Yang272a5272007-05-14 11:00:38 +020014929static struct hda_verb alc861vd_dallas_verbs[] = {
14930 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14931 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14932 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14933 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14934
14935 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14936 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14937 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14938 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14939 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14940 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14941 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14942 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014943
Kailang Yang272a5272007-05-14 11:00:38 +020014944 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14945 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14946 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14947 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14948 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14949 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14950 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14951 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14952
14953 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14954 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14955 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14956 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14957 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14958 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14959 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14960 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14961
14962 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14963 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14964 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14965 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
14966
14967 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014968 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020014969 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14970
14971 { } /* end */
14972};
14973
14974/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014975static void alc861vd_dallas_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020014976{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014977 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020014978
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014979 spec->autocfg.hp_pins[0] = 0x15;
14980 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang272a5272007-05-14 11:00:38 +020014981}
14982
Takashi Iwaicb53c622007-08-10 17:21:45 +020014983#ifdef CONFIG_SND_HDA_POWER_SAVE
14984#define alc861vd_loopbacks alc880_loopbacks
14985#endif
14986
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014987/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014988#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
14989#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
14990#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
14991#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
14992
14993/*
14994 * configuration and preset
14995 */
14996static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
14997 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020014998 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010014999 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015000 [ALC861VD_3ST] = "3stack",
15001 [ALC861VD_3ST_DIG] = "3stack-digout",
15002 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020015003 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020015004 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015005 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015006 [ALC861VD_AUTO] = "auto",
15007};
15008
15009static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015010 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
15011 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010015012 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015013 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Takashi Iwai13c94742008-11-05 08:06:08 +010015014 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020015015 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015016 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015017 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020015018 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Takashi Iwaice577e82009-08-03 08:23:52 +020015019 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai542d7c62007-08-16 18:57:30 +020015020 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010015021 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020015022 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010015023 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020015024 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015025 {}
15026};
15027
15028static struct alc_config_preset alc861vd_presets[] = {
15029 [ALC660VD_3ST] = {
15030 .mixers = { alc861vd_3st_mixer },
15031 .init_verbs = { alc861vd_volume_init_verbs,
15032 alc861vd_3stack_init_verbs },
15033 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15034 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015035 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15036 .channel_mode = alc861vd_3stack_2ch_modes,
15037 .input_mux = &alc861vd_capture_source,
15038 },
Mike Crash6963f842007-06-25 12:12:51 +020015039 [ALC660VD_3ST_DIG] = {
15040 .mixers = { alc861vd_3st_mixer },
15041 .init_verbs = { alc861vd_volume_init_verbs,
15042 alc861vd_3stack_init_verbs },
15043 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15044 .dac_nids = alc660vd_dac_nids,
15045 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020015046 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15047 .channel_mode = alc861vd_3stack_2ch_modes,
15048 .input_mux = &alc861vd_capture_source,
15049 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015050 [ALC861VD_3ST] = {
15051 .mixers = { alc861vd_3st_mixer },
15052 .init_verbs = { alc861vd_volume_init_verbs,
15053 alc861vd_3stack_init_verbs },
15054 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15055 .dac_nids = alc861vd_dac_nids,
15056 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15057 .channel_mode = alc861vd_3stack_2ch_modes,
15058 .input_mux = &alc861vd_capture_source,
15059 },
15060 [ALC861VD_3ST_DIG] = {
15061 .mixers = { alc861vd_3st_mixer },
15062 .init_verbs = { alc861vd_volume_init_verbs,
15063 alc861vd_3stack_init_verbs },
15064 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15065 .dac_nids = alc861vd_dac_nids,
15066 .dig_out_nid = ALC861VD_DIGOUT_NID,
15067 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15068 .channel_mode = alc861vd_3stack_2ch_modes,
15069 .input_mux = &alc861vd_capture_source,
15070 },
15071 [ALC861VD_6ST_DIG] = {
15072 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
15073 .init_verbs = { alc861vd_volume_init_verbs,
15074 alc861vd_6stack_init_verbs },
15075 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15076 .dac_nids = alc861vd_dac_nids,
15077 .dig_out_nid = ALC861VD_DIGOUT_NID,
15078 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
15079 .channel_mode = alc861vd_6stack_modes,
15080 .input_mux = &alc861vd_capture_source,
15081 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020015082 [ALC861VD_LENOVO] = {
15083 .mixers = { alc861vd_lenovo_mixer },
15084 .init_verbs = { alc861vd_volume_init_verbs,
15085 alc861vd_3stack_init_verbs,
15086 alc861vd_eapd_verbs,
15087 alc861vd_lenovo_unsol_verbs },
15088 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15089 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015090 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15091 .channel_mode = alc861vd_3stack_2ch_modes,
15092 .input_mux = &alc861vd_capture_source,
15093 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015094 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015095 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015096 },
Kailang Yang272a5272007-05-14 11:00:38 +020015097 [ALC861VD_DALLAS] = {
15098 .mixers = { alc861vd_dallas_mixer },
15099 .init_verbs = { alc861vd_dallas_verbs },
15100 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15101 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020015102 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15103 .channel_mode = alc861vd_3stack_2ch_modes,
15104 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015105 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015106 .setup = alc861vd_dallas_setup,
15107 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015108 },
15109 [ALC861VD_HP] = {
15110 .mixers = { alc861vd_hp_mixer },
15111 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
15112 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15113 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015114 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015115 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15116 .channel_mode = alc861vd_3stack_2ch_modes,
15117 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015118 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015119 .setup = alc861vd_dallas_setup,
15120 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +020015121 },
Takashi Iwai13c94742008-11-05 08:06:08 +010015122 [ALC660VD_ASUS_V1S] = {
15123 .mixers = { alc861vd_lenovo_mixer },
15124 .init_verbs = { alc861vd_volume_init_verbs,
15125 alc861vd_3stack_init_verbs,
15126 alc861vd_eapd_verbs,
15127 alc861vd_lenovo_unsol_verbs },
15128 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15129 .dac_nids = alc660vd_dac_nids,
15130 .dig_out_nid = ALC861VD_DIGOUT_NID,
15131 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15132 .channel_mode = alc861vd_3stack_2ch_modes,
15133 .input_mux = &alc861vd_capture_source,
15134 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015135 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015136 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010015137 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015138};
15139
15140/*
15141 * BIOS auto configuration
15142 */
15143static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
15144 hda_nid_t nid, int pin_type, int dac_idx)
15145{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015146 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015147}
15148
15149static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
15150{
15151 struct alc_spec *spec = codec->spec;
15152 int i;
15153
15154 for (i = 0; i <= HDA_SIDE; i++) {
15155 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015156 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015157 if (nid)
15158 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015159 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015160 }
15161}
15162
15163
15164static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
15165{
15166 struct alc_spec *spec = codec->spec;
15167 hda_nid_t pin;
15168
15169 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015170 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015171 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015172 pin = spec->autocfg.speaker_pins[0];
15173 if (pin)
15174 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015175}
15176
15177#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
15178#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
15179
15180static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
15181{
15182 struct alc_spec *spec = codec->spec;
15183 int i;
15184
15185 for (i = 0; i < AUTO_PIN_LAST; i++) {
15186 hda_nid_t nid = spec->autocfg.input_pins[i];
15187 if (alc861vd_is_input_pin(nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010015188 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +010015189 if (nid != ALC861VD_PIN_CD_NID &&
15190 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015191 snd_hda_codec_write(codec, nid, 0,
15192 AC_VERB_SET_AMP_GAIN_MUTE,
15193 AMP_OUT_MUTE);
15194 }
15195 }
15196}
15197
Takashi Iwaif511b012008-08-15 16:46:42 +020015198#define alc861vd_auto_init_input_src alc882_auto_init_input_src
15199
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015200#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
15201#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
15202
15203/* add playback controls from the parsed DAC table */
15204/* Based on ALC880 version. But ALC861VD has separate,
15205 * different NIDs for mute/unmute switch and volume control */
15206static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
15207 const struct auto_pin_cfg *cfg)
15208{
15209 char name[32];
15210 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
15211 hda_nid_t nid_v, nid_s;
15212 int i, err;
15213
15214 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015215 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015216 continue;
15217 nid_v = alc861vd_idx_to_mixer_vol(
15218 alc880_dac_to_idx(
15219 spec->multiout.dac_nids[i]));
15220 nid_s = alc861vd_idx_to_mixer_switch(
15221 alc880_dac_to_idx(
15222 spec->multiout.dac_nids[i]));
15223
15224 if (i == 2) {
15225 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015226 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15227 "Center Playback Volume",
15228 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
15229 HDA_OUTPUT));
15230 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015231 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015232 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15233 "LFE Playback Volume",
15234 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
15235 HDA_OUTPUT));
15236 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015237 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015238 err = add_control(spec, ALC_CTL_BIND_MUTE,
15239 "Center Playback Switch",
15240 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
15241 HDA_INPUT));
15242 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015243 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015244 err = add_control(spec, ALC_CTL_BIND_MUTE,
15245 "LFE Playback Switch",
15246 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
15247 HDA_INPUT));
15248 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015249 return err;
15250 } else {
15251 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015252 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
15253 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
15254 HDA_OUTPUT));
15255 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015256 return err;
15257 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015258 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015259 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015260 HDA_INPUT));
15261 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015262 return err;
15263 }
15264 }
15265 return 0;
15266}
15267
15268/* add playback controls for speaker and HP outputs */
15269/* Based on ALC880 version. But ALC861VD has separate,
15270 * different NIDs for mute/unmute switch and volume control */
15271static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
15272 hda_nid_t pin, const char *pfx)
15273{
15274 hda_nid_t nid_v, nid_s;
15275 int err;
15276 char name[32];
15277
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015278 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015279 return 0;
15280
15281 if (alc880_is_fixed_pin(pin)) {
15282 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
15283 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015284 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015285 spec->multiout.hp_nid = nid_v;
15286 else
15287 spec->multiout.extra_out_nid[0] = nid_v;
15288 /* control HP volume/switch on the output mixer amp */
15289 nid_v = alc861vd_idx_to_mixer_vol(
15290 alc880_fixed_pin_idx(pin));
15291 nid_s = alc861vd_idx_to_mixer_switch(
15292 alc880_fixed_pin_idx(pin));
15293
15294 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015295 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
15296 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
15297 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015298 return err;
15299 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015300 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
15301 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
15302 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015303 return err;
15304 } else if (alc880_is_multi_pin(pin)) {
15305 /* set manual connection */
15306 /* we have only a switch on HP-out PIN */
15307 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015308 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
15309 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
15310 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015311 return err;
15312 }
15313 return 0;
15314}
15315
15316/* parse the BIOS configuration and set up the alc_spec
15317 * return 1 if successful, 0 if the proper config is not found,
15318 * or a negative error code
15319 * Based on ALC880 version - had to change it to override
15320 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
15321static int alc861vd_parse_auto_config(struct hda_codec *codec)
15322{
15323 struct alc_spec *spec = codec->spec;
15324 int err;
15325 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
15326
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015327 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15328 alc861vd_ignore);
15329 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015330 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015331 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015332 return 0; /* can't find valid BIOS pin config */
15333
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015334 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
15335 if (err < 0)
15336 return err;
15337 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
15338 if (err < 0)
15339 return err;
15340 err = alc861vd_auto_create_extra_out(spec,
15341 spec->autocfg.speaker_pins[0],
15342 "Speaker");
15343 if (err < 0)
15344 return err;
15345 err = alc861vd_auto_create_extra_out(spec,
15346 spec->autocfg.hp_pins[0],
15347 "Headphone");
15348 if (err < 0)
15349 return err;
15350 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
15351 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015352 return err;
15353
15354 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15355
Takashi Iwai0852d7a2009-02-11 11:35:15 +010015356 if (spec->autocfg.dig_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015357 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
15358
Takashi Iwai603c4012008-07-30 15:01:44 +020015359 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010015360 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015361
Takashi Iwaid88897e2008-10-31 15:01:37 +010015362 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015363
15364 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015365 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015366
Takashi Iwai776e1842007-08-29 15:07:11 +020015367 err = alc_auto_add_mic_boost(codec);
15368 if (err < 0)
15369 return err;
15370
Takashi Iwai4a79ba32009-04-22 16:31:35 +020015371 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
15372
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015373 return 1;
15374}
15375
15376/* additional initialization for auto-configuration model */
15377static void alc861vd_auto_init(struct hda_codec *codec)
15378{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015379 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015380 alc861vd_auto_init_multi_out(codec);
15381 alc861vd_auto_init_hp_out(codec);
15382 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020015383 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015384 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020015385 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015386}
15387
15388static int patch_alc861vd(struct hda_codec *codec)
15389{
15390 struct alc_spec *spec;
15391 int err, board_config;
15392
15393 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15394 if (spec == NULL)
15395 return -ENOMEM;
15396
15397 codec->spec = spec;
15398
15399 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
15400 alc861vd_models,
15401 alc861vd_cfg_tbl);
15402
15403 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020015404 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
15405 codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015406 board_config = ALC861VD_AUTO;
15407 }
15408
15409 if (board_config == ALC861VD_AUTO) {
15410 /* automatic parse from the BIOS config */
15411 err = alc861vd_parse_auto_config(codec);
15412 if (err < 0) {
15413 alc_free(codec);
15414 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015415 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015416 printk(KERN_INFO
15417 "hda_codec: Cannot set up configuration "
15418 "from BIOS. Using base mode...\n");
15419 board_config = ALC861VD_3ST;
15420 }
15421 }
15422
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015423 err = snd_hda_attach_beep_device(codec, 0x23);
15424 if (err < 0) {
15425 alc_free(codec);
15426 return err;
15427 }
15428
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015429 if (board_config != ALC861VD_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020015430 setup_preset(codec, &alc861vd_presets[board_config]);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015431
Kailang Yang2f893282008-05-27 12:14:47 +020015432 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020015433 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010015434 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020015435 }
15436
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015437 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
15438 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
15439
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015440 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
15441 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
15442
Takashi Iwaidd704692009-08-11 08:45:11 +020015443 if (!spec->adc_nids) {
15444 spec->adc_nids = alc861vd_adc_nids;
15445 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
15446 }
15447 if (!spec->capsrc_nids)
15448 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015449
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015450 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015451 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015452
Takashi Iwai2134ea42008-01-10 16:53:55 +010015453 spec->vmaster_nid = 0x02;
15454
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015455 codec->patch_ops = alc_patch_ops;
15456
15457 if (board_config == ALC861VD_AUTO)
15458 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015459#ifdef CONFIG_SND_HDA_POWER_SAVE
15460 if (!spec->loopback.amplist)
15461 spec->loopback.amplist = alc861vd_loopbacks;
15462#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010015463 codec->proc_widget_hook = print_realtek_coef;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015464
15465 return 0;
15466}
15467
15468/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015469 * ALC662 support
15470 *
15471 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
15472 * configuration. Each pin widget can choose any input DACs and a mixer.
15473 * Each ADC is connected from a mixer of all inputs. This makes possible
15474 * 6-channel independent captures.
15475 *
15476 * In addition, an independent DAC for the multi-playback (not used in this
15477 * driver yet).
15478 */
15479#define ALC662_DIGOUT_NID 0x06
15480#define ALC662_DIGIN_NID 0x0a
15481
15482static hda_nid_t alc662_dac_nids[4] = {
15483 /* front, rear, clfe, rear_surr */
15484 0x02, 0x03, 0x04
15485};
15486
Kailang Yang622e84c2009-04-21 07:39:04 +020015487static hda_nid_t alc272_dac_nids[2] = {
15488 0x02, 0x03
15489};
15490
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015491static hda_nid_t alc662_adc_nids[2] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015492 /* ADC1-2 */
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015493 0x09, 0x08
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015494};
Takashi Iwaie1406342008-02-11 18:32:32 +010015495
Kailang Yang622e84c2009-04-21 07:39:04 +020015496static hda_nid_t alc272_adc_nids[1] = {
15497 /* ADC1-2 */
15498 0x08,
15499};
15500
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015501static hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
Kailang Yang622e84c2009-04-21 07:39:04 +020015502static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
15503
Takashi Iwaie1406342008-02-11 18:32:32 +010015504
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015505/* input MUX */
15506/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015507static struct hda_input_mux alc662_capture_source = {
15508 .num_items = 4,
15509 .items = {
15510 { "Mic", 0x0 },
15511 { "Front Mic", 0x1 },
15512 { "Line", 0x2 },
15513 { "CD", 0x4 },
15514 },
15515};
15516
15517static struct hda_input_mux alc662_lenovo_101e_capture_source = {
15518 .num_items = 2,
15519 .items = {
15520 { "Mic", 0x1 },
15521 { "Line", 0x2 },
15522 },
15523};
Kailang Yang291702f2007-10-16 14:28:03 +020015524
Kailang Yang6dda9f42008-05-27 12:05:31 +020015525static struct hda_input_mux alc663_capture_source = {
15526 .num_items = 3,
15527 .items = {
15528 { "Mic", 0x0 },
15529 { "Front Mic", 0x1 },
15530 { "Line", 0x2 },
15531 },
15532};
15533
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015534#if 0 /* set to 1 for testing other input sources below */
Chris Pockelé9541ba12009-05-12 08:08:53 +020015535static struct hda_input_mux alc272_nc10_capture_source = {
15536 .num_items = 16,
15537 .items = {
15538 { "Autoselect Mic", 0x0 },
15539 { "Internal Mic", 0x1 },
15540 { "In-0x02", 0x2 },
15541 { "In-0x03", 0x3 },
15542 { "In-0x04", 0x4 },
15543 { "In-0x05", 0x5 },
15544 { "In-0x06", 0x6 },
15545 { "In-0x07", 0x7 },
15546 { "In-0x08", 0x8 },
15547 { "In-0x09", 0x9 },
15548 { "In-0x0a", 0x0a },
15549 { "In-0x0b", 0x0b },
15550 { "In-0x0c", 0x0c },
15551 { "In-0x0d", 0x0d },
15552 { "In-0x0e", 0x0e },
15553 { "In-0x0f", 0x0f },
15554 },
15555};
15556#endif
15557
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015558/*
15559 * 2ch mode
15560 */
15561static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
15562 { 2, NULL }
15563};
15564
15565/*
15566 * 2ch mode
15567 */
15568static struct hda_verb alc662_3ST_ch2_init[] = {
15569 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
15570 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15571 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
15572 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15573 { } /* end */
15574};
15575
15576/*
15577 * 6ch mode
15578 */
15579static struct hda_verb alc662_3ST_ch6_init[] = {
15580 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15581 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15582 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
15583 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15584 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15585 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
15586 { } /* end */
15587};
15588
15589static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
15590 { 2, alc662_3ST_ch2_init },
15591 { 6, alc662_3ST_ch6_init },
15592};
15593
15594/*
15595 * 2ch mode
15596 */
15597static struct hda_verb alc662_sixstack_ch6_init[] = {
15598 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15599 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15600 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15601 { } /* end */
15602};
15603
15604/*
15605 * 6ch mode
15606 */
15607static struct hda_verb alc662_sixstack_ch8_init[] = {
15608 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15609 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15610 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15611 { } /* end */
15612};
15613
15614static struct hda_channel_mode alc662_5stack_modes[2] = {
15615 { 2, alc662_sixstack_ch6_init },
15616 { 6, alc662_sixstack_ch8_init },
15617};
15618
15619/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15620 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15621 */
15622
15623static struct snd_kcontrol_new alc662_base_mixer[] = {
15624 /* output mixer control */
15625 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015626 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015627 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015628 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015629 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15630 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015631 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15632 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015633 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15634
15635 /*Input mixer control */
15636 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
15637 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
15638 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
15639 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
15640 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
15641 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
15642 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
15643 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015644 { } /* end */
15645};
15646
15647static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
15648 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015649 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015650 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15651 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15652 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15653 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15654 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15655 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15656 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15657 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15658 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015659 { } /* end */
15660};
15661
15662static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
15663 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015664 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015665 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015666 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015667 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15668 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015669 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15670 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015671 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15672 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15673 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15674 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15675 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15676 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15677 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15678 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15679 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015680 { } /* end */
15681};
15682
15683static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
15684 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15685 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010015686 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15687 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015688 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15689 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15690 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15691 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15692 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015693 { } /* end */
15694};
15695
Kailang Yang291702f2007-10-16 14:28:03 +020015696static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020015697 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15698 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020015699
15700 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
15701 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15702 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15703
15704 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
15705 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15706 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15707 { } /* end */
15708};
15709
Kailang Yang8c427222008-01-10 13:03:59 +010015710static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020015711 ALC262_HIPPO_MASTER_SWITCH,
15712 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015713 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015714 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15715 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015716 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
15717 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15718 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15719 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15720 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15721 { } /* end */
15722};
15723
Kailang Yangf1d4e282008-08-26 14:03:29 +020015724static struct hda_bind_ctls alc663_asus_bind_master_vol = {
15725 .ops = &snd_hda_bind_vol,
15726 .values = {
15727 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15728 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
15729 0
15730 },
15731};
15732
15733static struct hda_bind_ctls alc663_asus_one_bind_switch = {
15734 .ops = &snd_hda_bind_sw,
15735 .values = {
15736 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15737 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15738 0
15739 },
15740};
15741
Kailang Yang6dda9f42008-05-27 12:05:31 +020015742static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015743 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15744 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
15745 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15746 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15747 { } /* end */
15748};
15749
15750static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
15751 .ops = &snd_hda_bind_sw,
15752 .values = {
15753 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15754 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15755 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15756 0
15757 },
15758};
15759
15760static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
15761 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15762 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
15763 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15764 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15765 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15766 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15767
15768 { } /* end */
15769};
15770
15771static struct hda_bind_ctls alc663_asus_four_bind_switch = {
15772 .ops = &snd_hda_bind_sw,
15773 .values = {
15774 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15775 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15776 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
15777 0
15778 },
15779};
15780
15781static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
15782 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15783 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
15784 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15785 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15786 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15787 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15788 { } /* end */
15789};
15790
15791static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020015792 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15793 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015794 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15795 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15796 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15797 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15798 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15799 { } /* end */
15800};
15801
15802static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
15803 .ops = &snd_hda_bind_vol,
15804 .values = {
15805 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15806 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
15807 0
15808 },
15809};
15810
15811static struct hda_bind_ctls alc663_asus_two_bind_switch = {
15812 .ops = &snd_hda_bind_sw,
15813 .values = {
15814 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15815 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
15816 0
15817 },
15818};
15819
15820static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
15821 HDA_BIND_VOL("Master Playback Volume",
15822 &alc663_asus_two_bind_master_vol),
15823 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15824 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015825 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15826 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15827 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015828 { } /* end */
15829};
15830
15831static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
15832 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15833 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15834 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15835 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15836 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15837 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015838 { } /* end */
15839};
15840
15841static struct snd_kcontrol_new alc663_g71v_mixer[] = {
15842 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15843 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15844 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15845 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15846 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15847
15848 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15849 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15850 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15851 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15852 { } /* end */
15853};
15854
15855static struct snd_kcontrol_new alc663_g50v_mixer[] = {
15856 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15857 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15858 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15859
15860 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15861 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15862 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15863 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15864 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15865 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15866 { } /* end */
15867};
15868
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015869static struct snd_kcontrol_new alc662_chmode_mixer[] = {
15870 {
15871 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15872 .name = "Channel Mode",
15873 .info = alc_ch_mode_info,
15874 .get = alc_ch_mode_get,
15875 .put = alc_ch_mode_put,
15876 },
15877 { } /* end */
15878};
15879
15880static struct hda_verb alc662_init_verbs[] = {
15881 /* ADC: mute amp left and right */
15882 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15883 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15884 /* Front mixer: unmute input/output amp left and right (volume = 0) */
15885
Takashi Iwaicb53c622007-08-10 17:21:45 +020015886 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15887 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15888 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15889 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15890 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015891
Kailang Yangb60dd392007-09-20 12:50:29 +020015892 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15893 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15894 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15895 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15896 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15897 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015898
15899 /* Front Pin: output 0 (0x0c) */
15900 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15901 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15902
15903 /* Rear Pin: output 1 (0x0d) */
15904 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15905 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15906
15907 /* CLFE Pin: output 2 (0x0e) */
15908 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15909 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15910
15911 /* Mic (rear) pin: input vref at 80% */
15912 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15913 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15914 /* Front Mic pin: input vref at 80% */
15915 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15916 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15917 /* Line In pin: input */
15918 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15919 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15920 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15921 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15922 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15923 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15924 /* CD pin widget for input */
15925 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15926
15927 /* FIXME: use matrix-type input source selection */
15928 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15929 /* Input mixer */
15930 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020015931 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015932
15933 /* always trun on EAPD */
15934 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15935 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
15936
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015937 { }
15938};
15939
15940static struct hda_verb alc662_sue_init_verbs[] = {
15941 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15942 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020015943 {}
15944};
15945
15946static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
15947 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15948 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15949 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015950};
15951
Kailang Yang8c427222008-01-10 13:03:59 +010015952/* Set Unsolicited Event*/
15953static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
15954 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15955 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15956 {}
15957};
15958
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015959/*
15960 * generic initialization of ADC, input mixers and output mixers
15961 */
15962static struct hda_verb alc662_auto_init_verbs[] = {
15963 /*
15964 * Unmute ADC and set the default input to mic-in
15965 */
15966 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15967 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15968
15969 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
15970 * mixer widget
15971 * Note: PASD motherboards uses the Line In 2 as the input for front
15972 * panel mic (mic 2)
15973 */
15974 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020015975 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15976 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15977 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15978 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15979 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015980
15981 /*
15982 * Set up output mixers (0x0c - 0x0f)
15983 */
15984 /* set vol=0 to output mixers */
15985 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15986 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15987 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15988
15989 /* set up input amps for analog loopback */
15990 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020015991 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15992 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15993 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15994 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15995 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15996 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015997
15998
15999 /* FIXME: use matrix-type input source selection */
16000 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
16001 /* Input mixer */
16002 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020016003 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016004 { }
16005};
16006
Takashi Iwai24fb9172008-09-02 14:48:20 +020016007/* additional verbs for ALC663 */
16008static struct hda_verb alc663_auto_init_verbs[] = {
16009 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16010 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16011 { }
16012};
16013
Kailang Yang6dda9f42008-05-27 12:05:31 +020016014static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020016015 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16016 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016017 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16018 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020016019 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16020 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16021 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016022 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16023 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16024 {}
16025};
16026
Kailang Yangf1d4e282008-08-26 14:03:29 +020016027static struct hda_verb alc663_21jd_amic_init_verbs[] = {
16028 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16029 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16030 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16031 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16032 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16033 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16034 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16035 {}
16036};
16037
16038static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
16039 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16040 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16041 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16042 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16043 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16044 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16045 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16046 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16047 {}
16048};
16049
16050static struct hda_verb alc663_15jd_amic_init_verbs[] = {
16051 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16052 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16053 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16054 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16055 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16056 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16057 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16058 {}
16059};
16060
16061static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
16062 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16063 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16064 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16065 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16066 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16067 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16068 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16069 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16070 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16071 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16072 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16073 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16074 {}
16075};
16076
16077static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
16078 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16079 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16080 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16081 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16082 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16083 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16084 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16085 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16086 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16087 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16088 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16089 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16090 {}
16091};
16092
Kailang Yang6dda9f42008-05-27 12:05:31 +020016093static struct hda_verb alc663_g71v_init_verbs[] = {
16094 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16095 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
16096 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
16097
16098 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16099 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16100 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16101
16102 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16103 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
16104 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
16105 {}
16106};
16107
16108static struct hda_verb alc663_g50v_init_verbs[] = {
16109 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16110 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16111 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16112
16113 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16114 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16115 {}
16116};
16117
Kailang Yangf1d4e282008-08-26 14:03:29 +020016118static struct hda_verb alc662_ecs_init_verbs[] = {
16119 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
16120 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16121 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16122 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16123 {}
16124};
16125
Kailang Yang622e84c2009-04-21 07:39:04 +020016126static struct hda_verb alc272_dell_zm1_init_verbs[] = {
16127 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16128 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16129 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
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, 0x01}, /* Headphone */
16134 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16135 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16136 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16137 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16138 {}
16139};
16140
16141static struct hda_verb alc272_dell_init_verbs[] = {
16142 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16143 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16144 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16145 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16146 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16147 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16148 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16149 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16150 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16151 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16152 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16153 {}
16154};
16155
Kailang Yangf1d4e282008-08-26 14:03:29 +020016156static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
16157 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
16158 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
16159 { } /* end */
16160};
16161
Kailang Yang622e84c2009-04-21 07:39:04 +020016162static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
16163 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
16164 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
16165 { } /* end */
16166};
16167
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016168static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
16169{
16170 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016171 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016172
16173 present = snd_hda_codec_read(codec, 0x14, 0,
16174 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020016175 bits = present ? HDA_AMP_MUTE : 0;
16176 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16177 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016178}
16179
16180static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
16181{
16182 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016183 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016184
16185 present = snd_hda_codec_read(codec, 0x1b, 0,
16186 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020016187 bits = present ? HDA_AMP_MUTE : 0;
16188 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16189 HDA_AMP_MUTE, bits);
16190 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16191 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016192}
16193
16194static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
16195 unsigned int res)
16196{
16197 if ((res >> 26) == ALC880_HP_EVENT)
16198 alc662_lenovo_101e_all_automute(codec);
16199 if ((res >> 26) == ALC880_FRONT_EVENT)
16200 alc662_lenovo_101e_ispeaker_automute(codec);
16201}
16202
Kailang Yang291702f2007-10-16 14:28:03 +020016203/* unsolicited event for HP jack sensing */
16204static void alc662_eeepc_unsol_event(struct hda_codec *codec,
16205 unsigned int res)
16206{
Kailang Yang291702f2007-10-16 14:28:03 +020016207 if ((res >> 26) == ALC880_MIC_EVENT)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016208 alc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020016209 else
16210 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020016211}
16212
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016213static void alc662_eeepc_setup(struct hda_codec *codec)
Kailang Yang291702f2007-10-16 14:28:03 +020016214{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016215 struct alc_spec *spec = codec->spec;
16216
16217 alc262_hippo1_setup(codec);
16218 spec->ext_mic.pin = 0x18;
16219 spec->ext_mic.mux_idx = 0;
16220 spec->int_mic.pin = 0x19;
16221 spec->int_mic.mux_idx = 1;
16222 spec->auto_mic = 1;
Kailang Yang291702f2007-10-16 14:28:03 +020016223}
16224
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016225static void alc662_eeepc_inithook(struct hda_codec *codec)
16226{
16227 alc262_hippo_automute(codec);
16228 alc_mic_automute(codec);
16229}
16230
16231static void alc662_eeepc_ep20_setup(struct hda_codec *codec)
Kailang Yang8c427222008-01-10 13:03:59 +010016232{
Takashi Iwai42171c12009-05-08 14:11:43 +020016233 struct alc_spec *spec = codec->spec;
16234
16235 spec->autocfg.hp_pins[0] = 0x14;
16236 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang8c427222008-01-10 13:03:59 +010016237}
16238
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016239#define alc662_eeepc_ep20_inithook alc262_hippo_master_update
16240
Kailang Yang6dda9f42008-05-27 12:05:31 +020016241static void alc663_m51va_speaker_automute(struct hda_codec *codec)
16242{
16243 unsigned int present;
16244 unsigned char bits;
16245
16246 present = snd_hda_codec_read(codec, 0x21, 0,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016247 AC_VERB_GET_PIN_SENSE, 0)
16248 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020016249 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020016250 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16251 AMP_IN_MUTE(0), bits);
16252 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16253 AMP_IN_MUTE(0), bits);
16254}
16255
16256static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
16257{
16258 unsigned int present;
16259 unsigned char bits;
16260
16261 present = snd_hda_codec_read(codec, 0x21, 0,
16262 AC_VERB_GET_PIN_SENSE, 0)
16263 & AC_PINSENSE_PRESENCE;
16264 bits = present ? HDA_AMP_MUTE : 0;
16265 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16266 AMP_IN_MUTE(0), bits);
16267 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16268 AMP_IN_MUTE(0), bits);
16269 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16270 AMP_IN_MUTE(0), bits);
16271 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16272 AMP_IN_MUTE(0), bits);
16273}
16274
16275static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
16276{
16277 unsigned int present;
16278 unsigned char bits;
16279
16280 present = snd_hda_codec_read(codec, 0x15, 0,
16281 AC_VERB_GET_PIN_SENSE, 0)
16282 & AC_PINSENSE_PRESENCE;
16283 bits = present ? HDA_AMP_MUTE : 0;
16284 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16285 AMP_IN_MUTE(0), bits);
16286 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16287 AMP_IN_MUTE(0), bits);
16288 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16289 AMP_IN_MUTE(0), bits);
16290 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16291 AMP_IN_MUTE(0), bits);
16292}
16293
16294static void alc662_f5z_speaker_automute(struct hda_codec *codec)
16295{
16296 unsigned int present;
16297 unsigned char bits;
16298
16299 present = snd_hda_codec_read(codec, 0x1b, 0,
16300 AC_VERB_GET_PIN_SENSE, 0)
16301 & AC_PINSENSE_PRESENCE;
16302 bits = present ? 0 : PIN_OUT;
16303 snd_hda_codec_write(codec, 0x14, 0,
16304 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
16305}
16306
16307static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
16308{
16309 unsigned int present1, present2;
16310
16311 present1 = snd_hda_codec_read(codec, 0x21, 0,
16312 AC_VERB_GET_PIN_SENSE, 0)
16313 & AC_PINSENSE_PRESENCE;
16314 present2 = snd_hda_codec_read(codec, 0x15, 0,
16315 AC_VERB_GET_PIN_SENSE, 0)
16316 & AC_PINSENSE_PRESENCE;
16317
16318 if (present1 || present2) {
16319 snd_hda_codec_write_cache(codec, 0x14, 0,
16320 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16321 } else {
16322 snd_hda_codec_write_cache(codec, 0x14, 0,
16323 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16324 }
16325}
16326
16327static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
16328{
16329 unsigned int present1, present2;
16330
16331 present1 = snd_hda_codec_read(codec, 0x1b, 0,
16332 AC_VERB_GET_PIN_SENSE, 0)
16333 & AC_PINSENSE_PRESENCE;
16334 present2 = snd_hda_codec_read(codec, 0x15, 0,
16335 AC_VERB_GET_PIN_SENSE, 0)
16336 & AC_PINSENSE_PRESENCE;
16337
16338 if (present1 || present2) {
16339 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16340 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16341 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16342 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16343 } else {
16344 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16345 AMP_IN_MUTE(0), 0);
16346 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16347 AMP_IN_MUTE(0), 0);
16348 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020016349}
16350
Kailang Yang6dda9f42008-05-27 12:05:31 +020016351static void alc663_m51va_unsol_event(struct hda_codec *codec,
16352 unsigned int res)
16353{
16354 switch (res >> 26) {
16355 case ALC880_HP_EVENT:
16356 alc663_m51va_speaker_automute(codec);
16357 break;
16358 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016359 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016360 break;
16361 }
16362}
16363
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016364static void alc663_m51va_setup(struct hda_codec *codec)
16365{
16366 struct alc_spec *spec = codec->spec;
16367 spec->ext_mic.pin = 0x18;
16368 spec->ext_mic.mux_idx = 0;
16369 spec->int_mic.pin = 0x12;
16370 spec->int_mic.mux_idx = 1;
16371 spec->auto_mic = 1;
16372}
16373
Kailang Yang6dda9f42008-05-27 12:05:31 +020016374static void alc663_m51va_inithook(struct hda_codec *codec)
16375{
16376 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016377 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016378}
16379
Kailang Yangf1d4e282008-08-26 14:03:29 +020016380/* ***************** Mode1 ******************************/
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016381#define alc663_mode1_unsol_event alc663_m51va_unsol_event
16382#define alc663_mode1_setup alc663_m51va_setup
16383#define alc663_mode1_inithook alc663_m51va_inithook
Kailang Yangf1d4e282008-08-26 14:03:29 +020016384
Kailang Yangf1d4e282008-08-26 14:03:29 +020016385/* ***************** Mode2 ******************************/
16386static void alc662_mode2_unsol_event(struct hda_codec *codec,
16387 unsigned int res)
16388{
16389 switch (res >> 26) {
16390 case ALC880_HP_EVENT:
16391 alc662_f5z_speaker_automute(codec);
16392 break;
16393 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016394 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016395 break;
16396 }
16397}
16398
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016399#define alc662_mode2_setup alc663_m51va_setup
16400
Kailang Yangf1d4e282008-08-26 14:03:29 +020016401static void alc662_mode2_inithook(struct hda_codec *codec)
16402{
16403 alc662_f5z_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016404 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016405}
16406/* ***************** Mode3 ******************************/
16407static void alc663_mode3_unsol_event(struct hda_codec *codec,
16408 unsigned int res)
16409{
16410 switch (res >> 26) {
16411 case ALC880_HP_EVENT:
16412 alc663_two_hp_m1_speaker_automute(codec);
16413 break;
16414 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016415 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016416 break;
16417 }
16418}
16419
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016420#define alc663_mode3_setup alc663_m51va_setup
16421
Kailang Yangf1d4e282008-08-26 14:03:29 +020016422static void alc663_mode3_inithook(struct hda_codec *codec)
16423{
16424 alc663_two_hp_m1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016425 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016426}
16427/* ***************** Mode4 ******************************/
16428static void alc663_mode4_unsol_event(struct hda_codec *codec,
16429 unsigned int res)
16430{
16431 switch (res >> 26) {
16432 case ALC880_HP_EVENT:
16433 alc663_21jd_two_speaker_automute(codec);
16434 break;
16435 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016436 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016437 break;
16438 }
16439}
16440
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016441#define alc663_mode4_setup alc663_m51va_setup
16442
Kailang Yangf1d4e282008-08-26 14:03:29 +020016443static void alc663_mode4_inithook(struct hda_codec *codec)
16444{
16445 alc663_21jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016446 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016447}
16448/* ***************** Mode5 ******************************/
16449static void alc663_mode5_unsol_event(struct hda_codec *codec,
16450 unsigned int res)
16451{
16452 switch (res >> 26) {
16453 case ALC880_HP_EVENT:
16454 alc663_15jd_two_speaker_automute(codec);
16455 break;
16456 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016457 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016458 break;
16459 }
16460}
16461
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016462#define alc663_mode5_setup alc663_m51va_setup
16463
Kailang Yangf1d4e282008-08-26 14:03:29 +020016464static void alc663_mode5_inithook(struct hda_codec *codec)
16465{
16466 alc663_15jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016467 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016468}
16469/* ***************** Mode6 ******************************/
16470static void alc663_mode6_unsol_event(struct hda_codec *codec,
16471 unsigned int res)
16472{
16473 switch (res >> 26) {
16474 case ALC880_HP_EVENT:
16475 alc663_two_hp_m2_speaker_automute(codec);
16476 break;
16477 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016478 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016479 break;
16480 }
16481}
16482
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016483#define alc663_mode6_setup alc663_m51va_setup
16484
Kailang Yangf1d4e282008-08-26 14:03:29 +020016485static void alc663_mode6_inithook(struct hda_codec *codec)
16486{
16487 alc663_two_hp_m2_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016488 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016489}
16490
Kailang Yang6dda9f42008-05-27 12:05:31 +020016491static void alc663_g71v_hp_automute(struct hda_codec *codec)
16492{
16493 unsigned int present;
16494 unsigned char bits;
16495
16496 present = snd_hda_codec_read(codec, 0x21, 0,
16497 AC_VERB_GET_PIN_SENSE, 0)
16498 & AC_PINSENSE_PRESENCE;
16499 bits = present ? HDA_AMP_MUTE : 0;
16500 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16501 HDA_AMP_MUTE, bits);
16502 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16503 HDA_AMP_MUTE, bits);
16504}
16505
16506static void alc663_g71v_front_automute(struct hda_codec *codec)
16507{
16508 unsigned int present;
16509 unsigned char bits;
16510
16511 present = snd_hda_codec_read(codec, 0x15, 0,
16512 AC_VERB_GET_PIN_SENSE, 0)
16513 & AC_PINSENSE_PRESENCE;
16514 bits = present ? HDA_AMP_MUTE : 0;
16515 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16516 HDA_AMP_MUTE, bits);
16517}
16518
16519static void alc663_g71v_unsol_event(struct hda_codec *codec,
16520 unsigned int res)
16521{
16522 switch (res >> 26) {
16523 case ALC880_HP_EVENT:
16524 alc663_g71v_hp_automute(codec);
16525 break;
16526 case ALC880_FRONT_EVENT:
16527 alc663_g71v_front_automute(codec);
16528 break;
16529 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016530 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016531 break;
16532 }
16533}
16534
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016535#define alc663_g71v_setup alc663_m51va_setup
16536
Kailang Yang6dda9f42008-05-27 12:05:31 +020016537static void alc663_g71v_inithook(struct hda_codec *codec)
16538{
16539 alc663_g71v_front_automute(codec);
16540 alc663_g71v_hp_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016541 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016542}
16543
16544static void alc663_g50v_unsol_event(struct hda_codec *codec,
16545 unsigned int res)
16546{
16547 switch (res >> 26) {
16548 case ALC880_HP_EVENT:
16549 alc663_m51va_speaker_automute(codec);
16550 break;
16551 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016552 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016553 break;
16554 }
16555}
16556
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016557#define alc663_g50v_setup alc663_m51va_setup
16558
Kailang Yang6dda9f42008-05-27 12:05:31 +020016559static void alc663_g50v_inithook(struct hda_codec *codec)
16560{
16561 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016562 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016563}
16564
Kailang Yangf1d4e282008-08-26 14:03:29 +020016565static struct snd_kcontrol_new alc662_ecs_mixer[] = {
16566 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020016567 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016568
16569 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
16570 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
16571 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
16572
16573 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16574 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16575 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16576 { } /* end */
16577};
16578
Chris Pockelé9541ba12009-05-12 08:08:53 +020016579static struct snd_kcontrol_new alc272_nc10_mixer[] = {
16580 /* Master Playback automatically created from Speaker and Headphone */
16581 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16582 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16583 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16584 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16585
16586 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16587 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16588 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
16589
16590 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16591 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16592 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
16593 { } /* end */
16594};
16595
Takashi Iwaicb53c622007-08-10 17:21:45 +020016596#ifdef CONFIG_SND_HDA_POWER_SAVE
16597#define alc662_loopbacks alc880_loopbacks
16598#endif
16599
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016600
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016601/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016602#define alc662_pcm_analog_playback alc880_pcm_analog_playback
16603#define alc662_pcm_analog_capture alc880_pcm_analog_capture
16604#define alc662_pcm_digital_playback alc880_pcm_digital_playback
16605#define alc662_pcm_digital_capture alc880_pcm_digital_capture
16606
16607/*
16608 * configuration and preset
16609 */
16610static const char *alc662_models[ALC662_MODEL_LAST] = {
16611 [ALC662_3ST_2ch_DIG] = "3stack-dig",
16612 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
16613 [ALC662_3ST_6ch] = "3stack-6ch",
16614 [ALC662_5ST_DIG] = "6stack-dig",
16615 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020016616 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010016617 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016618 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020016619 [ALC663_ASUS_M51VA] = "m51va",
16620 [ALC663_ASUS_G71V] = "g71v",
16621 [ALC663_ASUS_H13] = "h13",
16622 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016623 [ALC663_ASUS_MODE1] = "asus-mode1",
16624 [ALC662_ASUS_MODE2] = "asus-mode2",
16625 [ALC663_ASUS_MODE3] = "asus-mode3",
16626 [ALC663_ASUS_MODE4] = "asus-mode4",
16627 [ALC663_ASUS_MODE5] = "asus-mode5",
16628 [ALC663_ASUS_MODE6] = "asus-mode6",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020016629 [ALC272_DELL] = "dell",
16630 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020016631 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016632 [ALC662_AUTO] = "auto",
16633};
16634
16635static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010016636 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020016637 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
16638 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016639 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
16640 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
16641 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
16642 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
16643 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
16644 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
16645 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
16646 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
16647 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
16648 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
16649 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
16650 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016651 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
16652 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
16653 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016654 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
16655 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
16656 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
16657 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016658 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016659 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
16660 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016661 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016662 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
16663 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
16664 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020016665 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
16666 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
16667 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016668 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
16669 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
16670 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016671 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016672 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
16673 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020016674 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016675 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020016676 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016677 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
16678 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
16679 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016680 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016681 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
16682 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010016683 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020016684 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010016685 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016686 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030016687 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
16688 ALC662_3ST_6ch_DIG),
Chris Pockelé9541ba12009-05-12 08:08:53 +020016689 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030016690 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
16691 ALC662_3ST_6ch_DIG),
Vedran Miletic19c009a2008-09-29 20:29:25 +020016692 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020016693 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016694 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020016695 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020016696 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016697 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
16698 ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016699 {}
16700};
16701
16702static struct alc_config_preset alc662_presets[] = {
16703 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016704 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016705 .init_verbs = { alc662_init_verbs },
16706 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16707 .dac_nids = alc662_dac_nids,
16708 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016709 .dig_in_nid = ALC662_DIGIN_NID,
16710 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16711 .channel_mode = alc662_3ST_2ch_modes,
16712 .input_mux = &alc662_capture_source,
16713 },
16714 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016715 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016716 .init_verbs = { alc662_init_verbs },
16717 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16718 .dac_nids = alc662_dac_nids,
16719 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016720 .dig_in_nid = ALC662_DIGIN_NID,
16721 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16722 .channel_mode = alc662_3ST_6ch_modes,
16723 .need_dac_fix = 1,
16724 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016725 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016726 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016727 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016728 .init_verbs = { alc662_init_verbs },
16729 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16730 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016731 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16732 .channel_mode = alc662_3ST_6ch_modes,
16733 .need_dac_fix = 1,
16734 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016735 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016736 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016737 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016738 .init_verbs = { alc662_init_verbs },
16739 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16740 .dac_nids = alc662_dac_nids,
16741 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016742 .dig_in_nid = ALC662_DIGIN_NID,
16743 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
16744 .channel_mode = alc662_5stack_modes,
16745 .input_mux = &alc662_capture_source,
16746 },
16747 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016748 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016749 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
16750 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16751 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016752 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16753 .channel_mode = alc662_3ST_2ch_modes,
16754 .input_mux = &alc662_lenovo_101e_capture_source,
16755 .unsol_event = alc662_lenovo_101e_unsol_event,
16756 .init_hook = alc662_lenovo_101e_all_automute,
16757 },
Kailang Yang291702f2007-10-16 14:28:03 +020016758 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016759 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020016760 .init_verbs = { alc662_init_verbs,
16761 alc662_eeepc_sue_init_verbs },
16762 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16763 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020016764 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16765 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang291702f2007-10-16 14:28:03 +020016766 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016767 .setup = alc662_eeepc_setup,
Kailang Yang291702f2007-10-16 14:28:03 +020016768 .init_hook = alc662_eeepc_inithook,
16769 },
Kailang Yang8c427222008-01-10 13:03:59 +010016770 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016771 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010016772 alc662_chmode_mixer },
16773 .init_verbs = { alc662_init_verbs,
16774 alc662_eeepc_ep20_sue_init_verbs },
16775 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16776 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010016777 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16778 .channel_mode = alc662_3ST_6ch_modes,
16779 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020016780 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016781 .setup = alc662_eeepc_ep20_setup,
Kailang Yang8c427222008-01-10 13:03:59 +010016782 .init_hook = alc662_eeepc_ep20_inithook,
16783 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016784 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016785 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016786 .init_verbs = { alc662_init_verbs,
16787 alc662_ecs_init_verbs },
16788 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16789 .dac_nids = alc662_dac_nids,
16790 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16791 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016792 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016793 .setup = alc662_eeepc_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016794 .init_hook = alc662_eeepc_inithook,
16795 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016796 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016797 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016798 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16799 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16800 .dac_nids = alc662_dac_nids,
16801 .dig_out_nid = ALC662_DIGOUT_NID,
16802 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16803 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020016804 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016805 .setup = alc663_m51va_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020016806 .init_hook = alc663_m51va_inithook,
16807 },
16808 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016809 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016810 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
16811 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16812 .dac_nids = alc662_dac_nids,
16813 .dig_out_nid = ALC662_DIGOUT_NID,
16814 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16815 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020016816 .unsol_event = alc663_g71v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016817 .setup = alc663_g71v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020016818 .init_hook = alc663_g71v_inithook,
16819 },
16820 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016821 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016822 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16823 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16824 .dac_nids = alc662_dac_nids,
16825 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16826 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020016827 .unsol_event = alc663_m51va_unsol_event,
16828 .init_hook = alc663_m51va_inithook,
16829 },
16830 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016831 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016832 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
16833 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16834 .dac_nids = alc662_dac_nids,
16835 .dig_out_nid = ALC662_DIGOUT_NID,
16836 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16837 .channel_mode = alc662_3ST_6ch_modes,
16838 .input_mux = &alc663_capture_source,
16839 .unsol_event = alc663_g50v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016840 .setup = alc663_g50v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020016841 .init_hook = alc663_g50v_inithook,
16842 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016843 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016844 .mixers = { alc663_m51va_mixer },
16845 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016846 .init_verbs = { alc662_init_verbs,
16847 alc663_21jd_amic_init_verbs },
16848 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16849 .hp_nid = 0x03,
16850 .dac_nids = alc662_dac_nids,
16851 .dig_out_nid = ALC662_DIGOUT_NID,
16852 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16853 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016854 .unsol_event = alc663_mode1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016855 .setup = alc663_mode1_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016856 .init_hook = alc663_mode1_inithook,
16857 },
16858 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016859 .mixers = { alc662_1bjd_mixer },
16860 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016861 .init_verbs = { alc662_init_verbs,
16862 alc662_1bjd_amic_init_verbs },
16863 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16864 .dac_nids = alc662_dac_nids,
16865 .dig_out_nid = ALC662_DIGOUT_NID,
16866 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16867 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016868 .unsol_event = alc662_mode2_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016869 .setup = alc662_mode2_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016870 .init_hook = alc662_mode2_inithook,
16871 },
16872 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016873 .mixers = { alc663_two_hp_m1_mixer },
16874 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016875 .init_verbs = { alc662_init_verbs,
16876 alc663_two_hp_amic_m1_init_verbs },
16877 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16878 .hp_nid = 0x03,
16879 .dac_nids = alc662_dac_nids,
16880 .dig_out_nid = ALC662_DIGOUT_NID,
16881 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16882 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016883 .unsol_event = alc663_mode3_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016884 .setup = alc663_mode3_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016885 .init_hook = alc663_mode3_inithook,
16886 },
16887 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016888 .mixers = { alc663_asus_21jd_clfe_mixer },
16889 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016890 .init_verbs = { alc662_init_verbs,
16891 alc663_21jd_amic_init_verbs},
16892 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16893 .hp_nid = 0x03,
16894 .dac_nids = alc662_dac_nids,
16895 .dig_out_nid = ALC662_DIGOUT_NID,
16896 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16897 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016898 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016899 .setup = alc663_mode4_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016900 .init_hook = alc663_mode4_inithook,
16901 },
16902 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016903 .mixers = { alc663_asus_15jd_clfe_mixer },
16904 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016905 .init_verbs = { alc662_init_verbs,
16906 alc663_15jd_amic_init_verbs },
16907 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16908 .hp_nid = 0x03,
16909 .dac_nids = alc662_dac_nids,
16910 .dig_out_nid = ALC662_DIGOUT_NID,
16911 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16912 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016913 .unsol_event = alc663_mode5_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016914 .setup = alc663_mode5_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016915 .init_hook = alc663_mode5_inithook,
16916 },
16917 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016918 .mixers = { alc663_two_hp_m2_mixer },
16919 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016920 .init_verbs = { alc662_init_verbs,
16921 alc663_two_hp_amic_m2_init_verbs },
16922 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16923 .hp_nid = 0x03,
16924 .dac_nids = alc662_dac_nids,
16925 .dig_out_nid = ALC662_DIGOUT_NID,
16926 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16927 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016928 .unsol_event = alc663_mode6_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016929 .setup = alc663_mode6_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016930 .init_hook = alc663_mode6_inithook,
16931 },
Kailang Yang622e84c2009-04-21 07:39:04 +020016932 [ALC272_DELL] = {
16933 .mixers = { alc663_m51va_mixer },
16934 .cap_mixer = alc272_auto_capture_mixer,
16935 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
16936 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
16937 .dac_nids = alc662_dac_nids,
16938 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16939 .adc_nids = alc272_adc_nids,
16940 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
16941 .capsrc_nids = alc272_capsrc_nids,
16942 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020016943 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016944 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020016945 .init_hook = alc663_m51va_inithook,
16946 },
16947 [ALC272_DELL_ZM1] = {
16948 .mixers = { alc663_m51va_mixer },
16949 .cap_mixer = alc662_auto_capture_mixer,
16950 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
16951 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
16952 .dac_nids = alc662_dac_nids,
16953 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16954 .adc_nids = alc662_adc_nids,
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016955 .num_adc_nids = 1,
Kailang Yang622e84c2009-04-21 07:39:04 +020016956 .capsrc_nids = alc662_capsrc_nids,
16957 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020016958 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016959 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020016960 .init_hook = alc663_m51va_inithook,
16961 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020016962 [ALC272_SAMSUNG_NC10] = {
16963 .mixers = { alc272_nc10_mixer },
16964 .init_verbs = { alc662_init_verbs,
16965 alc663_21jd_amic_init_verbs },
16966 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
16967 .dac_nids = alc272_dac_nids,
16968 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16969 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016970 /*.input_mux = &alc272_nc10_capture_source,*/
Chris Pockelé9541ba12009-05-12 08:08:53 +020016971 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016972 .setup = alc663_mode4_setup,
Chris Pockelé9541ba12009-05-12 08:08:53 +020016973 .init_hook = alc663_mode4_inithook,
16974 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016975};
16976
16977
16978/*
16979 * BIOS auto configuration
16980 */
16981
16982/* add playback controls from the parsed DAC table */
16983static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
16984 const struct auto_pin_cfg *cfg)
16985{
16986 char name[32];
16987 static const char *chname[4] = {
16988 "Front", "Surround", NULL /*CLFE*/, "Side"
16989 };
16990 hda_nid_t nid;
16991 int i, err;
16992
16993 for (i = 0; i < cfg->line_outs; i++) {
16994 if (!spec->multiout.dac_nids[i])
16995 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020016996 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016997 if (i == 2) {
16998 /* Center/LFE */
16999 err = add_control(spec, ALC_CTL_WIDGET_VOL,
17000 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017001 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
17002 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017003 if (err < 0)
17004 return err;
17005 err = add_control(spec, ALC_CTL_WIDGET_VOL,
17006 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017007 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
17008 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017009 if (err < 0)
17010 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017011 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017012 "Center Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017013 HDA_COMPOSE_AMP_VAL(0x0e, 1, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017014 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017015 if (err < 0)
17016 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017017 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017018 "LFE Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017019 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017020 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017021 if (err < 0)
17022 return err;
17023 } else {
17024 sprintf(name, "%s Playback Volume", chname[i]);
17025 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017026 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
17027 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017028 if (err < 0)
17029 return err;
17030 sprintf(name, "%s Playback Switch", chname[i]);
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017031 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
17032 HDA_COMPOSE_AMP_VAL(alc880_idx_to_mixer(i),
17033 3, 0, HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017034 if (err < 0)
17035 return err;
17036 }
17037 }
17038 return 0;
17039}
17040
17041/* add playback controls for speaker and HP outputs */
17042static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
17043 const char *pfx)
17044{
17045 hda_nid_t nid;
17046 int err;
17047 char name[32];
17048
17049 if (!pin)
17050 return 0;
17051
Takashi Iwai24fb9172008-09-02 14:48:20 +020017052 if (pin == 0x17) {
17053 /* ALC663 has a mono output pin on 0x17 */
17054 sprintf(name, "%s Playback Switch", pfx);
17055 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
17056 HDA_COMPOSE_AMP_VAL(pin, 2, 0, HDA_OUTPUT));
17057 return err;
17058 }
17059
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017060 if (alc880_is_fixed_pin(pin)) {
17061 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai939778a2009-02-05 15:57:55 +010017062 /* printk(KERN_DEBUG "DAC nid=%x\n",nid); */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017063 /* specify the DAC as the extra output */
17064 if (!spec->multiout.hp_nid)
17065 spec->multiout.hp_nid = nid;
17066 else
17067 spec->multiout.extra_out_nid[0] = nid;
17068 /* control HP volume/switch on the output mixer amp */
17069 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
17070 sprintf(name, "%s Playback Volume", pfx);
17071 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
17072 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
17073 if (err < 0)
17074 return err;
17075 sprintf(name, "%s Playback Switch", pfx);
17076 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
17077 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
17078 if (err < 0)
17079 return err;
17080 } else if (alc880_is_multi_pin(pin)) {
17081 /* set manual connection */
17082 /* we have only a switch on HP-out PIN */
17083 sprintf(name, "%s Playback Switch", pfx);
17084 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
17085 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
17086 if (err < 0)
17087 return err;
17088 }
17089 return 0;
17090}
17091
Takashi Iwai2d864c42009-03-20 12:52:47 +010017092static int alc662_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
17093{
Takashi Iwai1327a322009-03-23 13:07:47 +010017094 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai2d864c42009-03-20 12:52:47 +010017095 return (pincap & AC_PINCAP_IN) != 0;
17096}
17097
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017098/* create playback/capture controls for input pins */
Takashi Iwai2d864c42009-03-20 12:52:47 +010017099static int alc662_auto_create_analog_input_ctls(struct hda_codec *codec,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017100 const struct auto_pin_cfg *cfg)
17101{
Takashi Iwai2d864c42009-03-20 12:52:47 +010017102 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017103 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017104 int i, err, idx;
17105
17106 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai2d864c42009-03-20 12:52:47 +010017107 if (alc662_is_input_pin(codec, cfg->input_pins[i])) {
Takashi Iwai6c819492009-08-10 18:47:44 +020017108 idx = get_connection_index(codec, 0x0b,
Takashi Iwai2d864c42009-03-20 12:52:47 +010017109 cfg->input_pins[i]);
17110 if (idx >= 0) {
17111 err = new_analog_input(spec, cfg->input_pins[i],
17112 auto_pin_cfg_labels[i],
17113 idx, 0x0b);
17114 if (err < 0)
17115 return err;
17116 }
Takashi Iwai6c819492009-08-10 18:47:44 +020017117 idx = get_connection_index(codec, 0x22,
Takashi Iwai2d864c42009-03-20 12:52:47 +010017118 cfg->input_pins[i]);
17119 if (idx >= 0) {
17120 imux->items[imux->num_items].label =
17121 auto_pin_cfg_labels[i];
17122 imux->items[imux->num_items].index = idx;
17123 imux->num_items++;
17124 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017125 }
17126 }
17127 return 0;
17128}
17129
17130static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
17131 hda_nid_t nid, int pin_type,
17132 int dac_idx)
17133{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017134 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017135 /* need the manual connection? */
17136 if (alc880_is_multi_pin(nid)) {
17137 struct alc_spec *spec = codec->spec;
17138 int idx = alc880_multi_pin_idx(nid);
17139 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
17140 AC_VERB_SET_CONNECT_SEL,
17141 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
17142 }
17143}
17144
17145static void alc662_auto_init_multi_out(struct hda_codec *codec)
17146{
17147 struct alc_spec *spec = codec->spec;
17148 int i;
17149
17150 for (i = 0; i <= HDA_SIDE; i++) {
17151 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017152 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017153 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017154 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017155 i);
17156 }
17157}
17158
17159static void alc662_auto_init_hp_out(struct hda_codec *codec)
17160{
17161 struct alc_spec *spec = codec->spec;
17162 hda_nid_t pin;
17163
17164 pin = spec->autocfg.hp_pins[0];
17165 if (pin) /* connect to front */
17166 /* use dac 0 */
17167 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017168 pin = spec->autocfg.speaker_pins[0];
17169 if (pin)
17170 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017171}
17172
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017173#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
17174
17175static void alc662_auto_init_analog_input(struct hda_codec *codec)
17176{
17177 struct alc_spec *spec = codec->spec;
17178 int i;
17179
17180 for (i = 0; i < AUTO_PIN_LAST; i++) {
17181 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai2d864c42009-03-20 12:52:47 +010017182 if (alc662_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010017183 alc_set_input_pin(codec, nid, i);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010017184 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010017185 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017186 snd_hda_codec_write(codec, nid, 0,
17187 AC_VERB_SET_AMP_GAIN_MUTE,
17188 AMP_OUT_MUTE);
17189 }
17190 }
17191}
17192
Takashi Iwaif511b012008-08-15 16:46:42 +020017193#define alc662_auto_init_input_src alc882_auto_init_input_src
17194
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017195static int alc662_parse_auto_config(struct hda_codec *codec)
17196{
17197 struct alc_spec *spec = codec->spec;
17198 int err;
17199 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
17200
17201 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
17202 alc662_ignore);
17203 if (err < 0)
17204 return err;
17205 if (!spec->autocfg.line_outs)
17206 return 0; /* can't find valid BIOS pin config */
17207
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017208 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
17209 if (err < 0)
17210 return err;
17211 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
17212 if (err < 0)
17213 return err;
17214 err = alc662_auto_create_extra_out(spec,
17215 spec->autocfg.speaker_pins[0],
17216 "Speaker");
17217 if (err < 0)
17218 return err;
17219 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
17220 "Headphone");
17221 if (err < 0)
17222 return err;
Takashi Iwai2d864c42009-03-20 12:52:47 +010017223 err = alc662_auto_create_analog_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017224 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017225 return err;
17226
17227 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
17228
Takashi Iwai0852d7a2009-02-11 11:35:15 +010017229 if (spec->autocfg.dig_outs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017230 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
17231
Takashi Iwai603c4012008-07-30 15:01:44 +020017232 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017233 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017234
17235 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017236 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020017237
Takashi Iwaid88897e2008-10-31 15:01:37 +010017238 add_verb(spec, alc662_auto_init_verbs);
Takashi Iwai24fb9172008-09-02 14:48:20 +020017239 if (codec->vendor_id == 0x10ec0663)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017240 add_verb(spec, alc663_auto_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020017241
17242 err = alc_auto_add_mic_boost(codec);
17243 if (err < 0)
17244 return err;
17245
Takashi Iwai4a79ba32009-04-22 16:31:35 +020017246 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
17247
Takashi Iwai8c87286f2007-06-19 12:11:16 +020017248 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017249}
17250
17251/* additional initialization for auto-configuration model */
17252static void alc662_auto_init(struct hda_codec *codec)
17253{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017254 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017255 alc662_auto_init_multi_out(codec);
17256 alc662_auto_init_hp_out(codec);
17257 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020017258 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017259 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020017260 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017261}
17262
17263static int patch_alc662(struct hda_codec *codec)
17264{
17265 struct alc_spec *spec;
17266 int err, board_config;
17267
17268 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
17269 if (!spec)
17270 return -ENOMEM;
17271
17272 codec->spec = spec;
17273
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020017274 alc_fix_pll_init(codec, 0x20, 0x04, 15);
17275
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017276 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
17277 alc662_models,
17278 alc662_cfg_tbl);
17279 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020017280 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
17281 codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017282 board_config = ALC662_AUTO;
17283 }
17284
17285 if (board_config == ALC662_AUTO) {
17286 /* automatic parse from the BIOS config */
17287 err = alc662_parse_auto_config(codec);
17288 if (err < 0) {
17289 alc_free(codec);
17290 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020017291 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017292 printk(KERN_INFO
17293 "hda_codec: Cannot set up configuration "
17294 "from BIOS. Using base mode...\n");
17295 board_config = ALC662_3ST_2ch_DIG;
17296 }
17297 }
17298
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090017299 err = snd_hda_attach_beep_device(codec, 0x1);
17300 if (err < 0) {
17301 alc_free(codec);
17302 return err;
17303 }
17304
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017305 if (board_config != ALC662_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020017306 setup_preset(codec, &alc662_presets[board_config]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017307
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017308 spec->stream_analog_playback = &alc662_pcm_analog_playback;
17309 spec->stream_analog_capture = &alc662_pcm_analog_capture;
17310
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017311 spec->stream_digital_playback = &alc662_pcm_digital_playback;
17312 spec->stream_digital_capture = &alc662_pcm_digital_capture;
17313
Takashi Iwaidd704692009-08-11 08:45:11 +020017314 if (!spec->adc_nids) {
17315 spec->adc_nids = alc662_adc_nids;
17316 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
17317 }
17318 if (!spec->capsrc_nids)
17319 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017320
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017321 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017322 set_capture_mixer(codec);
Takashi Iwaib9591442009-03-16 15:25:00 +010017323 if (codec->vendor_id == 0x10ec0662)
17324 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
17325 else
17326 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017327
Takashi Iwai2134ea42008-01-10 16:53:55 +010017328 spec->vmaster_nid = 0x02;
17329
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017330 codec->patch_ops = alc_patch_ops;
17331 if (board_config == ALC662_AUTO)
17332 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020017333#ifdef CONFIG_SND_HDA_POWER_SAVE
17334 if (!spec->loopback.amplist)
17335 spec->loopback.amplist = alc662_loopbacks;
17336#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010017337 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017338
17339 return 0;
17340}
17341
17342/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070017343 * patch entries
17344 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017345static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070017346 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010017347 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017348 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020017349 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017350 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020017351 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017352 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017353 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017354 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
17355 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
17356 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017357 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017358 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017359 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
17360 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017361 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017362 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017363 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020017364 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +020017365 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017366 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020017367 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017368 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +010017369 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020017370 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 },
Kailang Yang44426082008-10-15 11:18:05 +020017371 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017372 .patch = patch_alc882 },
17373 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc882 },
17374 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017375 {} /* terminator */
17376};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017377
17378MODULE_ALIAS("snd-hda-codec-id:10ec*");
17379
17380MODULE_LICENSE("GPL");
17381MODULE_DESCRIPTION("Realtek HD-audio codec");
17382
17383static struct hda_codec_preset_list realtek_list = {
17384 .preset = snd_hda_preset_realtek,
17385 .owner = THIS_MODULE,
17386};
17387
17388static int __init patch_realtek_init(void)
17389{
17390 return snd_hda_add_codec_preset(&realtek_list);
17391}
17392
17393static void __exit patch_realtek_exit(void)
17394{
17395 snd_hda_delete_codec_preset(&realtek_list);
17396}
17397
17398module_init(patch_realtek_init)
17399module_exit(patch_realtek_exit)